From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Velizar Bodurski" Newsgroups: gmane.emacs.devel Subject: Strange behavior with 'save-excursion' Date: Wed, 4 Aug 2004 16:11:34 +0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: Reply-To: Velizar Bodurski NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1251"; Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1091624998 4569 80.91.224.253 (4 Aug 2004 13:09:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 4 Aug 2004 13:09:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 04 15:09:46 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BsLWb-0001L7-00 for ; Wed, 04 Aug 2004 15:09:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BsLa5-0006YM-Cf for ged-emacs-devel@m.gmane.org; Wed, 04 Aug 2004 09:13:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BsLZz-0006Xu-QT for emacs-devel@gnu.org; Wed, 04 Aug 2004 09:13:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BsLZy-0006Xe-4X for emacs-devel@gnu.org; Wed, 04 Aug 2004 09:13:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BsLZx-0006XU-W4 for emacs-devel@gnu.org; Wed, 04 Aug 2004 09:13:14 -0400 Original-Received: from [195.149.248.129] (helo=sql.data.bg) by monty-python.gnu.org with smtp (Exim 4.34) id 1BsLWJ-000807-6X for emacs-devel@gnu.org; Wed, 04 Aug 2004 09:09:27 -0400 Original-Received: (qmail 1543 invoked from network); 4 Aug 2004 13:11:34 -0000 Original-Received: from localhost (HELO WebMail) (127.0.0.1) by localhost with SMTP; 4 Aug 2004 13:11:34 -0000 Original-Received: from client 212.91.166.210 for Data.BG WebMail (webmail client); Wed, 4 Aug 2004 16:11:34 +0200 Original-To: emacs-devel@gnu.org X-Priority: 3 X-Mailer: webmail@data.bg (v2.0) X-Original-IP: 212.91.166.210 X-MSMail-Priority: Medium Importance: Medium X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:26178 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:26178 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 Data.BG WebMail