[Top][All Lists]

[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: Thu, 10 Mar 2011 20:28:07 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> The difference between save-excursion and save-current-buffer is that
>> the first doesn't just save&restore the current buffer but also "point&
>> mark".  But if you do `set-buffer' right after save-excursion then most
>> likely you will change neither point nor mark in the original buffer, so
>> the extra work performed by save-excursion compared to
>> save-current-buffer will be useless.
>> Now that's just a waste of resources but is otherwise harmless.
>> Unless of course `blub' is already the current buffer to start with.
>> I.e. whether point movement in "..." is undone by save-excursion will
>> depend dynamically upon whether the current buffer happens to be `blub',
>> which leads to subtle bugs.  Hence the warning.

> Thanks, this warning goes away if body is wrapped with a let:

> (save-excursion
>   (let ()
>     (set-buffer blub)
>       ...
>       ))

I see you apparently didn't understand much of what I wrote :-(


reply via email to

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