emacs-devel
[Top][All Lists]
Advanced

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

Re: `save-excursion' defeated by `set-buffer'


From: martin rudalics
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Sun, 10 Jan 2010 19:05:55 +0100
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

> An aside: While reading this discussion I wanted to experiment to
> understand the difference between the two forms above. If I execute
> the following from a buffer other than *scratch*, the letter A is
> inserted four places after point, but point does not move:
>
> (with-current-buffer "*scratch*" (forward-char 4) (insert "A"))
>
> However, the doc string for with-current-buffer says nothing about
> restoring point. This is confusing. Also, with-current-buffer expands
> to save-current-buffer, whose doc string also says nothing about
> restoring point. Again confusing.

The form above _does_ move `point' unless that's inhibited by other
(usually text) properties.  If *scratch* is displayed in some window,
`point' moves as well but the visible effect is overridden by the fact
that `window-point' in any window showing *scratch* does not move (wrt
to the surrounding text).  So I suppose the behavior you report is a
behavior you observed with *scratch* displayed in some window while you
executed that form.

martin




reply via email to

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