From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Date: Mon, 21 Aug 2017 20:18:39 -0400 Message-ID: <87o9r8bgkg.fsf@users.sourceforge.net> References: <87lhdd5e52.fsf@secretsauce.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1503361125 25279 195.159.176.226 (22 Aug 2017 00:18:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 22 Aug 2017 00:18:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 21262@debbugs.gnu.org, Dima Kogan To: charles@aurox.ch (Charles A. Roelli) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 22 02:18:40 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 1djwtu-0005vQ-7L for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Aug 2017 02:18:34 +0200 Original-Received: from localhost ([::1]:43114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djwu0-0007CA-Tw for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Aug 2017 20:18:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djwtR-0006ph-NG for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 20:18:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djwtO-0005Xm-HB for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 20:18:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39672) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1djwtO-0005Xe-D5 for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 20:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1djwtO-00079l-7l for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 20:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Aug 2017 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21262-submit@debbugs.gnu.org id=B21262.150336103027450 (code B ref 21262); Tue, 22 Aug 2017 00:18:02 +0000 Original-Received: (at 21262) by debbugs.gnu.org; 22 Aug 2017 00:17:10 +0000 Original-Received: from localhost ([127.0.0.1]:48353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djwsX-00078f-Lk for submit@debbugs.gnu.org; Mon, 21 Aug 2017 20:17:09 -0400 Original-Received: from mail-it0-f68.google.com ([209.85.214.68]:34553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djwsV-00078Q-MC for 21262@debbugs.gnu.org; Mon, 21 Aug 2017 20:17:08 -0400 Original-Received: by mail-it0-f68.google.com with SMTP id s132so10782603ita.1 for <21262@debbugs.gnu.org>; Mon, 21 Aug 2017 17:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=8XHYMFgSBb5K63TLog6uJ63WdHaVfnLC/SK5IcPhVrs=; b=D7A1R3j3UsHu7zCYpAaFJzP0ubyKIcOtA0Rf6y8cbIT/dENpZCMvxuvQYE/PiwQqyb Ot64UkM7X4/zmarRmVVoe/HpjjdphQm1MN7lMm7AIUL5pX00lecrHvlZUsPdSJYTILuJ j1qA1KrhwlL01NdDcRkg6q/D30gGD7LP3DTqLRAbTFb0+arg8v6LzSyfou2JxM56jSad hkpHxJFq63PgwH5d5hY4dhSDYGdm1IlnzZEb70bBvsgkwT4QK4O9QNnzrHAKl85Ykwqv llYFiGGLBLvSX7hL6jUgj0GE7tn06kFg7G875hMcTawayJ+1C1NUvdqDlwzNSI1Ji4sx DByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=8XHYMFgSBb5K63TLog6uJ63WdHaVfnLC/SK5IcPhVrs=; b=Mo8fPQY6SSPQw/lXTq2esJ0Pm2hikVYWZP2FqpQryCsjxRo6jeL0n7SHPYig/4F2wK DYkMFhG8ZJR3iG//S7eBu9G9dmy7AWUz/cy7XSiXMhi2jyKQaUiFL0HY+GmRLx4xNsOk 9owYxPGFHaB5N/1HpSu0W8KiNXKgLUGoIo7OWs0PblZ7vW8ovNU/XeAfw2gbD9BOvsKP 2fz7dxqIG9hW5+IibBY9Lw/VjgnCBzmqk/pfpQGvtrskIBU/m/0OoAwAZX0c9Sg0G8SR HEnc1qC7HRlcvuUwgPdlqn2Udgn5RIVjPOQW30Y4D/UYTEtvHjr0wsQwQSrt8/VBN4HJ QhRg== X-Gm-Message-State: AHYfb5h1I9l7h8aJHinJ68s3PSkb6w0mXZVCtPmks/qBz/YB3jOHqLh4 ACZzRhygKdKMg7bc X-Received: by 10.36.190.132 with SMTP id i126mr1757885itf.165.1503361022056; Mon, 21 Aug 2017 17:17:02 -0700 (PDT) Original-Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id r186sm6228322iod.6.2017.08.21.17.17.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 17:17:01 -0700 (PDT) In-Reply-To: (Charles A. Roelli's message of "Mon, 21 Aug 2017 21:49:50 +0200") 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:136027 Archived-At: charles@aurox.ch (Charles A. Roelli) writes: > This still affects 26.0.50. > > The attached change fixes it -- but I know nothing of diff-mode, so > better ideas are welcome. Note that the buffer will be widened while > Emacs asks where to look for the sources, but it will return to the > original narrowing after the user has selected a file or hit C-g. 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.