GNU bug report logs -
#69097
[PATCH] Add 'kill-region-or-word' command
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Tue, 13 Feb 2024 09:57:02 UTC
Severity: normal
Tags: patch
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
Message #122 received at 69097 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Mon 02 Sep 2024 at 11:30am -07, Stefan Kangas wrote:
> Binding C-w to backward-kill-word, or some version thereof, is an old
> Emacs power user trick that has been recommended in many places over the
> years. See, for example:
> https://sites.google.com/site/steveyegge2/effective-emacs#h.p_ID_193
> https://emacs-fu.blogspot.com/2009/11/copying-lines-without-selecting-them.html
>
> So I think this command would be a good addition. Making the word
> boundary behaviour into a tristate option sounds like a reasonable way
> forward, which should make everyone happy and let people experiment with
> what works best for them.
For reference purposes while implementing the tristate, here is my
implementation of the Unix behaviour from my init.
Should be helpful, though there is lots of room for improvement :)
(defun spw/unix-word-rubout (arg &optional pos neg)
(interactive "p")
;; Do skip over \n because `backward-kill-word' does.
(unless pos (setq pos "[:space:]\n"))
(unless neg (setq neg "^[:space:]\n"))
(undo-boundary)
(let ((start (point)))
;; Go only backwards.
(dotimes (_ (abs arg))
(skip-chars-backward pos)
(skip-chars-backward neg))
;; Skip forward over any read-only text (e.g. an Eshell or comint prompt).
(when-let ((beg (and (get-char-property (point) 'read-only)
(next-single-char-property-change
(point) 'read-only nil start))))
(goto-char beg))
(kill-region start (point))))
--
Sean Whitton
This bug report was last modified 243 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.