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

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

Modified isearch


From: Peter West
Subject: Modified isearch
Date: Thu, 23 Jan 2014 23:40:37 +1000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

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


reply via email to

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