From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.bugs Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Date: Sun, 27 Aug 2017 14:21:05 +0200 Message-ID: References: <87lhdd5e52.fsf@secretsauce.net> <87o9r8bgkg.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1503836539 335 195.159.176.226 (27 Aug 2017 12:22:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 27 Aug 2017 12:22:19 +0000 (UTC) Cc: 21262-done@debbugs.gnu.org, dima@secretsauce.net To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 27 14:22:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1dlwZt-000851-Hj for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Aug 2017 14:22:09 +0200 Original-Received: from localhost ([::1]:60788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlwa0-0004Oh-Fg for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Aug 2017 08:22:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlwZr-0004O1-9N for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 08:22:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlwZm-00023f-FH for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 08:22:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dlwZm-00023Y-Aq for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 08:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dlwZm-0004QW-43 for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 08:22:02 -0400 Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Aug 2017 12:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 21262@debbugs.gnu.org, charles@aurox.ch, dima@secretsauce.net Original-Received: via spool by 21262-done@debbugs.gnu.org id=D21262.150383649116971 (code D ref 21262); Sun, 27 Aug 2017 12:22:01 +0000 Original-Received: (at 21262-done) by debbugs.gnu.org; 27 Aug 2017 12:21:31 +0000 Original-Received: from localhost ([127.0.0.1]:57117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlwZG-0004Pf-OZ for submit@debbugs.gnu.org; Sun, 27 Aug 2017 08:21:30 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:44295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlwZF-0004PR-D0 for 21262-done@debbugs.gnu.org; Sun, 27 Aug 2017 08:21:29 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id DB60E2250C for <21262-done@debbugs.gnu.org>; Sun, 27 Aug 2017 12:15:28 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= references:subject:subject:in-reply-to:to:from:from:message-id :date:date; s=dkim; t=1503836124; x=1504700125; bh=o+fIxC8GKkm4b UswxicdYfMNoHRGLbXwDMByMgmiFVI=; b=s3lVjdyRh/w09BFiU/Dp8UhtYMalm /RsbM3FjOvx2NO3UUAZf3yKlkM4wpZFGQ0HZCHcFE3MNZxpgccBjfpwxB+eFa1m+ nl2PyFwEq++vrdL//hcK1ABqfotK6OqpROXyUrSUgISxllT4BVafxDQ9UE5TPFgZ i8VRHeFMhX28fU= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id X_IEdsUvBVCG for <21262-done@debbugs.gnu.org>; Sun, 27 Aug 2017 12:15:24 +0000 (UTC) Original-Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 82EE422502; Sun, 27 Aug 2017 12:15:24 +0000 (UTC) In-reply-to: (charles@aurox.ch) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136253 Archived-At: > Date: Tue, 22 Aug 2017 16:02:17 +0200 > From: charles@aurox.ch (Charles A. Roelli) > > > From: npostavs@users.sourceforge.net > > Cc: Dima Kogan , 21262@debbugs.gnu.org > > Date: Mon, 21 Aug 2017 20:18:39 -0400 > > > > Looks like a reasonable fix to me (though I know only a little bit of > > diff-mode). Here it is again ignoring whitespace, which I think makes > > it easier to see what is happening: > > > > modified lisp/vc/diff-mode.el > > @@ -874,6 +874,8 @@ diff-find-file-name > > ;; Flush diff-remembered-files-alist if the default-directory is changed. > > (set (make-local-variable 'diff-remembered-defdir) default-directory) > > (set (make-local-variable 'diff-remembered-files-alist) nil)) > > + (save-restriction > > + (widen) > > (save-excursion > > (unless (looking-at diff-file-header-re) > > (or (ignore-errors (diff-beginning-of-file)) > > @@ -919,7 +921,7 @@ diff-find-file-name > > (file-name-nondirectory file))) > > (set (make-local-variable 'diff-remembered-files-alist) > > (cons (cons fs file) diff-remembered-files-alist)) > > - file)))))) > > + file))))))) > > > > Perhaps we should swap the save-restriction and save-excursion around > > though? The elisp manual says: > > > > If you use both `save-restriction' and `save-excursion' together, > > `save-excursion' should come first (on the outside). Otherwise, > > the old point value would be restored with temporary narrowing > > still in effect. > > Good point, thank you. I'll apply the attached patch in a few days if > there's no further discussion. I've pushed the fix, closing the bug now. commit 208a3cb05f4d954abc9dd6c8cd858ef2bedd7cb4 Date: Tue Aug 22 15:57:01 2017 +0200 Fix 'diff-goto-source' when buffer is narrowed (Bug#21262) * lisp/vc/diff-mode.el (diff-find-file-name): Save the current narrowing, and widen the buffer before searching for the name of the file corresponding to the diff. With thanks to Noam Postavsky.