From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#39512: 28.0.50; Add command isearch-yank-region Date: Sat, 08 Feb 2020 19:04:57 +0100 Message-ID: <87eev52bw6.fsf@calancha-pc.dy.bbexcite.jp> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="25800"; mail-complaints-to="usenet@ciao.gmane.io" Cc: spacibba@aol.com, npostavs@gmail.com, juri@linkov.net, contovob@tcd.ie To: 39512@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 08 19:06:40 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 1j0UV6-0006aa-9o for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Feb 2020 19:06:40 +0100 Original-Received: from localhost ([::1]:44072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0UV5-0004CM-C1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Feb 2020 13:06:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37586) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0UUy-0004Br-5J for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 13:06:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0UUw-0000JJ-KS for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 13:06:32 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0UUb-00081e-MQ; Sat, 08 Feb 2020 13:06:09 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j0UUT-0002s3-OD; Sat, 08 Feb 2020 13:06:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: spacibba@aol.com, juri@linkov.net, drew.adams@oracle.com, npostavs@gmail.com, contovob@tcd.ie, eliz@gnu.org, bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Feb 2020 18:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39512 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: spacibba@aol.com, juri@linkov.net, drew.adams@oracle.com, npostavs@gmail.com, contovob@tcd.ie, eliz@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158118511710979 (code B ref -1); Sat, 08 Feb 2020 18:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Feb 2020 18:05:17 +0000 Original-Received: from localhost ([127.0.0.1]:51768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0UTg-0002qx-I5 for submit@debbugs.gnu.org; Sat, 08 Feb 2020 13:05:17 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:59156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0UTe-0002qp-FU for submit@debbugs.gnu.org; Sat, 08 Feb 2020 13:05:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37244) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0UTc-0003ow-SS for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 13:05:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0UTb-0006Zh-9E for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 13:05:08 -0500 Original-Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:39805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0UTb-0006YC-0t for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 13:05:07 -0500 Original-Received: by mail-wr1-x42f.google.com with SMTP id y11so2625119wrt.6 for ; Sat, 08 Feb 2020 10:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=PbL6lRxJosvn+LCnXeLo9LdnOiPrUicIvTcebKxgmhA=; b=qkA1M6jWqGZVusXnPYIS/WvorkZM5dp3u0CKQCWBEfCeAs1V0yMv4hQL/CWX6i+/oH JPcMWsqjH7UielcNDr51PWCpaCwwKtFn/h62Z0UQbaljAvJ0/FWMW7FGZRIymPxTSGSK sb2IsbvUawSvYtQXdzBepvn7bvwK33NXyvPRoj8rn9uw9g13eFxIIaQjWWFAX2q4gRra II3BsE+0P1wUylrZ3hiKG5dPn30lFTbCWBt9ekXb/9cj8f66MxIqlhei5LG2c4+6qtXu PUR72ycaKowSCrK0CsrDTB7Co3MQ+tynEdNp65IUSCMauAOPj5kQHCz1RIwXKeqC+Ih/ 7YiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=PbL6lRxJosvn+LCnXeLo9LdnOiPrUicIvTcebKxgmhA=; b=XYtOv6/GUjm2ndYb5ZWEpDKG5S0up5Sfh5Eke2IrR3gSZT5ZoI6KFsDCKtEJ/z7d2G 3ebGqFc8NSdG0yG7j0YeG7qRQvp7JBdjJlAe2jkAy56gQYneXHWeAEx86CJcFPgfS6Jq E5lVOkwjYDyCNkSR3eoJwOlDxLTr+hMzFJ4Ol+UGGMg+q9eaCBWuY9TH49zUXoJ+6g7m Ac+K1s4FCWsys3tV0OZplUHyg7ULZX6WVLLcvFNvk9Nr0OEAGZoNRlMJI6Kex3UHmiC/ JMLkAp4nOmVLYhtfEPd2VI4uWMndDOVkP6i8Qj6p8sfZ6KzInfg5eLzeJatDCkDCBkkm 2WTg== X-Gm-Message-State: APjAAAWOSjndwYNXnKhZ5Ju2eauabvSEtHHjm5dkVELOmbdJ4+EUFHuE GhVCQMbrGelg98bvK36tPJzyK7y+wfU= X-Google-Smtp-Source: APXvYqyJ9edx/hhOI9j0W1B4dpsp+ssZn1P3D/mOxSxXLARkdJBoP4HN7s8xdw722ziVv7VxTsyQiA== X-Received: by 2002:adf:f3d1:: with SMTP id g17mr6040111wrp.378.1581185104477; Sat, 08 Feb 2020 10:05:04 -0800 (PST) Original-Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id w26sm7914115wmi.8.2020.02.08.10.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 10:05:03 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:175802 Archived-At: 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)