From: Philip Kaludercic <philipk@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rms@gnu.org, 69097@debbugs.gnu.org, juri@linkov.net,
Stefan Kangas <stefankangas@gmail.com>,
Andrea Corallo <acorallo@gnu.org>,
spwhitton@spwhitton.name
Subject: bug#69097: [PATCH] Add 'kill-region-or-word' command
Date: Mon, 02 Sep 2024 20:39:52 +0000 [thread overview]
Message-ID: <87cyllg57r.fsf@posteo.net> (raw)
In-Reply-To: <867cbu9uce.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 02 Sep 2024 14:18:57 +0300")
Stefan Kangas <stefankangas@gmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Philip Kaludercic <philipk@posteo.net>
>>> Cc: Sean Whitton <spwhitton@spwhitton.name>, juri@linkov.net, rms@gnu.org,
>>> 69097@debbugs.gnu.org
>>> Date: Sun, 01 Sep 2024 20:06:00 +0000
>>>
>>> Ping. I am not sure how to proceed on this patch. IIRC the issue was
>>> that the notion of a word differs in Emacs and in Bash. I am still in
>>> favour of utilising Emacs's definition, as it remains more useful
>>> for some given major mode and the fact that it is easier to implement.
>>
>> Or you could make the defcustom a tristate, and implement both
>> behaviors...
>>
>> As for how to proceed: Stefan and Andrea, do you have an opinion on
>> this?
>
> 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.
How about this suggestion: We add a generic kill-region-or-word
command, and a user option for a function (set to either
`backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a
patch with the simpler version, and then Sean can add his behaviour in a
second patch so that the attribution remains correct.
Sean Whitton <spwhitton@spwhitton.name> writes:
> 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))))
FWIW I don't have any suggestions on how to improve the function either.
I wonder if it would make sense to have a minor mode like subword-mode
that would enforce a understanding of words like implemented here.
--
Philip Kaludercic on peregrine
next prev parent reply other threads:[~2024-09-02 20:39 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 9:55 bug#69097: [PATCH] Add 'kill-region-or-word' command Philip Kaludercic
2024-02-17 3:53 ` Richard Stallman
[not found] ` <87ttm7gi9i.fsf@posteo.net>
2024-02-19 3:44 ` Richard Stallman
[not found] ` <87sf1obkw9.fsf@posteo.net>
2024-02-23 3:04 ` Richard Stallman
[not found] ` <871q93rzv8.fsf@posteo.net>
2024-02-25 3:16 ` Richard Stallman
[not found] ` <87frxgn73g.fsf@posteo.net>
2024-02-27 3:12 ` Richard Stallman
2024-05-03 7:37 ` Philip Kaludercic
2024-05-03 10:40 ` Eli Zaretskii
2024-05-03 10:48 ` Philip Kaludercic
2024-05-03 10:59 ` Eli Zaretskii
2024-05-03 11:04 ` Eli Zaretskii
2024-05-03 17:32 ` Philip Kaludercic
2024-05-03 18:01 ` Eli Zaretskii
2024-05-03 19:41 ` Philip Kaludercic
2024-05-04 6:20 ` Eli Zaretskii
2024-05-05 6:53 ` Juri Linkov
2024-05-05 9:04 ` Eli Zaretskii
2024-05-05 16:29 ` Juri Linkov
2024-05-05 16:54 ` Philip Kaludercic
2024-05-05 16:59 ` Juri Linkov
2024-05-05 17:08 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 18:27 ` Philip Kaludercic
2024-05-05 17:05 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 17:13 ` Eli Zaretskii
2024-05-05 17:53 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 0:21 ` Sean Whitton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 16:46 ` Sean Whitton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 16:51 ` Sean Whitton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 17:55 ` Eli Zaretskii
2024-05-07 8:47 ` Sean Whitton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-07 8:47 ` Sean Whitton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-01 20:06 ` Philip Kaludercic
2024-09-02 6:36 ` Sean Whitton
2024-09-02 11:18 ` Eli Zaretskii
2024-09-02 18:30 ` Stefan Kangas
2024-09-02 18:45 ` Sean Whitton
2024-09-02 20:39 ` Philip Kaludercic [this message]
2024-09-02 20:42 ` Sean Whitton
2024-09-02 20:45 ` Philip Kaludercic
2024-09-02 20:46 ` Sean Whitton
2024-09-02 21:12 ` Philip Kaludercic
2024-09-03 12:21 ` Eli Zaretskii
2024-09-03 13:53 ` Robert Pluim
2024-09-03 14:27 ` Eli Zaretskii
2024-09-03 14:55 ` Robert Pluim
2024-09-03 15:32 ` Eli Zaretskii
2024-09-03 16:32 ` Philip Kaludercic
2024-09-03 16:47 ` Robert Pluim
2024-09-04 11:08 ` Eli Zaretskii
2024-09-04 14:07 ` Sean Whitton
2024-09-04 14:21 ` Eli Zaretskii
2024-09-05 9:39 ` Philip Kaludercic
2024-09-05 9:52 ` Eli Zaretskii
2024-09-05 10:02 ` Philip Kaludercic
2024-09-05 10:19 ` Eli Zaretskii
2024-09-05 10:23 ` Philip Kaludercic
2024-09-05 13:27 ` Sean Whitton
2024-09-05 14:38 ` Philip Kaludercic
2024-09-06 10:36 ` Sean Whitton
2024-09-06 11:06 ` Sean Whitton
2024-09-06 11:30 ` Eli Zaretskii
2024-09-06 13:54 ` Sean Whitton
2024-09-06 16:32 ` Philip Kaludercic
2024-09-07 9:52 ` Eli Zaretskii
2024-09-07 10:10 ` Philip Kaludercic
2024-09-07 21:08 ` Sean Whitton
2024-09-07 21:17 ` Sean Whitton
2024-09-09 17:54 ` Sean Whitton
2024-09-09 19:03 ` Eli Zaretskii
2024-09-09 19:48 ` Sean Whitton
2024-09-09 19:23 ` Philip Kaludercic
2024-09-14 9:12 ` Eli Zaretskii
2024-09-14 11:27 ` Sean Whitton
2024-09-14 13:39 ` Philip Kaludercic
2024-09-14 14:05 ` Eli Zaretskii
2024-09-14 14:13 ` Philip Kaludercic
2024-09-14 14:24 ` Eli Zaretskii
2024-09-14 16:10 ` Sean Whitton
2024-09-14 16:26 ` German Pacenza
2024-09-14 16:36 ` Sean Whitton
2024-09-14 21:19 ` Philip Kaludercic
2024-09-14 21:22 ` Sean Whitton
2024-09-17 17:58 ` Juri Linkov
2024-09-18 16:08 ` Juri Linkov
2024-09-19 7:19 ` Philip Kaludercic
2024-09-20 6:50 ` Juri Linkov
2024-09-20 16:57 ` Philip Kaludercic
2024-09-08 10:38 ` Philip Kaludercic
2024-05-05 16:47 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-03 16:20 ` Philip Kaludercic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cyllg57r.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=69097@debbugs.gnu.org \
--cc=acorallo@gnu.org \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
--cc=rms@gnu.org \
--cc=spwhitton@spwhitton.name \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.