help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Jason Earl
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Tue, 15 Mar 2011 13:02:47 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

On Tue, Mar 15 2011, Stefan Monnier wrote:

>> People will not naturally use `save-excursion' nowadays just to save
>> the current buffer.
>
> Maybe not naturally, no.  But thanks to the pressure of years of old
> code flying around the web, they will do it nowadays on a regular
> basis.  But indeed, thanks to threads like this one and to the warning
> I added, I hope I can reverse the trend.
>
>
>         Stefan

Precisely, these warnings are not for people like you, Drew, or David.
You guys have the experience necessary to make the correct choice.
Warnings like this are *very* helpful to people like me, however, that
have no experience with Emacs Lisp, but would like to write Elisp
anyhow.

To be honest, for the purpose of teaching newbies it almost doesn't
matter what the warning says either.  As long as it is clear that
save-excursion and set-buffer are not to be used together then it is a
win.

And yes, I realize that what I should do is read the manual umpteen
million times, and memorize a pile of stuff.  Actually, in this case
this might not be such a good idea.  I assumed that I had picked up the
save-excursion + set-buffer idiom while I was perusing the Gnus code,
but in checking the manual I think that I might have picked it up from
the /Introduction to Emacs Lisp/.  Using save-excursion and set-buffer
together is covered in:

         4.4.3 `save-excursion' in `append-to-buffer'

Jason


reply via email to

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