[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: Sun, 13 Mar 2011 14:16:44 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

On 3/13/2011 7:15 AM, Andreas Röhler wrote:

They should be restored if the parentese closes.
Every setting of buffer, mark and point between then doesn't matter as
far as the buffer now current again is concerned.

Maybe there have been other `save-excursion' intercurse. But every one
tells it's own story.

I don't fully understand what you are trying to say. But the advice given to me by Stephen Turnbull, which I fully agree with, is that save-excursion should be placed *as close as possible* to the point movements that it is trying to revert. Placing it far away may result in the connection being broken sometime down the road when the code is modified or reused in new ways.

If there is a function that has the side-effect of changing point or mark, then ask yourself whether that is the intended effect of the function. If you depend on an unrelated save-excursion to restore the point movement, then you will be asking for trouble.

Another way to think about the problem is, for every save-excursion in the code:

- are you clear which point movements it is trying to revert,

- is it placed as close as possible to those point movements?


reply via email to

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