From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#39512: 28.0.50; Add command isearch-yank-region Date: Sun, 9 Feb 2020 00:47:13 +0100 Message-ID: <20200208234713.tlenu5tmna6ezvb7@Ergus> References: <87eev52bw6.fsf@calancha-pc.dy.bbexcite.jp> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="79372"; mail-complaints-to="usenet@ciao.gmane.io" Cc: npostavs@gmail.com, juri@linkov.net, contovob@tcd.ie, eliz@gnu.org, 39512@debbugs.gnu.org, drew.adams@oracle.com To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 09 00:48:17 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j0Zpg-000KWe-21 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Feb 2020 00:48:16 +0100 Original-Received: from localhost ([::1]:46312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0Zpf-000187-2U for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Feb 2020 18:48:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39284) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0ZpV-00017k-Av for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 18:48:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0ZpS-0000pO-Mi for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 18:48:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0ZpS-0000oY-Hj for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 18:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j0ZpS-0004J1-FR for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 18:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Feb 2020 23:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39512 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39512-submit@debbugs.gnu.org id=B39512.158120564916505 (code B ref 39512); Sat, 08 Feb 2020 23:48:02 +0000 Original-Received: (at 39512) by debbugs.gnu.org; 8 Feb 2020 23:47:29 +0000 Original-Received: from localhost ([127.0.0.1]:51943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0Zou-0004I7-W7 for submit@debbugs.gnu.org; Sat, 08 Feb 2020 18:47:29 -0500 Original-Received: from sonic311-15.consmr.mail.bf2.yahoo.com ([74.6.131.125]:45303) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0Zor-0004Hp-W2 for 39512@debbugs.gnu.org; Sat, 08 Feb 2020 18:47:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1581205640; bh=D0ecjj6SL2ZA/KeJvmPxYsOSQOMdmfsI9PVp9fVz3GM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=BkzxGsNbiuCXBEI4xaUBqMj7CqK5R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ZayqamSuleW8msbOv2tFg4qvQGIo0guQSfBYJjB_5m6wMZYM3VdCW3xJ8X06Dib5_ISumjbA gbmOkwDnaB94v4hGd0zLxbDwwPS6OZjotIoxqHIWta Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.bf2.yahoo.com with HTTP; Sat, 8 Feb 2020 23:47:20 +0000 Original-Received: by smtp421.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID a1bda407d9ec9c63b9a4f5e6e9ba703f; Sat, 08 Feb 2020 23:47:15 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87eev52bw6.fsf@calancha-pc.dy.bbexcite.jp> X-Mailer: WebService/1.1.15199 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175811 Archived-At: Hi Tino: It is good to see that someone else is interested on this. I just forgot it after not having a good agreement about the bindings to use. The patch seems good for me, I only want to comment that there was a race condition when the selected region is not contiguous (ex: rectangular selection). Did you tried that case? If possible, please consider adding also some function like the one I proposed in one of the mails (isearch-forward-region) to start the search directly with the selected region text. A good improvement to my function would be to use thing-at-point if not region is active (or modify isearch-forward-symbol-at-point) to do so. Best, Ergus On Sat, Feb 08, 2020 at 07:04:57PM +0100, Tino Calancha wrote: >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 >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. > > * 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) > > >