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: Roland Winkler
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Thu, 24 Dec 2009 08:04:55 -0600

On Mon Dec 21 2009 Stefan Monnier wrote:
> save-excursion only saves point in the current buffer, so
> 
>    (save-excursion (set-buffer foo) (goto-char (point-min)))
> 
> will move point in foo and the point-saving done by save-excursion is
> useless.  So either you want to use
> 
>    (save-current-buffer (set-buffer foo) (goto-char (point-min)))
> aka
>    (with-current-buffer foo (goto-char (point-min)))
> 
> if moving point in foo is what you wanted, or
> 
>    (with-current-buffer foo (save-excursion (goto-char (point-min))))
> 
> if you didn't want to move point in foo.

Hi Stefan,

Thanks for the clarification! -- I still believe it would be good if
this was mentioned in the elisp manual as the compiler warning by
itself is somewhat cryptic for non-experts.

Roland




reply via email to

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