all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Peter West <lists@pbw.id.au>
To: help-gnu-emacs@gnu.org
Subject: Modified isearch
Date: Thu, 23 Jan 2014 23:40:37 +1000	[thread overview]
Message-ID: <lbr64l$1ruo$1@adenine.netfront.net> (raw)

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	other threads:[~2014-01-23 13:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 13:40 Peter West [this message]
2014-01-23 17:28 ` Modified isearch Drew Adams
2014-01-24 23:12   ` Peter West
2014-01-25  1:24     ` Drew Adams
2014-01-23 18:01 ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='lbr64l$1ruo$1@adenine.netfront.net' \
    --to=lists@pbw.id.au \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.