emacs-devel
[Top][All Lists]
Advanced

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

Re: Add M-x occur to the menu-bar


From: Stefan Monnier
Subject: Re: Add M-x occur to the menu-bar
Date: 07 Feb 2004 17:39:18 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>> >   (save-excursion
>> >     (set-buffer buffer)
>> 
>> Also known as (with-current buffer buffer

> It's not the same if buffer is already selected.  In that case the
> first version restores the cursor position afterwards and the second
> doesn't.

Indeed, it's not 100% equivalent.  My experience is that in practice, in
98% of the cases, you can replace the first with the second, as for the
remaining 2% it's probably equally split between cases where it would
introduce a bug and cases where it makes an existing bug a bit more obvious
to the programmer.  This last case is when people do for example:

   (save-excursion
     (set-buffer foo)
     (re-search-forward "bar")
     (match-string 1))
     
where they should have done

   (with-current-buffer foo
     (save-excursion
       (re-search-forward "bar")
       (match-string 1)))


-- Stefan




reply via email to

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