all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#39512: 28.0.50; Add command isearch-yank-region
@ 2020-02-08 18:04 Tino Calancha
  2020-02-08 23:47 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-02-09  0:31 ` Juri Linkov
  0 siblings, 2 replies; 21+ messages in thread
From: Tino Calancha @ 2020-02-08 18:04 UTC (permalink / raw)
  To: 39512; +Cc: spacibba, npostavs, juri, contovob

Severity: wishlist
Tags: patch
X-Debbugs-Cc: spacibba@aol.com,juri@linkov.net,drew.adams@oracle.com,npostavs@gmail.com,contovob@tcd.ie,eliz@gnu.org

I wish to have this command; it naturally completes other
isearch-yank-... cases.

This topic has been already discussed in the following links:

https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg01125.html
https://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00003.html

Note that in those threads there were plenty of discussions; here I'd
like to focus just in this proposed command.  If needed, I'd recommend
to open further bugs to discuss about other commands.

I let this command to start the interactive search if we are
not already there; from the above links I realized that
such a functionality was also missing.  This is consistent with
`isearch-yank-kill' (I think we should mention that in its docstring).


--8<-----------------------------cut here---------------start------------->8---
commit 1ea1939929fbf22c6d635b075cfcb2b77a4b8243
Author: Tino Calancha <tino.calancha@gmail.com>
Date:   Sat Feb 8 18:39:44 2020 +0100

    Add command isearch-yank-region
    
    During an incremental search, this command appends the region
    to the search string.  Otherwise, start an incremental search
    using the region as the search string.
    
    * lisp/isearch.el (isearch-yank-region): New command; bound to 'M-.'
    in isearch-mode-map.
    
    * doc/emacs/search.texi (Isearch Yank): Document it.
    * etc/NEWS: Announce this change.

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index 16916617a2..b443300b6d 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -285,6 +285,11 @@ Isearch Yank
 a prefix numeric argument of @var{n}, the command appends everything
 from point to the @var{n}th occurrence of the specified character.
 
+@kindex M-. @r{(Incremental search)}
+@findex isearch-yank-region
+  Likewise, @kbd{M-.} (@code{isearch-yank-region}) appends to
+the search string the selected region.
+
 @kindex C-y @r{(Incremental search)}
 @kindex M-y @r{(Incremental search)}
 @kindex mouse-2 @r{in the minibuffer (Incremental search)}
diff --git a/etc/NEWS b/etc/NEWS
index 55c1a47fbf..cf63176124 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -91,6 +91,13 @@ shows equivalent key bindings for all commands that have them.
 \f
 * Changes in Specialized Modes and Packages in Emacs 28.1
 
+** Search and Replace
+
++++
+*** New isearch bindings.
+'M-.' invokes new fnction 'isearch-yank-region', which yanks the selected
+region into the search string.
+
 ** Help
 
 +++
diff --git a/lisp/isearch.el b/lisp/isearch.el
index ddf9190dc6..266c311c3d 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -514,6 +514,9 @@ isearch-menu-bar-yank-map
     (define-key map [isearch-yank-kill]
       '(menu-item "Current kill" isearch-yank-kill
                   :help "Append current kill to search string"))
+    (define-key map [isearch-yank-region]
+      '(menu-item "Active region" isearch-yank-region
+                  :help "Append active region to search string"))
     (define-key map [isearch-yank-until-char]
       '(menu-item "Until char..." isearch-yank-until-char
                   :help "Yank from point to specified character into search string"))
@@ -708,6 +711,7 @@ isearch-mode-map
     (define-key map "\M-\C-d" 'isearch-del-char)
     (define-key map "\M-\C-y" 'isearch-yank-char)
     (define-key map    "\C-y" 'isearch-yank-kill)
+    (define-key map    "\M-." 'isearch-yank-region)
     (define-key map "\M-\C-z" 'isearch-yank-until-char)
     (define-key map "\M-s\C-e" 'isearch-yank-line)
 
@@ -1007,6 +1011,7 @@ isearch-forward
 Type \\[isearch-yank-line] to yank rest of line onto end of search string\
  and search for it.
 Type \\[isearch-yank-kill] to yank the last string of killed text.
+Type \\[isearch-yank-region] to yank the active region.
 Type \\[isearch-yank-pop] to replace string just yanked into search prompt
  with string killed before it.
 Type \\[isearch-quote-char] to quote control character to search for it.
@@ -2473,6 +2478,17 @@ isearch-yank-kill
   (unless isearch-mode (isearch-mode t))
   (isearch-yank-string (current-kill 0)))
 
+(defun isearch-yank-region ()
+  "Pull region into search string.
+If called out of an incremental search, then start an incremental
+search with the region as the search string."
+  (interactive)
+  (cond ((use-region-p)
+         (unless isearch-mode (isearch-mode t))
+         (isearch-yank-string (funcall region-extract-function))
+         (deactivate-mark))
+        (t (user-error "No selected region"))))
+
 (defun isearch-yank-pop ()
   "Replace just-yanked search string with previously killed string."
   (interactive)

--8<-----------------------------cut here---------------end--------------->8---


In GNU Emacs 28.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-02-08 built on calancha-pc.dy.bbexcite.jp
Repository revision: fe903c5ab7354b97f80ecf1b01ca3ff1027be446
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)






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

end of thread, other threads:[~2021-04-21 20:41 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-08 18:04 bug#39512: 28.0.50; Add command isearch-yank-region Tino Calancha
2020-02-08 23:47 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-02-09  0:31 ` Juri Linkov
2020-02-09 11:21   ` Tino Calancha
2020-02-09 12:38   ` Tino Calancha
2020-02-10  0:45     ` Juri Linkov
2020-02-12 22:10       ` Juri Linkov
2020-08-09 11:28   ` Lars Ingebrigtsen
2020-08-09 23:23     ` Juri Linkov
2020-08-10  1:19       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-10 23:49         ` Juri Linkov
2020-08-11  1:12           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-11 23:13             ` Juri Linkov
2020-08-12 17:41               ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-12 23:44                 ` Juri Linkov
2020-08-13  3:14                   ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-15 20:52                     ` Juri Linkov
2021-04-18 15:34                       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-20 20:29                         ` Juri Linkov
2021-04-21 20:41                           ` Juri Linkov
2020-08-10 17:00       ` Tino Calancha

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.