GNU bug report logs - #21262
25.0.50; Diff-mode gets confused about its narrowing if hunk source not found

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Sat, 15 Aug 2015 06:02:01 UTC

Severity: normal

Found in version 25.0.50

Done: charles <at> aurox.ch (Charles A. Roelli)

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: charles <at> aurox.ch (Charles A. Roelli)
To: npostavs <at> users.sourceforge.net
Cc: 21262 <at> debbugs.gnu.org, dima <at> secretsauce.net
Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found
Date: Tue, 22 Aug 2017 16:02:17 +0200
[Message part 1 (text/plain, inline)]
> From: npostavs <at> users.sourceforge.net
> Cc: Dima Kogan <dima <at> secretsauce.net>,  21262 <at> 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.

[0001-Fix-diff-goto-source-when-buffer-is-narrowed-Bug-212.patch (text/x-patch, attachment)]

This bug report was last modified 7 years and 270 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.