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: Uday S Reddy
Subject: RE: `save-excursion' defeated by `set-buffer'
Date: Wed, 16 Mar 2011 12:05:33 +0000

Drew Adams writes:

> The warning has already mistaught some (e.g. Uday) that
> `save-excursion' is just downright evil.  The warning leaves users
> either unnecessarily frightened or unnecessarily confused, or both.
> That was not your intention, I'm sure, but it is the effect.

Hi Drew, that is a complete misunderstanding, if not a downright
distortion, of what I wrote.  `save-excursion' to protect point
movements and buffer changes that make up an "excursion" are perfectly
fine.  That is indeed the intended application of `save-excursion' as
described in the ELisp manual.  I have even shown sample pieces of
code describing how and where `save-excursion' should be placed.  For
example: 

Uday S Reddy writes:

> No, it wasn't from an actual application.  I just made it up.  And, it
> isn't good code either.  To make it good code, one needs another
> save-excursion to protect the point movement in buffer A, as below:
> 
>      (defun find-something ()
>         (....
>          (save-excursion 
>               (set-buffer A)  
>               (save-excursion
>                  (goto-char y)  
>                   ...))))
> 

You seem to have missed the significance of these statements.

Cheers,
Uday



reply via email to

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