all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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.