From: Dmitry Gutov <dmitry@gutov.dev>
To: 71604@debbugs.gnu.org
Cc: juri linkov <juri@linkov.net>
Subject: bug#71604: diff--get-revision-properties calls set-auto-mode twice
Date: Mon, 17 Jun 2024 05:25:31 +0300 [thread overview]
Message-ID: <d4fc2e28-fcad-4233-adbf-eb029b41b606@gutov.dev> (raw)
X-Debbugs-Cc: Juri Linkov <juri@linkov.net>
Tags: patch
vc-find-revision-no-save calls set-auto-mode, and then we repeat that
call in diff-syntax-fontify-props.
Which is a problem with CC Mode because it parses the buffer inside the
major mode function, and ends up doing that twice, at least the first
time the buffer is initialized before being saved to revision cache. Not
exactly double the work, but more work nevertheless.
This is a split off from https://debbugs.gnu.org/61667#587. I thought I
recalled an existing report of vc-diff being slow, but apparently not.
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index c0269d882b9..cc5509ca347 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2883,9 +2883,6 @@ diff--get-revision-properties
(buffer (cdr entry)))
(if (buffer-live-p buffer)
(progn
- ;; Don't re-initialize the buffer (which would throw
- ;; away the previous fontification work).
- (setq file nil)
(setq diff--cached-revision-buffers
(cons entry
(delq entry diff--cached-revision-buffers))))
@@ -2905,7 +2902,8 @@ diff--get-revision-properties
(diff--cache-schedule-clean)
(and buffer
(with-current-buffer buffer
- (diff-syntax-fontify-props file text line-nb)))))
+ ;; major mode is set in vc-find-revision-no-save already.
+ (diff-syntax-fontify-props nil text line-nb)))))
(defun diff-syntax-fontify-hunk (beg end old)
"Highlight source language syntax in diff hunk between BEG and END.
next reply other threads:[~2024-06-17 2:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 2:25 Dmitry Gutov [this message]
2024-06-17 16:33 ` bug#71604: diff--get-revision-properties calls set-auto-mode twice Juri Linkov
2024-06-17 20:01 ` Dmitry Gutov
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=d4fc2e28-fcad-4233-adbf-eb029b41b606@gutov.dev \
--to=dmitry@gutov.dev \
--cc=71604@debbugs.gnu.org \
--cc=juri@linkov.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.