[Top][All Lists]

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

Re: fix for bug#29935 copyright-update inserts year at random places

From: Stephen Leake
Subject: Re: fix for bug#29935 copyright-update inserts year at random places
Date: Wed, 03 Jan 2018 21:21:34 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt)

Stefan Monnier <address@hidden> writes:

>>> Why does this need to use save-window-excursion?
>> 'switch-to-buffer' can pop up a new frame, or use a different window,
>> depending on various settings, so save-window-excursion is needed. 
> Indeed, but note that if it pops up a new frame, save-window-excursion
> will be of no help to "undo" this effect (which really can't be undone
> in general, since to pop up that frame, the user may have had to place
> the new frame).

Right. I changed copyright-update-year to use pop-to-buffer, and set
pop-up-frames to t; update-copyright-year popped up a new frame, which
was not minimized or closed.

Using pop-to-buffer-same-window did not pop up a new frame, which is
preferable here, I think, even for people who normally have
pop-up-frames t.

I think there are still situations where pop-to-buffer-same-window can
change the window configuration (if it is invoked from a dedicated
window, for example), so save-window-excursion is still needed.

> Also switch-to-buffer is kind of ambiguous: do you really want to only
> affect the currently selected window, or do you really want to display
> the specified buffer (sometimes switch-to-buffer has to choose between
> those two options and it doesn't know what the caller wanted).  I think
> here we care more about displaying the specified buffer than about only
> affecting the selected window, so we should probably use
> `pop-to-buffer(-same-window)` instead.

pop-to-buffer-same-window works, and is a lower-level function, so it
makes sense here.

-- Stephe

reply via email to

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