[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#69097: [PATCH] Add 'kill-region-or-word' command
From: |
Sean Whitton |
Subject: |
bug#69097: [PATCH] Add 'kill-region-or-word' command |
Date: |
Mon, 02 Sep 2024 19:45:25 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Philip Kaludercic, 2024/09/01
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Sean Whitton, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Eli Zaretskii, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Stefan Kangas, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command,
Sean Whitton <=
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Philip Kaludercic, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Sean Whitton, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Philip Kaludercic, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Sean Whitton, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Philip Kaludercic, 2024/09/02
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Eli Zaretskii, 2024/09/03
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Robert Pluim, 2024/09/03
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Eli Zaretskii, 2024/09/03
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Robert Pluim, 2024/09/03
- bug#69097: [PATCH] Add 'kill-region-or-word' command, Eli Zaretskii, 2024/09/03