From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#39512: 28.0.50; Add command isearch-yank-region Date: Sun, 09 Feb 2020 02:31:50 +0200 Organization: LINKOV.NET Message-ID: <877e0wiosp.fsf@mail.linkov.net> References: <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="29792"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: spacibba@aol.com, npostavs@gmail.com, 39512@debbugs.gnu.org, contovob@tcd.ie To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 09 01:44:13 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 1j0ahp-0007b5-1R for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Feb 2020 01:44:13 +0100 Original-Received: from localhost ([::1]:46582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0ahn-0005E3-Ml for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Feb 2020 19:44:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0ahf-0005DU-C4 for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 19:44:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0ahe-0000gK-33 for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 19:44:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0ahd-0000fx-Ve for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 19:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j0ahd-0005fc-T6 for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2020 19:44:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Feb 2020 00:44:01 +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.158120903821766 (code B ref 39512); Sun, 09 Feb 2020 00:44:01 +0000 Original-Received: (at 39512) by debbugs.gnu.org; 9 Feb 2020 00:43:58 +0000 Original-Received: from localhost ([127.0.0.1]:51960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0ahZ-0005f0-QH for submit@debbugs.gnu.org; Sat, 08 Feb 2020 19:43:58 -0500 Original-Received: from cheetah.birch.relay.mailchannels.net ([23.83.209.34]:11846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0ahX-0005er-BC for 39512@debbugs.gnu.org; Sat, 08 Feb 2020 19:43:56 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 04ABB21452; Sun, 9 Feb 2020 00:43:54 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (100-96-215-16.trex.outbound.svc.cluster.local [100.96.215.16]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id CCFD221735; Sun, 9 Feb 2020 00:43:52 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Sun, 09 Feb 2020 00:43:53 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Imminent-Average: 67c557221ae72100_1581209033733_2632352009 X-MC-Loop-Signature: 1581209033732:1855016014 X-MC-Ingress-Time: 1581209033732 Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTP id 8B579803F9; Sat, 8 Feb 2020 16:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=XbuLCAOz+nX62xiK8Z0kXbS9pBM=; b= kefSMG2CiMos5hDOW8I+GpfWLzGXj4qyGOdxfq1HVUOFwrBhtRMsJq4rR6VY6A7e IOb1zCPVkBbhLLvJVHMeSXZpvJo82p1wO0VTp6vf9P1elKnpip9MjEj1G5BsQTEj k7Bm84DZ71lMa+PYruemFIboEWqSRJLXWYJ6ke4kDlI= Original-Received: from mail.jurta.org (m91-129-105-126.cust.tele2.ee [91.129.105.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTPSA id DB3277FF8F; Sat, 8 Feb 2020 16:43:42 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a62 In-Reply-To: <87eev52bw6.fsf@calancha-pc.dy.bbexcite.jp> (Tino Calancha's message of "Sat, 08 Feb 2020 19:04:57 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrheekgddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuffhomhgrihhnpehgnhhurdhorhhgnecukfhppeeluddruddvledruddthedruddvieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddthedruddviedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehtihhnohdrtggrlhgrnhgthhgrsehgmhgrihhlrdgtohhm 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:175814 Archived-At: > 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. Thanks for creating a new feature request that unlike these discussions on emacs-devel won't fall into oblivion. > 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). Please add this useful feature of `isearch-yank-kill' to the documentation. Maybe it should be bound to a special key on the global `M-s' prefix map. The most natural key would be `M-s C-y'. > 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. What use cases do you think it could be used for? I don't see any useful case for appending the region to the search string. I see only 2 useful cases that don't append the region to the search string: 1. Before starting isearch, the user selects the region, then types a special command bound to a key on the global `M-s' prefix that yanks the region to the initially empty search string (i.e. it doesn't append, it replaces the empty search string) I used such command to do this: (defun isearch-forward-region () "Do incremental search forward for text from the active region. Like ordinary incremental search except that text from the region is added to the search string initially if the region is active." (interactive) (isearch-forward nil 1) (cond ((use-region-p) (when (< (mark) (point)) (exchange-point-and-mark)) (isearch-yank-string (buffer-substring-no-properties (region-beginning) (region-end))) (deactivate-mark)) (t (setq isearch-error "No active region") (isearch-push-state) (isearch-update)))) (define-key search-map "\M-." 'isearch-forward-region) 2. The second useful case is to activate the region, start isearch, use isearch to find the string at the region end, thus moving the region end to a new position, replace (don't append) the search string with region text - this is what isearch-yank-region could do. IOW, sync the region with the search string. > +(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)) Here (funcall region-extract-function) signals the error (wrong-number-of-arguments (1 . 1) 0) Have you tested your patch?