help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: killing the result of isearch


From: Eric Abrahamsen
Subject: Re: killing the result of isearch
Date: Tue, 07 Nov 2017 09:45:14 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Drew Adams <drew.adams@oracle.com> writes:

>> Several years ago, when I wanted to do this, I wrote the following:
>> 
>> (define-key isearch-mode-map (kbd "M-m") 'my-isearch-mark-search-as-region)
>> (defun my-isearch-mark-search-as-region ()
>>   (interactive)
>>   (if (not isearch-mode)
>>       (message "This is only useful during isearch")
>>     (isearch-exit)
>>     (push-mark isearch-other-end)
>>     (activate-mark)))
>
> That's essentially the same thing used in Isearch+:
>
> (defun isearchp-set-region-around-search-target ()
>   "Set the region around the last search or query-replace target."
>   (interactive)
>   (case last-command
>     ((isearch-forward isearch-backward
>       isearch-forward-regexp isearch-backward-regexp)
>      (push-mark isearch-other-end t 'activate))
>     (t (push-mark (match-beginning 0) t 'activate)))
>   (setq deactivate-mark  nil))

Ah, I hadn't noticed the extra arguments to `push-mark', thanks. Anyway,
OP should be happy with `isearch-other-end'.

>> I guess that's just a tiny half-step in the direction that isearch+ is
>> headed.
>
> Isearch+ isn't really headed anywhere. ;-)  I just add/change things as
> they come to me.
>
>> Another very good facility to get comfortable with is recursive editing:
>> type "C-r" during search mode, do whatever editing you like, then
>> "C-M-c" to go back into search mode.
>
> +1
>
> But that's not in vanilla Emacs, AFAIK.  (It's certainly not
> bound to `C-r' by default - `C-r' is ` isearch-repeat-backward'.)
>
> With Isearch+, `C-x o' during Isearch opens a recursive edit.
> And `C-M-c' (`exit-recursive-edit') resumes searching.

Oops, that binding is for query-replace, not search. Another good
argument for simply starting out in (or switching to) query-replace.

>> I think what people are trying to say is that Emacs' defaults can often
>> seem lacking, but it makes up for it by giving you enormous power to
>> create your ideal behavior yourself...  I think we all expect that we
>> need to go the last half-mile ourselves.
>
> +1
>
> But sometimes it's not so much that we need to go the last
> half mile ourselves.  Sometimes it's more that we want to
> go the next N miles, for fun and learning.

Most definitely!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]