[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: placing cursor at *start* of match in incremental search
From: |
Greg Hill |
Subject: |
Re: placing cursor at *start* of match in incremental search |
Date: |
Wed, 22 Jan 2003 11:53:29 -0800 |
At 10:22 AM -0700 1/22/03, Kevin Rodgers wrote:
<snip>
Use the source:
Good "advice" :) for those of us who can make heads or tails of it.
But it's probably a bit much to ask of someone like Maciej who isn't
really a lisp programmer.
`C-g' is bound in isearch-mode-map to isearch-abort, which sets
isearch-success to nil before calling isearch-done, which is what runs
isearch-mode-end-hook. So you could check isearch-success before
calling goto-char in the hook function.
i.e., for someone who isn't a lisp programmer:
(add-hook 'isearch-mode-end-hook
(function (lambda ()
(if isearch-success (goto-char (match-beginning 0))))))
Seems to work. Thanks, Kevin.
Incidentally, Maciej, when you are experimenting with different
versions of anonymous (lambda) functions as hooks in the same Emacs
session, don't forget to explicitly remove any old versions of the
function from the hook variable, or you will end up executing more
that one version and wondering why the new one you just added doesn't
seem to work the way it should.
For example, after
(add-hook 'isearch-mode-end-hook
(function (lambda ()
(goto-char (match-beginning 0)))))
you should either
(setq isearch-mode-end-hook nil)
which will remove ALL functions from that hook, or
(remove-hook 'isearch-mode-end-hook
(function (lambda ()
(goto-char (match-beginning 0)))))
which will specifically remove just that one function, before you
(add-hook 'isearch-mode-end-hook
(function (lambda ()
(if isearch-success (goto-char (match-beginning 0))))))
In case you didn't know, the *scratch* buffer, which uses
lisp-interaction-mode, is the right place to do stuff like that. I
don't remember what source I used to learn about how to use
lisp-interaction mode. The versions I have of the GNU Emacs Manual
and the GNU Emacs Lisp Reference Manual don't seem to be much help;
but there really isn't much to it. Perhaps someone else can point
you to a geed tutorial.
--Greg
- Re: placing cursor at *start* of match in incremental search, (continued)
- Re: placing cursor at *start* of match in incremental search, Adrian Kubala, 2003/01/16
- Re: placing cursor at *start* of match in incremental search, Greg Hill, 2003/01/16
- Re: placing cursor at *start* of match in incremental search, David Robinow, 2003/01/16
- Message not available
- Re: placing cursor at *start* of match in incremental search, Maciej Kalisiak, 2003/01/17
- Re: placing cursor at *start* of match in incremental search, Greg Hill, 2003/01/17
- Re: placing cursor at *start* of match in incremental search, Kevin Rodgers, 2003/01/21
- Re: placing cursor at *start* of match in incremental search, Maciej Kalisiak, 2003/01/22
- Re: placing cursor at *start* of match in incremental search, Kevin Rodgers, 2003/01/22
- Re: placing cursor at *start* of match in incremental search,
Greg Hill <=
- Message not available
- Re: placing cursor at *start* of match in incremental search, Stefan Monnier <address@hidden>, 2003/01/22
- Message not available
- Re: placing cursor at *start* of match in incremental search, Kevin Rodgers, 2003/01/22
- Re: placing cursor at *start* of match in incremental search, Ittay Dror, 2003/01/23
- Re: placing cursor at *start* of match in incremental search, Maciej Kalisiak, 2003/01/23
- Re: placing cursor at *start* of match in incremental search, Ittay Dror, 2003/01/26
- Re: placing cursor at *start* of match in incremental search, Ittay Dror, 2003/01/26
- Re: placing cursor at *start* of match in incremental search, Ittay Dror, 2003/01/26