[Top][All Lists]

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

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

From: Uday Reddy
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Sat, 12 Mar 2011 15:17:30 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

On 3/12/2011 10:42 AM, David Kastrup wrote:

No, it isn't.  The likelilood that somebody uses `set-buffer' when he
expects it not to change the current buffer is not exactly large.

Agreed. But that is not the only case where the problems occur. As explained in my message yesterday, there could be unprotected point movements deep inside function calls, which are unintentionally caught by the save-excursion at the outer level. Ideally, those point movements should be protected where they occur, not by an unrelated an save-excursion sitting somewhere else.

Frankly, I think the warning message is quite fine. save-excursion is trying to preserve the point (and mark), but only for the current-buffer. set-buffer is changing the current-buffer and, so, the preservation of the point in the current-buffer is useless.

If one wants a completely plain warning message, it could be:

  "save-excursion has the effect of save-current-buffer"

It doesn't say very much, but nobody will presumably argue about it.


reply via email to

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