unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* cursor position upon search
@ 2010-02-27 19:05 sj10
  2010-02-28 22:51 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: sj10 @ 2010-02-27 19:05 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]

Hey,

If the search string is "arg", then is there a command in emacs to place the
cursor on the first character of arg when it is found rather than 1 past the
last character as search-forward for instance does?

Thanks
Sid

[-- Attachment #2: Type: text/html, Size: 255 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: cursor position upon search
  2010-02-27 19:05 cursor position upon search sj10
@ 2010-02-28 22:51 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2010-02-28 22:51 UTC (permalink / raw)
  To: sj10, help-gnu-emacs

> If the search string is "arg", then is there a command in
> emacs to place the cursor on the first character of arg
> when it is found rather than 1 past the last character
> as search-forward for instance does?

1. I assume you're asking about interactive use of Isearch (even though you
asked about `search-forward').

See `isearch-mode-end-hook' and variable `isearch-other-end'. The latter is the
position you want to go to. The former gives you a way to go there:

(defun foo () (goto-char isearch-other-end))
(add-hook 'isearch-mode-end-hook 'foo)

2. If you really meant `search-forward' and you are using this in Lisp code,
then after calling `search-forward' just (goto-char (match-beginning 0)).

3. If what you really want is to select the search hit, then see library
`isearch+.el' - option `isearchp-set-region-flag' determines this behavior. You
can use `C-SPC' during Isearch to toggle the behavior.
http://www.emacswiki.org/emacs/IsearchPlus





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-28 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-27 19:05 cursor position upon search sj10
2010-02-28 22:51 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).