bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk


From: Charles A. Roelli
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

> Date: Tue, 22 Aug 2017 16:02:17 +0200
> From: charles@aurox.ch (Charles A. Roelli) 
> 
> > From: npostavs@users.sourceforge.net
> > Cc: Dima Kogan <dima@secretsauce.net>,  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.





reply via email to

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