unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: npostavs@gmail.com, juri@linkov.net, contovob@tcd.ie,
	eliz@gnu.org, 39512@debbugs.gnu.org, drew.adams@oracle.com
Subject: bug#39512: 28.0.50; Add command isearch-yank-region
Date: Sun, 9 Feb 2020 00:47:13 +0100	[thread overview]
Message-ID: <20200208234713.tlenu5tmna6ezvb7@Ergus> (raw)
In-Reply-To: <87eev52bw6.fsf@calancha-pc.dy.bbexcite.jp>

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 <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)
>
>
>





  reply	other threads:[~2020-02-08 23:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200208234713.tlenu5tmna6ezvb7@Ergus \
    --to=bug-gnu-emacs@gnu.org \
    --cc=39512@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    --cc=npostavs@gmail.com \
    --cc=spacibba@aol.com \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).