GNU bug report logs - #69097
[PATCH] Add 'kill-region-or-word' command

Previous Next

Package: emacs;

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


View this message in rfc822 format

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>, philipk <at> posteo.net,  rms <at> gnu.org,  69097 <at> debbugs.gnu.org
Subject: bug#69097: [PATCH] Add 'kill-region-or-word' command
Date: Mon, 06 May 2024 17:46:20 +0100
Hello,

On Sun 05 May 2024 at 12:04pm +03, Eli Zaretskii wrote:

>> From: Juri Linkov <juri <at> linkov.net>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,  rms <at> gnu.org,  69097 <at> debbugs.gnu.org
>> Date: Sun, 05 May 2024 09:53:19 +0300
>>
>> > +(defcustom kill-word-if-no-region nil
>> > +  "Non-nil means that `kill-region' without a region will kill the last word."
>> > +  :type 'boolean
>> > +  :group 'killing)
>>
>> What a strange thing.  `kill-region' is not related to word commands
>> in no way.  Why not kill a sentence?  Why not kill a line?  Why just word?
>> All existing commands handle an active region.  But there is no commands
>> that do in the opposite direction where a general command handles
>> one random specific case.  This is because the region is a more
>> general concept.
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69097#14 is supposed to
> provide the rationale (consistency with what C-w does in a terminal,
> which I presume means in Bash or similar programs which use
> Readline?).

I am concerned that the difference between Emacs's backward-kill-word
and the tty unix-word-rubout is not being taken into account with this
change proposal.

In bash on Linux there is actually both M-DEL and C-w, and they do
different things, and it's useful to have both.
E.g. if you have a half-entered command

    % foo bar/baz/quux

with point at the end of the line, then M-DEL can be used to delete
individual path components, e.g. M-DEL M-DEL will get you

    % foo bar/

which is nice if you need to correct some path components.
But C-w always deletes back to whitespace, in this case leaving just
'foo', so you can replace the whole argument, or several arguments, with
C-w, instead of having to type M-DEL lots of times.

So if what we're aiming for here is concordance with the terminal, then
the fallback behaviour should not be Emacs's backward-kill-word, but a
new command that's more like unix-word-rubout.

But then, I'm not sure introducing something that funadmental to Emacs's
basic command set is appropriate in the context of thinking about
fallback behaviour.

(I have C-w in Emacs be like unix-word-rubout, keep M-DEL as the
default, and move kill-region elsewhere.)

-- 
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.