emacs-devel
[Top][All Lists]
Advanced

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

Strange behavior with 'save-excursion'


From: Velizar Bodurski
Subject: Strange behavior with 'save-excursion'
Date: Wed, 4 Aug 2004 16:11:34 +0200

The code is:
(progn
(save-excursion
(while (re-search-forward "^[ \t]*#define \\([a-zA-Z_0-9]+\\)[
\t]*\\([()a-zA-Z \t0-9]*$\\)" (point-max) t 1)
(end-of-line)
(let ((cur (point)))
(goto-char (point-min))
(insert (concat "Defined: " (match-string 1) " with "
(if (> (length (match-string 2)) 0)
(match-string 2)
"Empty")
"\n"))
(goto-char cur)))))

This code is executed in *scratch* buffer with '^J'
(eval-print-last-sexp)..
The buffer also contains "#define ABZ test" several lines after the
code. When the above code is executed it continuously adds new
records in the beginning of the buffer. But if the 'save-excursions' is
removed or moved inside the 'while' loop the code this time correctly,
only adds one new record and stops. Also I executed much simplified
re-search, the code was:
(progn
(save-excursion
(while (re-search-forward "test" (point-max) t 1)
(end-of-line)
(let ((cur (point)))
(goto-char (point-min))
(insert "OK\n")
(goto-char cur)))))
the buffer contained 'test' string some lines after the above code, the
result was that the the code executed only once as expected.

Is this a correct behavior.

Some information about emacs build used (the build is without any
additional patches or modifications of the original source archive):

In GNU Emacs 21.3.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2004-01-06 on moon.batmbg.com
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US
locale-coding-system: iso-latin-1
default-enable-multibyte-characters: t


________________________________________________
Message sent by <a href='http://mail.data.bg'>Data.BG WebMail</a>





reply via email to

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