unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Velizar Bodurski" <velo@homelan.bg>
Subject: Strange behavior with 'save-excursion'
Date: Wed, 4 Aug 2004 16:11:34 +0200	[thread overview]
Message-ID: <E1BsLZy-0006Xe-4X@lists.gnu.org> (raw)

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	other threads:[~2004-08-04 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-04 14:11 Velizar Bodurski [this message]
2004-08-04 13:52 ` Strange behavior with 'save-excursion' Andreas Schwab

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1BsLZy-0006Xe-4X@lists.gnu.org \
    --to=velo@homelan.bg \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).