GNU bug report logs - #73723
31.0.50; Add copy/kill/mark commands to isearch

Previous Next

Package: emacs;

Reported by: Phil Sainty <psainty <at> orcon.net.nz>

Date: Wed, 9 Oct 2024 20:37:02 UTC

Severity: wishlist

Tags: patch

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, "73723 <at> debbugs.gnu.org" <73723 <at> debbugs.gnu.org>
Subject: bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
Date: Thu, 10 Oct 2024 18:20:15 +0000
> >> It allows exiting Isearch with 'S-RET' that activates
> >> the region on the current match.  This allows using
> >> the standard keys afterwards: 'M-w' to copy the match,
> >> 'C-w' to kill the match, etc.
> >
> > FWIW, in isearch+.el I define `isearchp-kill-ring-save'
> > and bind it to `M-w'.
> > This has been the case since 2013.
> 
> Since `M-w' can't be used according to the comments in
> https://urldefense.com/v3/__https://old.reddit.com/r/emacs/comments/1fzv
> wig/copy_search_string_to_killring/__;!!ACWV5N9M2RV99hQ!L5HGxhm07QP4heBq
> z0oZG6Hs1DF2e5hty8aAHJG_sxr39y7pRCFJPoP2E_m9P8iyv-lGni4NgqrGZg$

I don't see anything there that says why `M-w' can't
be used.  What's the reason you think is given there?
Is it this?

  "I have muscle memory for pressing M-w to end the
   search and save the region from where point was
   before starting isearch to the location where the
   search string was found."

?

There are other ways to get the region to be from the
initial position to the end (if forward) or the start
(if backward) of the search match.

In any case, we are (should be) talking about default
key bindings (in `isearch-mode-map').  Both copying
the search match as a kill and setting the region to
origin-to-search-end are useful, and they can both have
default key bindings.  Which should be `M-w' by default
is something to decide.

You know what my recommendation is: copy the match.
IME, if someone wants to set the region from the initial
position they usually know that _before_ searching - in
which case it's enough to do `C-SPC' before searching.

* `M-w' _during_ search should copy the search match
because it can be done anytime _during_ a search.  It
can even be done multiple times _during_ a search, and
for the _same or different search patterns_.  It's a
very useful, versatile operation.

* `M-w' _after_ a search is something else, whether or
not you want to extend the region to initial position.

It makes no sense to use a key to set the region from
the initial position more than once during a search.
At most once per search is all you need, for that.

The question is whether to have a `isearch-mode-map'
key to _set the mark_ at the initial position (instead
of someone setting mark there before searching).

If we have such a key, then `M-w' _after_ the search
is just the _normal_ `M-w': `kill-ring-save'.  IOW,
we need not have a search-map key to set that region,
since that's done after searching (and once only).

To implement a command to _set mark_ at init position
during search we can always let-bind that position at
the outset, and then use it only when a user hits the
key to set the mark there (and that key shouldn't be
`M-w'.)

> what remains is `M-s M-w'.

Lots of possibilities remain.  But you might want to
use `M-s M-w' not for copying search matches but for
setting mark at the initial position.

Why?  See above: You only do that once, and you might
want to copy multiple (different) search matches to
the kill ring during the same search.  The key for
copying search matches should be `M-w' (IMO).




This bug report was last modified 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.