From xemacs-m  Fri Apr  4 18:53:34 1997
Received: from crystal.WonderWorks.COM (crystal.WonderWorks.com [192.203.206.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id SAA06981
	for <xemacs-beta@xemacs.org>; Fri, 4 Apr 1997 18:53:32 -0600 (CST)
Received: by crystal.WonderWorks.COM 
	id QQcjwt04651; Fri, 4 Apr 1997 19:53:34 -0500 (EST)
Date: Fri, 4 Apr 1997 19:53:34 -0500 (EST)
Message-Id: <QQcjwt04651.199704050053@crystal.WonderWorks.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Kyle Jones <kyle_jones@wonderworks.com>
To: xemacs-beta@xemacs.org
Subject: save-excursion sometimes doesn't
In-Reply-To: <m24tdmqp5h.fsf@altair.xemacs.org>
References: <m24tdmqp5h.fsf@altair.xemacs.org>
X-Mailer: VM 6.23 under 19.15 XEmacs Lucid
X-Face: /cA45WHG7jWq>(O3&Z57Y<"WsX5ddc,4c#w0F*zrV#=M
        0@~@,s;b,aMtR5Sqs"+nU.z^CSFQ9t`z2>W,S,]:[+2^
        Nbf6v4g>!&,7R4Ot4Wg{&tm=WX7P["9%a)_da48-^tGy
        ,qz]Z,Zz\{E.,]'EO+F)@$KtF&V

Steven L Baur writes:
 > The following example behaves the same way in Emacs 19.34 which leads
 > me to believe I'm probably missing something, or we copied a bug.
 > 
 > Put the following expression in *scratch* and hit C-x C-e at the end
 > of it.  Point moves down 4 lines despite the save-excursion.
 > 
 > (save-excursion
 >   (insert-before-markers "\n\n\n\n"))

Been this way since I started using GNU Emacs.

 > I expect it to work like this.
 > (let ((opoint (point)))
 >   (save-excursion
 >     (insert-before-markers "\n\n\n\n"))
 >   (goto-char opoint))

You don't really want the absolute point position to be preserved,
you want it to be restored between the same two chars.  I.e. after

(insert "efg")
(forward-char -1)
(save-excursion
  (goto-char (point-min))
  (insert "abc"))

you want point to still be between "f" and "g", not between "b"
and "c" as it would be if save-excursion worked as you wrote
above.

The way this is done is remembering point as a marker.  This has
all the desired properties except that insertion behavior is
surprising at the saved point marker.

