* Modified isearch
@ 2014-01-23 13:40 Peter West
2014-01-23 17:28 ` Drew Adams
2014-01-23 18:01 ` Michael Heerdegen
0 siblings, 2 replies; 5+ messages in thread
From: Peter West @ 2014-01-23 13:40 UTC (permalink / raw)
To: help-gnu-emacs
I want to bind a variation of isearch to the C-c R key, based on
comments in the Emacs Wiki page on isearch. Here are the suggestions
from the wiki for leaving point at the beginning of the match.
(add-hook 'isearch-mode-end-hook 'my-goto-match-beginning)
(defun my-goto-match-beginning ()
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))
(defadvice isearch-exit (after my-goto-match-beginning activate)
"Go to beginning of match."
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))
With this hook, both ‘C-g’ and ‘RET’ exit the search at the begining of
the search string.
...
Another way to get the functionality of jumping to the beginning of the
search-term is simply adding a little wrapper function and binding it to
a different key. I find C-v a good candidate, you don’t usually want to
jump to next page when searching:
(define-key isearch-mode-map (kbd "C-v")
'my-isearch-forward-to-beginning)
(defun my-isearch-forward-to-beginning ()
"Do a forward search and jump to the beginning of the search-term."
(interactive)
(isearch-repeat 'forward)
(goto-char isearch-other-end))
----------------
What I want to do is to invoke normal isearch and isearch-regexp
functions (forward functions at least), and have the mark reset to the
beginning of the matched text. So I tried this:
(define-key search-map (kbd "C-c R") 'my-set-mark-point-around-isearch)
(defun my-set-mark-point-around-isearch ()
"Do a forward search and set mark to the beginning of the
search-term."
(interactive)
(isearch-forward)
(push-mark isearch-other-end))
No luck. Can anyone advise me of the way to achieve this?
Thanks.
P
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Modified isearch
2014-01-23 13:40 Modified isearch Peter West
@ 2014-01-23 17:28 ` Drew Adams
2014-01-24 23:12 ` Peter West
2014-01-23 18:01 ` Michael Heerdegen
1 sibling, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-01-23 17:28 UTC (permalink / raw)
To: Peter West, help-gnu-emacs
> What I want to do is to invoke normal isearch and isearch-regexp
> functions (forward functions at least), and have the mark reset to
> the beginning of the matched text. Can anyone advise me of the
> way to achieve this?
Yes, just use Isearch+:
http://www.emacswiki.org/cgi-bin/wiki/IsearchPlus#isearchp-set-region-flag
Set option `isearchp-set-region-flag' to non-nil.
That automatically sets the region around the last search target.
And you can toggle this behavior anytime during Isearch, using
`C-SPC' (bound to command `isearchp-toggle-set-region').
And you can manually set the region around the last search
target using `M-x set-region-around-search-target'.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Modified isearch
2014-01-23 13:40 Modified isearch Peter West
2014-01-23 17:28 ` Drew Adams
@ 2014-01-23 18:01 ` Michael Heerdegen
1 sibling, 0 replies; 5+ messages in thread
From: Michael Heerdegen @ 2014-01-23 18:01 UTC (permalink / raw)
To: help-gnu-emacs
Peter West <lists@pbw.id.au> writes:
> What I want to do is to invoke normal isearch and isearch-regexp
> functions (forward functions at least), and have the mark reset to the
> beginning of the matched text. So I tried this:
>
>
> (define-key search-map (kbd "C-c R") 'my-set-mark-point-around-isearch)
> (defun my-set-mark-point-around-isearch ()
> "Do a forward search and set mark to the beginning of the
> search-term."
> (interactive)
> (isearch-forward)
> (push-mark isearch-other-end))
>
>
> No luck.
Works well for me. When I hit C-x C-x is see that the mark has been set
accordingly. Or do you want the region to be activated? Then use the
third argument of `push-mark'.
Regards,
Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Modified isearch
2014-01-23 17:28 ` Drew Adams
@ 2014-01-24 23:12 ` Peter West
2014-01-25 1:24 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Peter West @ 2014-01-24 23:12 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
Thanks Drew.
That will do nicely.
I would still like, at some time, to understand isearch and elisp well enough to be able to write such a function as required.
Peter West
...for he had healed many, and all who had diseases pressed upon him, to touch him.
On 24 Jan 2014, at 3:28 am, Drew Adams <drew.adams@oracle.com> wrote:
>> What I want to do is to invoke normal isearch and isearch-regexp
>> functions (forward functions at least), and have the mark reset to
>> the beginning of the matched text. Can anyone advise me of the
>> way to achieve this?
>
> Yes, just use Isearch+:
>
> http://www.emacswiki.org/cgi-bin/wiki/IsearchPlus#isearchp-set-region-flag
>
> Set option `isearchp-set-region-flag' to non-nil.
> That automatically sets the region around the last search target.
>
> And you can toggle this behavior anytime during Isearch, using
> `C-SPC' (bound to command `isearchp-toggle-set-region').
>
> And you can manually set the region around the last search
> target using `M-x set-region-around-search-target'.
[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 235 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Modified isearch
2014-01-24 23:12 ` Peter West
@ 2014-01-25 1:24 ` Drew Adams
0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2014-01-25 1:24 UTC (permalink / raw)
To: Peter West, help-gnu-emacs
> Thanks Drew. That will do nicely.
>
> I would still like, at some time, to understand isearch and elisp well
> enough to be able to write such a function as required.
With that ambition, you surely will. FWIW, I too am still learning
when it comes to the Isearch code (as well as other libraries).
Fortunately, there are plenty of others who understand more and are
helpful. And most important of all is the availability of the source
code. Thank sharing and free software for that.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-25 1:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 13:40 Modified isearch Peter West
2014-01-23 17:28 ` Drew Adams
2014-01-24 23:12 ` Peter West
2014-01-25 1:24 ` Drew Adams
2014-01-23 18:01 ` Michael Heerdegen
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.