unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
@ 2024-10-09 20:33 Phil Sainty
  2024-10-09 23:47 ` Stefan Kangas
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Phil Sainty @ 2024-10-09 20:33 UTC (permalink / raw)
  To: 73723

I find the following useful, and sometimes see others asking for
the same thing.  Shall we add these to Emacs?

  (defun isearch-copy-match ()
    "Copy the currently-matched text to the kill ring."
    (interactive)
    (kill-new (buffer-substring (min (point) isearch-other-end)
                                (max (point) isearch-other-end))))

  (defun isearch-kill-match ()
    "Kill the currently-matched text."
    (interactive)
    (kill-region (min (point) isearch-other-end)
                 (max (point) isearch-other-end)))

  (defun isearch-mark-match ()
    "Exit isearch, marking the last match."
    (interactive)
    (set-mark isearch-other-end)
    (isearch-exit)
    (activate-mark))

  (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
  (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
  (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
  (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-09 20:33 bug#73723: 31.0.50; Add copy/kill/mark commands to isearch Phil Sainty
@ 2024-10-09 23:47 ` Stefan Kangas
  2024-10-10  4:48 ` Eli Zaretskii
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Stefan Kangas @ 2024-10-09 23:47 UTC (permalink / raw)
  To: Phil Sainty, 73723

Phil Sainty <psainty@orcon.net.nz> writes:

> I find the following useful, and sometimes see others asking for
> the same thing.  Shall we add these to Emacs?
>
>   (defun isearch-copy-match ()
>     "Copy the currently-matched text to the kill ring."
>     (interactive)
>     (kill-new (buffer-substring (min (point) isearch-other-end)
>                                 (max (point) isearch-other-end))))
>
>   (defun isearch-kill-match ()
>     "Kill the currently-matched text."
>     (interactive)
>     (kill-region (min (point) isearch-other-end)
>                  (max (point) isearch-other-end)))
>
>   (defun isearch-mark-match ()
>     "Exit isearch, marking the last match."
>     (interactive)
>     (set-mark isearch-other-end)
>     (isearch-exit)
>     (activate-mark))
>
>   (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
>   (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
>   (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
>   (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)

It looks like a fine addition to me.  We'd need the usual documentation,
NEWS entry, etc., though.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-09 20:33 bug#73723: 31.0.50; Add copy/kill/mark commands to isearch Phil Sainty
  2024-10-09 23:47 ` Stefan Kangas
@ 2024-10-10  4:48 ` Eli Zaretskii
  2024-10-10 12:10   ` Phil Sainty
  2024-10-10  6:37 ` Juri Linkov
  2024-10-10 22:04 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  3 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2024-10-10  4:48 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 73723

> Date: Thu, 10 Oct 2024 09:33:41 +1300
> From: Phil Sainty <psainty@orcon.net.nz>
> 
> I find the following useful, and sometimes see others asking for
> the same thing.  Shall we add these to Emacs?
> 
>   (defun isearch-copy-match ()
>     "Copy the currently-matched text to the kill ring."
>     (interactive)
>     (kill-new (buffer-substring (min (point) isearch-other-end)
>                                 (max (point) isearch-other-end))))
> 
>   (defun isearch-kill-match ()
>     "Kill the currently-matched text."
>     (interactive)
>     (kill-region (min (point) isearch-other-end)
>                  (max (point) isearch-other-end)))
> 
>   (defun isearch-mark-match ()
>     "Exit isearch, marking the last match."
>     (interactive)
>     (set-mark isearch-other-end)
>     (isearch-exit)
>     (activate-mark))
> 
>   (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
>   (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
>   (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
>   (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)

Sounds useful, but "M-x M-w" is already taken, unfortunately.

For isearch-kill-match, should there also be a command to kill _all_
the matches?

Thanks.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-09 20:33 bug#73723: 31.0.50; Add copy/kill/mark commands to isearch Phil Sainty
  2024-10-09 23:47 ` Stefan Kangas
  2024-10-10  4:48 ` Eli Zaretskii
@ 2024-10-10  6:37 ` Juri Linkov
  2024-10-10  7:38   ` Eli Zaretskii
  2024-10-10 16:58   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 22:04 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  3 siblings, 2 replies; 15+ messages in thread
From: Juri Linkov @ 2024-10-10  6:37 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 73723

> I find the following useful, and sometimes see others asking for
> the same thing.  Shall we add these to Emacs?
>
>  (defun isearch-copy-match ()
>    "Copy the currently-matched text to the kill ring."
>    (interactive)
>    (kill-new (buffer-substring (min (point) isearch-other-end)
>                                (max (point) isearch-other-end))))
>
>  (defun isearch-kill-match ()
>    "Kill the currently-matched text."
>    (interactive)
>    (kill-region (min (point) isearch-other-end)
>                 (max (point) isearch-other-end)))
>
>  (defun isearch-mark-match ()
>    "Exit isearch, marking the last match."
>    (interactive)
>    (set-mark isearch-other-end)
>    (isearch-exit)
>    (activate-mark))
>
>  (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
>  (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
>  (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
>  (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)

I have a patch that I'm using for a long time every day.
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.  Does this eliminate the need
to add more Isearch commands?





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10  6:37 ` Juri Linkov
@ 2024-10-10  7:38   ` Eli Zaretskii
  2024-10-10 17:32     ` Juri Linkov
  2024-10-10 16:58   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2024-10-10  7:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: psainty, 73723

