aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-04-16 23:51:51 +0300
committerJuri Linkov2019-04-16 23:51:51 +0300
commit292e817aad806cc405bd72ae53eb32281bcc2636 (patch)
tree0a7203fac67e8f8ded0b374973ba5bfbccd793b7
parentd0da7ee82e6b0f952eae1069ec592bb466f71ed3 (diff)
downloademacs-292e817aad806cc405bd72ae53eb32281bcc2636.tar.gz
emacs-292e817aad806cc405bd72ae53eb32281bcc2636.zip
* lisp/vc/diff-mode.el (diff-syntax-fontify-hunk): Erase buffer
before inserting file contents to *diff-syntax-file*. Use absolute file names.
-rw-r--r--lisp/vc/diff-mode.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 1d5a2cf69ab..a26e9eef824 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2439,6 +2439,7 @@ When OLD is non-nil, highlight the hunk from the old source."
2439 (when (and diff-vc-backend 2439 (when (and diff-vc-backend
2440 (not (eq diff-font-lock-syntax 'hunk-only))) 2440 (not (eq diff-font-lock-syntax 'hunk-only)))
2441 (let* ((file (diff-find-file-name old t)) 2441 (let* ((file (diff-find-file-name old t))
2442 (file (and file (expand-file-name file)))
2442 (revision (and file (if (not old) (nth 1 diff-vc-revisions) 2443 (revision (and file (if (not old) (nth 1 diff-vc-revisions)
2443 (or (nth 0 diff-vc-revisions) 2444 (or (nth 0 diff-vc-revisions)
2444 (vc-working-revision file)))))) 2445 (vc-working-revision file))))))
@@ -2447,7 +2448,7 @@ When OLD is non-nil, highlight the hunk from the old source."
2447 ;; Get properties from the current working revision 2448 ;; Get properties from the current working revision
2448 (when (and (not old) (file-readable-p file) 2449 (when (and (not old) (file-readable-p file)
2449 (file-regular-p file)) 2450 (file-regular-p file))
2450 (let ((buf (get-file-buffer (expand-file-name file)))) 2451 (let ((buf (get-file-buffer file)))
2451 ;; Try to reuse an existing buffer 2452 ;; Try to reuse an existing buffer
2452 (if buf 2453 (if buf
2453 (with-current-buffer buf 2454 (with-current-buffer buf
@@ -2460,13 +2461,13 @@ When OLD is non-nil, highlight the hunk from the old source."
2460 ;; Same file as last-time, unmodified. 2461 ;; Same file as last-time, unmodified.
2461 ;; Reuse buffer as-is. 2462 ;; Reuse buffer as-is.
2462 (setq file nil) 2463 (setq file nil)
2464 (erase-buffer)
2463 (insert-file-contents file) 2465 (insert-file-contents file)
2464 (setq diff--syntax-file-attributes attrs))) 2466 (setq diff--syntax-file-attributes attrs)))
2465 (diff-syntax-fontify-props file text line-nb))))) 2467 (diff-syntax-fontify-props file text line-nb)))))
2466 ;; Get properties from a cached revision 2468 ;; Get properties from a cached revision
2467 (let* ((buffer-name (format " *diff-syntax:%s.~%s~*" 2469 (let* ((buffer-name (format " *diff-syntax:%s.~%s~*"
2468 (expand-file-name file) 2470 file revision))
2469 revision))
2470 (buffer (get-buffer buffer-name))) 2471 (buffer (get-buffer buffer-name)))
2471 (if buffer 2472 (if buffer
2472 ;; Don't re-initialize the buffer (which would throw 2473 ;; Don't re-initialize the buffer (which would throw
@@ -2474,7 +2475,7 @@ When OLD is non-nil, highlight the hunk from the old source."
2474 (setq file nil) 2475 (setq file nil)
2475 (setq buffer (ignore-errors 2476 (setq buffer (ignore-errors
2476 (vc-find-revision-no-save 2477 (vc-find-revision-no-save
2477 (expand-file-name file) revision 2478 file revision
2478 diff-vc-backend 2479 diff-vc-backend
2479 (get-buffer-create buffer-name))))) 2480 (get-buffer-create buffer-name)))))
2480 (when buffer 2481 (when buffer