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
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas <stefankangas <at> gmail.com>,
>> Andrea Corallo <acorallo <at> gnu.org>, juri <at> linkov.net, rms <at> gnu.org,
>> 69097 <at> debbugs.gnu.org
>> Date: Mon, 02 Sep 2024 21:12:01 +0000
>>
>> I had misremembered the last state of this patch. It is easier to just
>> have a tristate option. Here is the updated proposal:
>
> Thanks.
>
>> +(defcustom kill-word-if-no-region nil
>
> I would call this 'kill-region-dwim' instead.
Can do.
>> + "Behaviour when `kill-region' is invoked without an active region.
>> +If set to nil (default), then an error occurs and nothing is killed. If
>> +set to `emacs-word', then kill a the last word as defined by the current
>> +major mode. If set to `unix-word', then kill the last word in the style
>> +of a shell like Bash, disregarding the major mode."
>> + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word)
>> + (const :tag "Kill a word like Bash would" unix-word)
>> + (const :tag "Do not kill anything" nil))
>> + :group 'killing)
>
> :version tag is missing.
Whoops, added it.
>> -Lisp programs should use this function for killing text.
>> - (To delete text, use `delete-region'.)
>> -Supply two arguments, character positions BEG and END indicating the
>> - stretch of text to be killed. If the optional argument REGION is
>> - non-nil, the function ignores BEG and END, and kills the current
>> - region instead. Interactively, REGION is always non-nil, and so
>> - this command always kills the current region."
>> +Lisp programs should use this function for killing text. (To delete
>> +text, use `delete-region'.) Supply two arguments, character positions
>> +BEG and END indicating the stretch of text to be killed. If the
>> +optional argument REGION is non-nil, the function ignores BEG and END,
>> +and kills the current region instead. If REGION has the special value
>
> Not sure why you decided to reformat this part. Its formatting was
> not random.
I think this was just an accidental M-q.
> This also needs a NEWS entry.
I've added the NEWS entry from the last iteration of the patch (now
actually as a patch, not just a diff):
[0001-Allow-kill-region-kill-the-last-word-when-there-is-n.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Robert Pluim <rpluim <at> gmail.com> writes:
>>>>>> On Tue, 03 Sep 2024 15:21:54 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
>
> >> From: Philip Kaludercic <philipk <at> posteo.net>
> >> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas <stefankangas <at> gmail.com>,
> >> Andrea Corallo <acorallo <at> gnu.org>, juri <at> linkov.net, rms <at> gnu.org,
> >> 69097 <at> debbugs.gnu.org
> >> Date: Mon, 02 Sep 2024 21:12:01 +0000
> >>
> >> I had misremembered the last state of this patch. It is easier to just
> >> have a tristate option. Here is the updated proposal:
>
> Eli> Thanks.
>
> >> +(defcustom kill-word-if-no-region nil
>
> Eli> I would call this 'kill-region-dwim' instead.
>
> >> + "Behaviour when `kill-region' is invoked without an active region.
> >> +If set to nil (default), then an error occurs and nothing is killed. If
> >> +set to `emacs-word', then kill a the last word as defined by the current
> >> +major mode. If set to `unix-word', then kill the last word in the style
> >> +of a shell like Bash, disregarding the major mode."
> >> + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word)
> >> + (const :tag "Kill a word like Bash would" unix-word)
> >> + (const :tag "Do not kill anything" nil))
> >> + :group 'killing)
>
> Eli> :version tag is missing.
>
> Is it worth allowing a user-specified function?
That would be possible as well, but to make it manageable with the
current approach the function would have to be one that moves the point.
So we could rewrite the patch with two default options `backward-word'
and `unix-backward-word' (which we would have to add), but I am not sure
it would have much use. Perhaps killing the current word, instead of
just killing to the beginning?
> Robert
--
Philip Kaludercic on peregrine
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.