> Cc: 73723@debbugs.gnu.org
> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 10 Oct 2024 09:37:37 +0300
> 
> >  (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
> >  (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
> >  (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
> >  (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)
> 
> I have a patch that I'm using for a long time every day.
> It allows exiting Isearch with 'S-RET' that activates
> the region on the current match.

S-RET will not work on text terminals.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10  4:48 ` Eli Zaretskii
@ 2024-10-10 12:10   ` Phil Sainty
  0 siblings, 0 replies; 15+ messages in thread
From: Phil Sainty @ 2024-10-10 12:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 73723

On 2024-10-10 17:48, Eli Zaretskii wrote:
>> Date: Thu, 10 Oct 2024 09:33:41 +1300
>> From: Phil Sainty <psainty@orcon.net.nz>
>>   (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
>>   (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
>>   (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
>>   (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)
> 
> Sounds useful, but "M-x M-w" is already taken, unfortunately.

"M-s M-w" does have a binding to `eww-search-words' in the global 
keymap,
but I'm not sure that needs to prevent us using it here?

Certainly `eww-search-words' doesn't react to the current isearch match,
so I think there's not currently a particular reason why one would 
invoke
the global binding whilst isearching.  (You *could* set the mark and 
then
search to extend the region before calling `eww-search-words' for that
region; but you could trivially still do that simply by exiting the
isearch explicitly.)


> For isearch-kill-match, should there also be a command to kill _all_
> the matches?

Potentially, although there's a library iedit.el which provides that
kind of functionality.  It has an `iedit-mode-from-isearch' command
to invoke iedit on the matched text.  (Although to specifically kill
all matches, it looks like you'd need to follow that command by
restarting the isearch and *then* call `isearch-kill-match'.


-Phil






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10  6:37 ` Juri Linkov
  2024-10-10  7:38   ` Eli Zaretskii
@ 2024-10-10 16:58   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 17:35     ` Juri Linkov
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-10 16:58 UTC (permalink / raw)
  To: Juri Linkov, Phil Sainty; +Cc: 73723@debbugs.gnu.org

> > I find the following useful, and sometimes see others asking for
> > the same thing.  Shall we add these to Emacs?
> >
> >  (defun isearch-copy-match ()
> >    "Copy the currently-matched text to the kill ring."
> >    (interactive)
> >    (kill-new (buffer-substring (min (point) isearch-other-end)
> >                                (max (point) isearch-other-end))))
> >
> >  (defun isearch-kill-match ()
> >    "Kill the currently-matched text."
> >    (interactive)
> >    (kill-region (min (point) isearch-other-end)
> >                 (max (point) isearch-other-end)))
> >
> >  (defun isearch-mark-match ()
> >    "Exit isearch, marking the last match."
> >    (interactive)
> >    (set-mark isearch-other-end)
> >    (isearch-exit)
> >    (activate-mark))
> >
> >  (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
> >  (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
> >  (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
> >  (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)
> 
> I have a patch that I'm using for a long time every day.
> 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.  Does this eliminate the need
> to add more Isearch commands?

FWIW, in isearch+.el I define `isearchp-kill-ring-save'
and bind it to `M-w'.
This has been the case since 2013.

(defun isearchp-kill-ring-save () ; Bound to `M-w' in `isearch-mode-map'.
  "Copy the current search string to the kill ring."
  (interactive)
  (kill-new isearch-string)
  (let ((message-log-max  nil)) (message "Copied search string as kill"))
  (sit-for 1)
  (isearch-update))





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10  7:38   ` Eli Zaretskii
@ 2024-10-10 17:32     ` Juri Linkov
  0 siblings, 0 replies; 15+ messages in thread
From: Juri Linkov @ 2024-10-10 17:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: psainty, 73723

>> >  (define-key isearch-mode-map (kbd "M-s M-w") #'isearch-copy-match)
>> >  (define-key isearch-mode-map (kbd "M-s C-w") #'isearch-kill-match)
>> >  (define-key isearch-mode-map (kbd "M-s C-SPC") #'isearch-mark-match)
>> >  (define-key isearch-mode-map (kbd "M-s C-@") #'isearch-mark-match)
>>
>> I have a patch that I'm using for a long time every day.
>> It allows exiting Isearch with 'S-RET' that activates
>> the region on the current match.
>
> S-RET will not work on text terminals.

I see that S-left and S-right arrows work on text terminals
via 'this-command-keys-shift-translated', but S-RET
doesn't set 'this-command-keys-shift-translated'.

Then isearch-exit could support a prefix argument to
activate the region on exit like Gregory proposed in
https://debbugs.gnu.org/47599#34
with three values of prefix arguments to isearch-exit:
C-u  RET moves point to the other end,
C-u C-u RET activates region around match,
C-u C-u C-u RET moves point to the other end
                and activate region around match.
But then Ergus proposed M-RET or M-s RET.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 16:58   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-10 17:35     ` Juri Linkov
  2024-10-10 18:20       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2024-10-10 17:35 UTC (permalink / raw)
  To: Drew Adams; +Cc: Phil Sainty, 73723@debbugs.gnu.org

>> 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.
>
> (defun isearchp-kill-ring-save () ; Bound to `M-w' in `isearch-mode-map'.
>   "Copy the current search string to the kill ring."
>   (interactive)
>   (kill-new isearch-string)
>   (let ((message-log-max  nil)) (message "Copied search string as kill"))
>   (sit-for 1)
>   (isearch-update))

Since `M-w' can't be used according to the comments in
https://old.reddit.com/r/emacs/comments/1fzvwig/copy_search_string_to_killring/
what remains is `M-s M-w'.

OTOH, `S-RET M-w' is shorter than `M-s M-w RET'.
But since `S-RET' is not available on text terminals
what remains is still `M-s M-w RET' or `M-s RET M-w'.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 17:35     ` Juri Linkov
@ 2024-10-10 18:20       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 18:31         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 18:40         ` Juri Linkov
  0 siblings, 2 replies; 15+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-10 18:20 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Phil Sainty, 73723@debbugs.gnu.org

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





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 18:20       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-10 18:31         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 18:41           ` Juri Linkov
  2024-10-10 18:40         ` Juri Linkov
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-10 18:31 UTC (permalink / raw)
  To: Drew Adams, Juri Linkov; +Cc: Phil Sainty, 73723@debbugs.gnu.org

Sorry, I misspoke.  I was thinking that my `M-w'
copies the current search _match_, but it copies
the search string (input pattern), `isearch-string'.

The argument that it's better to use `M-w' during
search for that because you can use it multiple
times still holds, but only because you can change
the search pattern (during search) - not _also_
because the same pattern can match different text.

It probably makes sense to also have a command
that copies the current search match.  And maybe
that's the best candidate for `M-w' (not a command
that copies `isearch-string').





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 18:20       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-10-10 18:31         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-10 18:40         ` Juri Linkov
  1 sibling, 0 replies; 15+ messages in thread
From: Juri Linkov @ 2024-10-10 18:40 UTC (permalink / raw)
  To: Drew Adams; +Cc: Phil Sainty, 73723@debbugs.gnu.org

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

Yes, I meant exactly this feedback.

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

Like 'C-x C-x' etc.  But 'C-x C-x' can't activate the region
on the last match.  Therefore we need another key binding.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 18:31         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-10 18:41           ` Juri Linkov
  2024-10-10 18:54             ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2024-10-10 18:41 UTC (permalink / raw)
  To: Drew Adams; +Cc: Phil Sainty, 73723@debbugs.gnu.org

> Sorry, I misspoke.  I was thinking that my `M-w'
> copies the current search _match_, but it copies
> the search string (input pattern), `isearch-string'.

But it's easy to copy the search string with just
'M-e C-a C-k'.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-10 18:41           ` Juri Linkov
@ 2024-10-10 18:54             ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 15+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-10 18:54 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Phil Sainty, 73723@debbugs.gnu.org

> > Sorry, I misspoke.  I was thinking that my `M-w'
> > copies the current search _match_, but it copies
> > the search string (input pattern), `isearch-string'.
> 
> But it's easy to copy the search string with just
> 'M-e C-a C-k'.

Not as easy as `M-w'.

But I do think it makes sense to _also_ have a key
to copy the current _match_.  Both of those should
be short keys.

The use case of wanting to set mark at the initial
position, so you can get back there or activate the
region back to there (actions that take place when
you're _done_ searching), can be on a longer key
sequence.  Why?  Because it's useful at most _once_
during search.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#73723: 31.0.50; Add copy/kill/mark commands to isearch
  2024-10-09 20:33 bug#73723: 31.0.50; Add copy/kill/mark commands to isearch Phil Sainty
                   ` (2 preceding siblings ...)
  2024-10-10  6:37 ` Juri Linkov
@ 2024-10-10 22:04 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
  3 siblings, 0 replies; 15+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-10 22:04 UTC (permalink / raw)
  To: Phil Sainty, 73723@debbugs.gnu.org

>   (defun isearch-copy-match ()
>     "Copy the currently-matched text to the kill ring."
>     (interactive)
>     (kill-new (buffer-substring (min (point) isearch-other-end)
>                                 (max (point) isearch-other-end))))
> 
>   (defun isearch-kill-match ()
>     "Kill the currently-matched text."
>     (interactive)
>     (kill-region (min (point) isearch-other-end)
>                  (max (point) isearch-other-end)))

Two minor suggestions:

. Neither buffer-substring nor kill-region needs the
  positions in any particular order - don't need min/max.
  E.g., just (kill-region (point) isearch-other-end) 

. Show a message at the end of `isearch-copy-match':
  (let ((message-log-max  nil))
    (message "Copied search match as kill"))
  (sit-for 1)
  (isearch-update)





^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-10-10 22:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 20:33 bug#73723: 31.0.50; Add copy/kill/mark commands to isearch Phil Sainty
2024-10-09 23:47 ` Stefan Kangas
2024-10-10  4:48 ` Eli Zaretskii
2024-10-10 12:10   ` Phil Sainty
2024-10-10  6:37 ` Juri Linkov
2024-10-10  7:38   ` Eli Zaretskii
2024-10-10 17:32     ` Juri Linkov
2024-10-10 16:58   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 17:35     ` Juri Linkov
2024-10-10 18:20       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 18:31         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 18:41           ` Juri Linkov
2024-10-10 18:54             ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 18:40         ` Juri Linkov
2024-10-10 22:04 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).