[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 02:40:34 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
On 3/12/2011 3:25 PM, David Kastrup wrote:
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.
Why is that? I am quite happy to receive warnings about bad 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".
Ok, how about
"save-current-buffer is a better choice than save-excursion"
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?
If an excursion is happening unintentionally that is definitely a bug!
You probably mean that reverting it unintentionally is not so bad. But
I happen to think that it is. save-excursion's should be as close as
possible to the point movements they are protecting. One shouldn't
randomly wrap large pieces of bad code in save-excursion and hope that
nobody will notice. It is really hard to maintain such code. The
compiler warning is really welcome from my point of view. I only wish
that the compiler warning was there 20 years ago so that I wouldn't have
to deal with that mess now. But better late than never!
Cheers,
Uday
- 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, 2011/03/12
- Re: `save-excursion' defeated by `set-buffer',
Uday Reddy <=
- 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
- Re: `save-excursion' defeated by `set-buffer', Stefan Monnier, 2011/03/15