From: Juri Linkov <juri@linkov.net>
To: 32460@debbugs.gnu.org
Subject: bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
Date: Thu, 16 Aug 2018 23:48:05 +0300 [thread overview]
Message-ID: <87zhxmhz4a.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 729 bytes --]
It's difficult to debug a sporadic problem when automatic diff
refinement doesn't display refined overlays on some diff hunks
occasionally. Looking at the code, it seems there is a possible
race condition when diff--font-lock-refined calls diff-hunk-next
that sets a timer that later might remove and try to re-add again
overlays already added by the direct call of diff--refine-hunk
from diff--font-lock-refined. Also diff-hunk-next prevents
multiple consequent calls from refining a set of hunks
by checking diff--auto-refine-data.
To avoid such double refinement, this patch let-binds
diff-auto-refine-mode to nil before calling diff-hunk-next
for non-interactive navigation (it calls diff--refine-hunk
explicitly below):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: diff-refine.1.patch --]
[-- Type: text/x-diff, Size: 1253 bytes --]
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index b91a2ba45a..175687f184 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2077,7 +2088,9 @@ diff--font-lock-refined
(point) 'diff--font-lock-refined nil max)))
(let* ((min (point))
(beg (or (ignore-errors (diff-beginning-of-hunk))
- (ignore-errors (diff-hunk-next) (point))
+ (ignore-errors (let ((diff-auto-refine-mode nil))
+ (diff-hunk-next))
+ (point))
max)))
(while (< beg max)
(let ((end
@@ -2092,7 +2105,10 @@ diff--font-lock-refined
(overlay-put ol 'modification-hooks
'(diff--font-lock-refine--refresh))))
(goto-char (max beg end))
- (setq beg (or (ignore-errors (diff-hunk-next) (point)) max)))))))
+ (setq beg (or (ignore-errors (let ((diff-auto-refine-mode nil))
+ (diff-hunk-next))
+ (point))
+ max)))))))
(defun diff--font-lock-refine--refresh (ol _after _beg _end &optional _len)
(delete-overlay ol))
next reply other threads:[~2018-08-16 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 20:48 Juri Linkov [this message]
2019-03-07 19:26 ` bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks Charles A. Roelli
2019-03-08 3:07 ` Stefan Monnier
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=87zhxmhz4a.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=32460@debbugs.gnu.org \
/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.