[Top][All Lists]

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

Re: Problem using search-forward

From: Tassilo Horn
Subject: Re: Problem using search-forward
Date: Sun, 07 Oct 2012 20:26:15 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux)

Bob Shanley <address@hidden> writes:

Hi Bob,

> ; These do not:
> ;   (defun eol ( ) (end-of-line) (point))
> ;   (search-forward ");" (eol))
> ;   (let ( (n (eol)) ) (message "this is the value %d" n) (search-forward 
> ");" n))
> ; They result in a Search failed: ");" and point moves to end of line
> ; What am I missing?

The `end-of-line' call already moves point to the end of line, thus you
bound the search to the same position where it starts.  Try this
definition of `eol'.

  (defun eol ()

,----[ C-h f save-excursion RET ]
| save-excursion is a special form in `C source code'.
| (save-excursion &rest BODY)
| Save point, mark, and current buffer; execute BODY; restore those things.
| Executes BODY just like `progn'.
| The values of point, mark and the current buffer are restored
| even in case of abnormal exit (throw or error).
| The state of activation of the mark is also restored.
| This construct does not save `deactivate-mark', and therefore
| functions that change the buffer will still cause deactivation
| of the mark at the end of the command.  To prevent that, bind
| `deactivate-mark' with `let'.
| If you only want to save the current buffer but not point nor mark,
| then just use `save-current-buffer', or even `with-current-buffer'.


reply via email to

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