From: npostavs@users.sourceforge.net
To: charles@aurox.ch (Charles A. Roelli)
Cc: 21262@debbugs.gnu.org, Dima Kogan <dima@secretsauce.net>
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 [thread overview]
Message-ID: <87o9r8bgkg.fsf@users.sourceforge.net> (raw)
In-Reply-To: <m2y3qcpuox.fsf@aurox.ch> (Charles A. Roelli's message of "Mon, 21 Aug 2017 21:49:50 +0200")
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.
next prev parent reply other threads:[~2017-08-22 0:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-15 5:12 bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Dima Kogan
2017-08-21 19:49 ` Charles A. Roelli
2017-08-22 0:18 ` npostavs [this message]
2017-08-22 14:02 ` Charles A. Roelli
2017-08-27 12:21 ` Charles A. Roelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9r8bgkg.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=21262@debbugs.gnu.org \
--cc=charles@aurox.ch \
--cc=dima@secretsauce.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.