From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: fix for bug#29935 copyright-update inserts year at random places Date: Wed, 03 Jan 2018 21:21:34 -0600 Message-ID: <86k1wy48ch.fsf@stephe-leake.org> References: <868tdh5fag.fsf@stephe-leake.org> <837et0ckou.fsf@gnu.org> <86shbm4ks9.fsf@stephe-leake.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1515036033 29777 195.159.176.226 (4 Jan 2018 03:20:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 4 Jan 2018 03:20:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 04 04:20:29 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWw4r-0006v4-9e for ged-emacs-devel@m.gmane.org; Thu, 04 Jan 2018 04:20:21 +0100 Original-Received: from localhost ([::1]:47084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWw6o-0004oS-Ry for ged-emacs-devel@m.gmane.org; Wed, 03 Jan 2018 22:22:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWw6B-0004oL-6n for emacs-devel@gnu.org; Wed, 03 Jan 2018 22:21:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWw68-0003nV-18 for emacs-devel@gnu.org; Wed, 03 Jan 2018 22:21:43 -0500 Original-Received: from smtp153.ord.emailsrvr.com ([173.203.6.153]:52505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWw67-0003mX-So for emacs-devel@gnu.org; Wed, 03 Jan 2018 22:21:39 -0500 Original-Received: from smtp24.relay.ord1a.emailsrvr.com (localhost [127.0.0.1]) by smtp24.relay.ord1a.emailsrvr.com (SMTP Server) with ESMTP id CCBC0201A2 for ; Wed, 3 Jan 2018 22:21:38 -0500 (EST) X-Auth-ID: board-president@tomahawk-creek-hoa.com Original-Received: by smtp24.relay.ord1a.emailsrvr.com (Authenticated sender: board-president-AT-tomahawk-creek-hoa.com) with ESMTPSA id 5866520163 for ; Wed, 3 Jan 2018 22:21:38 -0500 (EST) X-Sender-Id: board-president@tomahawk-creek-hoa.com Original-Received: from Takver4 (76-218-37-33.lightspeed.kscymo.sbcglobal.net [76.218.37.33]) (using TLSv1.2 with cipher AES256-GCM-SHA384) by 0.0.0.0:587 (trex/5.7.12); Wed, 03 Jan 2018 22:21:38 -0500 In-Reply-To: (Stefan Monnier's message of "Wed, 03 Jan 2018 20:01:55 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 173.203.6.153 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221574 Archived-At: Stefan Monnier 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