GNU bug report logs - #39512
28.0.50; Add command isearch-yank-region

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Sat, 8 Feb 2020 18:06:01 UTC

Severity: wishlist

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 39512 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: spacibba <at> aol.com, npostavs <at> gmail.com, 39512 <at> debbugs.gnu.org,
 contovob <at> tcd.ie, eliz <at> gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#39512: 28.0.50; Add command isearch-yank-region
Date: Sun, 09 Feb 2020 12:21:10 +0100
Juri Linkov <juri <at> linkov.net> writes:

>>     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.
Me either.  I believe I have copied such an append wording from
elsewhere.  What I have in mind is just to set the search string = to
the region.


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

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

I was motivated with a scenario similar to 1.
1. I select a region that I want to search for
2. C-s ; I start an interactive search
3. `some keybinding here'; that sets the search string = to the region.

I think on 3. as an alternative of `isearch-yank-until-char' (and
family).  Sure, having the command to start the search directly with a
M-s prefix is desirable too.
My mind finds easy to remember that I always can do the patter:
C-s
;; Now some keybinding that sets the search string with `isearch-yank- (whatever)

>> +(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?

Opps, I tested without emacs -Q. sorry for that!  I have some advice
in that function that lets me call it with no arguments.




This bug report was last modified 4 years and 115 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.