diff-mode: Optimize source language syntax highlighting
authorDmitry Gutov <dmitry@gutov.dev>
Mon, 17 Jun 2024 19:51:23 +0000 (22:51 +0300)
committerDmitry Gutov <dmitry@gutov.dev>
Mon, 17 Jun 2024 19:53:35 +0000 (22:53 +0300)
* lisp/vc/diff-mode.el (diff--get-revision-properties):
Never pass FILE to 'diff-syntax-fontify-props'; assume that
'vc-find-revision-no-save' has called the major mode function
already (bug#71604).

lisp/vc/diff-mode.el

index c0269d882b993a81b349f1795186e087fe2ac445..81e8b23ee33575bbc4b5a25a0514310f79408e87 100644 (file)
@@ -2883,9 +2883,6 @@ and the position in MAX."
          (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 @@ and the position in MAX."
     (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.