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: Stefan Monnier
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Sat, 09 Jan 2010 23:57:08 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

> which to code things, just what is inherently wrong or dangerous (meriting a
> warning) with code like the following, to do some work in other buffers yet
> return to the original buffer AND restore its point and mark?

> (save-excursion
>   (set-buffer FOO)
>   ; Pick up some info in FOO, & perhaps assign it to a var
>   (set-buffer BAR)
>   ; Calculate something in BAR, & perhaps record it too
>   ...
> )

What is dangerous about it is that dependong on which buffer is current
before executing this code, the point-saving will either do something
or nothing.  That's a very delicate semantics, which (as mentioned) I've
never found to be correct (i.e. the only times it works reliably is
when the point-saving part of save-excursion is never useful nor
harmful).

Anyway, we just disagree,


        Stefan




reply via email to

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