* option to let isearch select the search target (in transient mark mode)
@ 2007-07-10 19:58 Drew Adams
2007-07-10 20:37 ` Davis Herring
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Drew Adams @ 2007-07-10 19:58 UTC (permalink / raw)
To: Emacs-Devel
How about adding this to Isearch: Depending on the value of an option,
`isearch-set-region-flag', Isearch leaves the region active around the
search target when you stop searching with `RET'. This is only for
Transient Mark mode; if that mode is not on, then this does nothing.
This feature makes it easy to delete the found text, copy it, or type
to replace it in Delete Selection mode. You can toggle the option at
any time during searching, with `C-SPC'.
I use `isearch-mode-end-hook' to implement this, but it could no doubt
be integrated with the Isearch code more directly. Alternatively,
`transient-mark-mode' could perhaps add this to or remove it from
`isearch-mode-end-hook'. In that case, the test for
`transient-mark-mode' would be removed.
(defcustom isearch-set-region-flag nil
"Non-nil means set region around search target.
This is used only for Transient Mark mode.
You can toggle this with `isearch-toggle-set-region', bound to
`C-SPC' during isearch."
:type 'boolean :group 'isearch)
(add-hook 'isearch-mode-end-hook 'isearch-set-region)
(defun isearch-set-region ()
"Set the region around the search target, if `isearch-set-region-flag'.
This is used only for Transient Mark mode."
(when (and isearch-set-region-flag transient-mark-mode)
(push-mark isearch-other-end t 'activate)))
(defun isearch-toggle-set-region ()
"Toggle `isearch-set-region-flag'."
(interactive)
(setq isearch-set-region-flag (not isearch-set-region-flag))
(if isearch-set-region-flag
(message "Setting region around search target is now ON")
(message "Setting region around search target is now OFF")))
(define-key isearch-mode-map [(control ? )]
'isearch-toggle-set-region)
And here is a standalone command, for users who want to do this only
upon demand and leave `isearch-set-region-flag' = nil:
(defun 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))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 19:58 option to let isearch select the search target (in transient mark mode) Drew Adams
@ 2007-07-10 20:37 ` Davis Herring
2007-07-10 21:03 ` Mathias Dahl
` (2 more replies)
2007-07-11 2:34 ` Miles Bader
` (2 subsequent siblings)
3 siblings, 3 replies; 10+ messages in thread
From: Davis Herring @ 2007-07-10 20:37 UTC (permalink / raw)
To: Drew Adams; +Cc: Emacs-Devel
> How about adding this to Isearch: Depending on the value of an option,
> `isearch-set-region-flag', Isearch leaves the region active around the
> search target when you stop searching with `RET'. This is only for
> Transient Mark mode; if that mode is not on, then this does nothing.
>
> This feature makes it easy to delete the found text, copy it, or type
> to replace it in Delete Selection mode. You can toggle the option at
> any time during searching, with `C-SPC'.
I have a hard time seeing this as useful (although, to state my potential
biases, I use neither Transient Mark nor Delete Selection mode). The
whole point of the i in isearch is that one very rarely needs to type
"all" of the target string (or the regexp describing it). Having found my
target with, say, 3 of its 11 characters specified, I would find it much
easier to type something like M-b M-d M-d to kill it (followed by C-y if I
wanted to copy it), perhaps followed by self-inserts to replace it, than
to type the rest of the target (no typos1) and then have isearch drop the
mark usefully.
If you're suggesting instead that one would use this to set the beginning
(for forward searches) of the region at the beginning of the match and
then use other commands to find the end of it, I suppose that's somewhat
more useful, but it seems a lot of complication to save what will most
often be <search...> M-b C-SPC before the M-f that you would use to
terminate the search with this option. Thinking about this, I realize
that I would get almost all the utility of this idea with just one command
added to isearch which meant "exit and move point to start of match", or
(closer to your idea) a command which meant "exit and drop mark at start
of match" in place of your toggle. WDOT?
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 20:37 ` Davis Herring
@ 2007-07-10 21:03 ` Mathias Dahl
2007-07-10 21:31 ` Davis Herring
2007-07-10 21:56 ` Drew Adams
2007-08-01 9:46 ` Johan Bockgård
2 siblings, 1 reply; 10+ messages in thread
From: Mathias Dahl @ 2007-07-10 21:03 UTC (permalink / raw)
To: herring; +Cc: Drew Adams, Emacs-Devel
> terminate the search with this option. Thinking about this, I realize
> that I would get almost all the utility of this idea with just one command
> added to isearch which meant "exit and move point to start of match",
Isn't that what isearch does already? When exiting a successful
isearch with RET it says in the echo area:
Mark saved where search started
And I can use this to delete the region or kill it or whatever.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 21:03 ` Mathias Dahl
@ 2007-07-10 21:31 ` Davis Herring
0 siblings, 0 replies; 10+ messages in thread
From: Davis Herring @ 2007-07-10 21:31 UTC (permalink / raw)
To: Mathias Dahl; +Cc: Drew Adams, Emacs-Devel
>> terminate the search with this option. Thinking about this, I realize
>> that I would get almost all the utility of this idea with just one
>> command
>> added to isearch which meant "exit and move point to start of match",
>
> Isn't that what isearch does already? When exiting a successful
> isearch with RET it says in the echo area:
>
> Mark saved where search started
>
> And I can use this to delete the region or kill it or whatever.
Where search started is not where the -match- started, but rather where
point was when you started isearch altogether.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: option to let isearch select the search target (in transient mark mode)
2007-07-10 20:37 ` Davis Herring
2007-07-10 21:03 ` Mathias Dahl
@ 2007-07-10 21:56 ` Drew Adams
2007-08-01 9:46 ` Johan Bockgård
2 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2007-07-10 21:56 UTC (permalink / raw)
To: herring; +Cc: Emacs-Devel
> > How about adding this to Isearch: Depending on the value of an option,
> > `isearch-set-region-flag', Isearch leaves the region active around the
> > search target when you stop searching with `RET'. This is only for
> > Transient Mark mode; if that mode is not on, then this does nothing.
> >
> > This feature makes it easy to delete the found text, copy it, or type
> > to replace it in Delete Selection mode. You can toggle the option at
> > any time during searching, with `C-SPC'.
>
> I have a hard time seeing this as useful (although, to state my potential
> biases, I use neither Transient Mark nor Delete Selection mode).
I stated clearly that "This is only for Transient Mark mode." If you don't
use that mode, then, no, you won't find this useful. Neither should you find
it an obstacle, however, since it does nothing in that case.
> The whole point of the i in isearch is that one very rarely needs to type
> "all" of the target string (or the regexp describing it). Having found my
> target with, say, 3 of its 11 characters specified, I would find it much
> easier to type something like M-b M-d M-d to kill it (followed by C-y if I
> wanted to copy it), perhaps followed by self-inserts to replace it, than
> to type the rest of the target (no typos1) and then have isearch drop the
> mark usefully.
In Delete Selection mode, you would just type the replacement, or hit `DEL'
to delete the selection.
Deleting text after the search hit is another matter. That is the same
regardless of whether you use something like Transient Mark mode: `M-d' or
whatever. Or you can use `C-w' before exiting, or...
> If you're suggesting instead...
No, that's your suggestion, not mine.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 20:37 ` Davis Herring
2007-07-10 21:03 ` Mathias Dahl
2007-07-10 21:56 ` Drew Adams
@ 2007-08-01 9:46 ` Johan Bockgård
2 siblings, 0 replies; 10+ messages in thread
From: Johan Bockgård @ 2007-08-01 9:46 UTC (permalink / raw)
To: emacs-devel
"Davis Herring" <herring@lanl.gov> writes:
> Thinking about this, I realize that I would get almost all the
> utility of this idea with just one command added to isearch which
> meant "exit and move point to start of match", or (closer to your
> idea) a command which meant "exit and drop mark at start of match"
> in place of your toggle. WDOT?
+1
--
Johan Bockgård
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 19:58 option to let isearch select the search target (in transient mark mode) Drew Adams
2007-07-10 20:37 ` Davis Herring
@ 2007-07-11 2:34 ` Miles Bader
2007-07-11 3:05 ` Richard Stallman
2007-07-12 7:28 ` Slawomir Nowaczyk
3 siblings, 0 replies; 10+ messages in thread
From: Miles Bader @ 2007-07-11 2:34 UTC (permalink / raw)
To: emacs-devel
"Drew Adams" <drew.adams@oracle.com> writes:
> How about adding this to Isearch: Depending on the value of an option,
> `isearch-set-region-flag', Isearch leaves the region active around the
> search target when you stop searching with `RET'. This is only for
> Transient Mark mode; if that mode is not on, then this does nothing.
Hmm, sounds like it might be useful -- I quite often end up manually
putting the region around the target of a search after searching, and
have always found the "double work" annoying...
-Miles
--
P.S. All information contained in the above letter is false,
for reasons of military security.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 19:58 option to let isearch select the search target (in transient mark mode) Drew Adams
2007-07-10 20:37 ` Davis Herring
2007-07-11 2:34 ` Miles Bader
@ 2007-07-11 3:05 ` Richard Stallman
2007-08-01 9:51 ` Johan Bockgård
2007-07-12 7:28 ` Slawomir Nowaczyk
3 siblings, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2007-07-11 3:05 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
How about adding this to Isearch: Depending on the value of an option,
`isearch-set-region-flag', Isearch leaves the region active around the
search target when you stop searching with `RET'. This is only for
Transient Mark mode; if that mode is not on, then this does nothing.
I don't think it is needed. You can type C-@ C-r C-r to put the region
around the match that was just found.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-11 3:05 ` Richard Stallman
@ 2007-08-01 9:51 ` Johan Bockgård
0 siblings, 0 replies; 10+ messages in thread
From: Johan Bockgård @ 2007-08-01 9:51 UTC (permalink / raw)
To: emacs-devel
Richard Stallman <rms@gnu.org> writes:
> How about adding this to Isearch: Depending on the value of an option,
> `isearch-set-region-flag', Isearch leaves the region active around the
> search target when you stop searching with `RET'. This is only for
> Transient Mark mode; if that mode is not on, then this does nothing.
>
> I don't think it is needed. You can type C-@ C-r C-r to put the region
> around the match that was just found.
That (C-M-r) doesn't do the right thing for regexp searches (forward
and backward searches are not symmetrical).
--
Johan Bockgård
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: option to let isearch select the search target (in transient mark mode)
2007-07-10 19:58 option to let isearch select the search target (in transient mark mode) Drew Adams
` (2 preceding siblings ...)
2007-07-11 3:05 ` Richard Stallman
@ 2007-07-12 7:28 ` Slawomir Nowaczyk
3 siblings, 0 replies; 10+ messages in thread
From: Slawomir Nowaczyk @ 2007-07-12 7:28 UTC (permalink / raw)
To: Emacs-Devel
On Tue, 10 Jul 2007 12:58:48 -0700
Drew Adams <drew.adams@oracle.com> wrote:
#> How about adding this to Isearch: Depending on the value of an
#> option, `isearch-set-region-flag', Isearch leaves the region active
#> around the search target when you stop searching with `RET'. This is
#> only for Transient Mark mode; if that mode is not on, then this does
#> nothing.
I would definitely find that useful at times.
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
"Consequences, shmonsequences! So long as I'm rich!" -- Daffy Duck
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-08-01 9:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10 19:58 option to let isearch select the search target (in transient mark mode) Drew Adams
2007-07-10 20:37 ` Davis Herring
2007-07-10 21:03 ` Mathias Dahl
2007-07-10 21:31 ` Davis Herring
2007-07-10 21:56 ` Drew Adams
2007-08-01 9:46 ` Johan Bockgård
2007-07-11 2:34 ` Miles Bader
2007-07-11 3:05 ` Richard Stallman
2007-08-01 9:51 ` Johan Bockgård
2007-07-12 7:28 ` Slawomir Nowaczyk
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.