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>, Phil Sainty <psainty <at> orcon.net.nz>
Cc: "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 16:58:10 +0000
> > 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))




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.