From: Juri Linkov <juri@jurta.org>
To: "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-devel@gnu.org
Subject: Re: Point at beginning of search pattern incompatible with M-p
Date: Sat, 06 Oct 2012 20:31:11 +0300 [thread overview]
Message-ID: <871uhbfqvw.fsf@mail.jurta.org> (raw)
In-Reply-To: <80mx00ug23.fsf@somewhere.org> (Sebastien Vauban's message of "Sat, 06 Oct 2012 11:04:52 +0200")
> I had, for some time, the following code in my .emacs.
>
> The goal: always exit searches at the beginning of the expression found.
>
> (add-hook 'isearch-mode-end-hook 'custom-goto-match-beginning)
>
> (defun custom-goto-match-beginning ()
> "Use with isearch hook to end search at first char of match."
> (when isearch-forward (goto-char isearch-other-end)))
>
> Problem: when I want to reuse earlier search strings (with the command `M-p'),
> I get the following error:
> [...]
> Can this be fixed somehow, to enjoy both features (exiting searches at the
> beginning of the expression, and reusing earlier search strings) together?
I for one have this code in ~/.emacs that could help you to do what you want:
(define-key isearch-mode-map [(control return)] 'isearch-exit)
;; C-RET doesn't add the current search string to the search ring
;; and moves point to the beginning of the found search string.
(add-hook 'isearch-mode-end-hook
(lambda ()
;; Exiting isearch with C-RET
(when (eq last-input-event 'C-return)
;; Move point to the beginning of the found search string
(if (and isearch-forward isearch-other-end)
(goto-char isearch-other-end))
;; Don't add the current search string to the search ring
(if isearch-regexp
(setq regexp-search-ring (cdr regexp-search-ring))
(setq search-ring (cdr search-ring))))))
Not sure about turning this into some configurable options.
prev parent reply other threads:[~2012-10-06 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-06 9:04 Point at beginning of search pattern incompatible with M-p Sebastien Vauban
2012-10-06 17:31 ` Juri Linkov [this message]
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=871uhbfqvw.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=wxhgmqzgwmuf@spammotel.com \
/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.