[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: |
Sat, 12 Mar 2011 16:25:24 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Uday Reddy <uDOTsDOTreddy@cs.bham.ac.uk> writes:
> 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.
There is little reason to warn about "useless" code.
> 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.
The most plausible theory I have for this thread is that you are
collectively trying to pull my leg.
If you give the user that warning, he'll say "great, just like I wanted
it to do".
Why warn the user that "save-excursion" is doing what he wants it to do,
when the actual problem is that it may do more, namely reverting an
excursion happening unintendedly in the original buffer?
--
David Kastrup
- RE: `save-excursion' defeated by `set-buffer', (continued)
- Message not available
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/14
- Message not available
- Re: `save-excursion' defeated by `set-buffer', Uday Reddy, 2011/03/12
- RE: `save-excursion' defeated by `set-buffer', Drew Adams, 2011/03/13
- Message not available
- Re: `save-excursion' defeated by `set-buffer', David Kastrup, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer', Eli Zaretskii, 2011/03/12
- Message not available
- Re: `save-excursion' defeated by `set-buffer', David Kastrup, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer', Eli Zaretskii, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer', Uday Reddy, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer',
David Kastrup <=
- Re: `save-excursion' defeated by `set-buffer', Uday Reddy, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/14
- Re: `save-excursion' defeated by `set-buffer', Andreas Röhler, 2011/03/14
- Message not available
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/15
- Re: `save-excursion' defeated by `set-buffer', PJ Weisberg, 2011/03/15
- Re: `save-excursion' defeated by `set-buffer', David Kastrup, 2011/03/15
- RE: `save-excursion' defeated by `set-buffer', Drew Adams, 2011/03/15
- Message not available
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/15
- Message not available
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/15
- RE: `save-excursion' defeated by `set-buffer', Drew Adams, 2011/03/15