[Top][All Lists]

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

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

From: David Kastrup
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Fri, 11 Mar 2011 12:38:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Andreas Röhler <address@hidden> writes:

> Am 11.03.2011 10:54, schrieb David Kastrup:
>> Andreas Röhler<address@hidden>  writes:
>>> Maybe let's put the question another way:
>>> is there an example, where save-excursion will fail, ie not restore
>>> the buffer due to a set-buffer afterwards?
>> No.  It will restore buffer, point and mark, in that order.  It is never
>> defeated.  What _may_ be defeated is an excursion happening within the
>> scope of `set-buffer' because restoring buffer will in some instances
>> restore to the same buffer before restoring point and mark.
> Hmm, isn't it just the task of save-excursion to defeat an inner
> set-buffer?

It will always defeat the set-buffer (unless they agree in the first
place), that is not the problem.  The problem is that it may also defeat
any excursion (cursor and mark movements) done inside of the buffer
visited with set-buffer (or made while temporarily switching buffer
again within that construct).  When it does _not_ defeat set-buffer, it
will defeat excursions made after set-buffer.

> Or with other words: save-excursion must not restore if no danger
> buffer being set otherwise meanwhile.
> So the warning is just nonsense?

There is a difference between "wrong" and "nonsense".  I would classify
the warning message as simply wrong, and the phrase you write after "Or
with other words:" as nonsense.

David Kastrup

reply via email to

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