aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2018-12-19 01:10:09 +0200
committerJuri Linkov2018-12-19 01:10:09 +0200
commitfb16313025dcbe2f010a79072536aeab000eaf80 (patch)
tree5ece6b88f047bcd868df6650baaf23ec456cc1ab
parent8cbbf4ba25bef2c6c1b525aa380a1cd3f0b0d012 (diff)
downloademacs-fb16313025dcbe2f010a79072536aeab000eaf80.tar.gz
emacs-fb16313025dcbe2f010a79072536aeab000eaf80.zip
More font-lock improvements for diff-mode
* lisp/vc/diff-mode.el (diff-font-lock-keywords): Use diff-header face for git index lines (like already used for bzr index lines). Use diff-file-header face for binary file headers. (diff-find-source-location): Use expand-file-name for vc-find-revision. (diff--font-lock-prettify): Use diff-indicator-* faces for left-fringe indicators. (diff-syntax-fontify-props): Optimize to not use text-property-not-all for font-lock-ensure. * lisp/replace.el (occur-engine-line): Simplify to use font-lock-ensure without text-property-not-all.
-rw-r--r--lisp/replace.el6
-rw-r--r--lisp/vc/diff-mode.el24
2 files changed, 15 insertions, 15 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index dcae12e9b76..b8f231eb55d 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1907,10 +1907,8 @@ See also `multi-occur'."
1907 global-matches))) 1907 global-matches)))
1908 1908
1909(defun occur-engine-line (beg end &optional keep-props) 1909(defun occur-engine-line (beg end &optional keep-props)
1910 (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode) 1910 (if (and keep-props font-lock-mode)
1911 (text-property-not-all beg end 'fontified t)) 1911 (font-lock-ensure beg end))
1912 (if (fboundp 'jit-lock-fontify-now)
1913 (jit-lock-fontify-now beg end)))
1914 (if (and keep-props (not (eq occur-excluded-properties t))) 1912 (if (and keep-props (not (eq occur-excluded-properties t)))
1915 (let ((str (buffer-substring beg end))) 1913 (let ((str (buffer-substring beg end)))
1916 (remove-list-of-text-properties 1914 (remove-list-of-text-properties
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 549f49a8d13..043d22d14b3 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -255,7 +255,7 @@ in wrong fontification. This is the fastest option, but less reliable."
255 "Keymap for `diff-minor-mode'. See also `diff-mode-shared-map'.") 255 "Keymap for `diff-minor-mode'. See also `diff-mode-shared-map'.")
256 256
257(define-minor-mode diff-auto-refine-mode 257(define-minor-mode diff-auto-refine-mode
258 "Toggle automatic diff hunk highlighting (Diff Auto Refine mode). 258 "Toggle automatic diff hunk finer highlighting (Diff Auto Refine mode).
259 259
260Diff Auto Refine mode is a buffer-local minor mode used with 260Diff Auto Refine mode is a buffer-local minor mode used with
261`diff-mode'. When enabled, Emacs automatically highlights 261`diff-mode'. When enabled, Emacs automatically highlights
@@ -435,7 +435,9 @@ and the face `diff-added' for added lines.")
435 'diff-removed)))))) 435 'diff-removed))))))
436 ("^\\(?:Index\\|revno\\): \\(.+\\).*\n" 436 ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
437 (0 'diff-header) (1 'diff-index prepend)) 437 (0 'diff-header) (1 'diff-index prepend))
438 ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)
438 ("^Only in .*\n" . 'diff-nonexistent) 439 ("^Only in .*\n" . 'diff-nonexistent)
440 ("^Binary files .* differ\n" . 'diff-file-header)
439 ("^\\(#\\)\\(.*\\)" 441 ("^\\(#\\)\\(.*\\)"
440 (1 font-lock-comment-delimiter-face) 442 (1 font-lock-comment-delimiter-face)
441 (2 font-lock-comment-face)) 443 (2 font-lock-comment-face))
@@ -1785,7 +1787,7 @@ NOPROMPT, if non-nil, means not to prompt the user."
1785 (vc-working-revision file))))) 1787 (vc-working-revision file)))))
1786 (buf (if revision 1788 (buf (if revision
1787 (let ((vc-find-revision-no-save t)) 1789 (let ((vc-find-revision-no-save t))
1788 (vc-find-revision file revision diff-vc-backend)) 1790 (vc-find-revision (expand-file-name file) revision diff-vc-backend))
1789 (find-file-noselect file)))) 1791 (find-file-noselect file))))
1790 ;; Update the user preference if he so wished. 1792 ;; Update the user preference if he so wished.
1791 (when (> (prefix-numeric-value other-file) 8) 1793 (when (> (prefix-numeric-value other-file) 8)
@@ -2321,9 +2323,9 @@ fixed, visit it in a buffer."
2321 ;; FIXME: Include the first space for context-style hunks! 2323 ;; FIXME: Include the first space for context-style hunks!
2322 (while (re-search-forward "^[-+! ]" limit t) 2324 (while (re-search-forward "^[-+! ]" limit t)
2323 (let ((spec (alist-get (char-before) 2325 (let ((spec (alist-get (char-before)
2324 '((?+ . (left-fringe diff-fringe-add diff-added)) 2326 '((?+ . (left-fringe diff-fringe-add diff-indicator-added))
2325 (?- . (left-fringe diff-fringe-del diff-removed)) 2327 (?- . (left-fringe diff-fringe-del diff-indicator-removed))
2326 (?! . (left-fringe diff-fringe-rep diff-changed)) 2328 (?! . (left-fringe diff-fringe-rep diff-indicator-changed))
2327 (?\s . (left-fringe diff-fringe-nul)))))) 2329 (?\s . (left-fringe diff-fringe-nul))))))
2328 (put-text-property (match-beginning 0) (match-end 0) 'display spec)))) 2330 (put-text-property (match-beginning 0) (match-end 0) 'display spec))))
2329 ;; Mimicks the output of Magit's diff. 2331 ;; Mimicks the output of Magit's diff.
@@ -2523,14 +2525,14 @@ hunk text is not found in the source file."
2523 2525
2524 (when (and beg end) 2526 (when (and beg end)
2525 (goto-char beg) 2527 (goto-char beg)
2526 (when (text-property-not-all beg end 'fontified t) 2528 (if file
2527 (if file 2529 ;; In a temporary or cached buffer
2528 ;; In a temporary or cached buffer 2530 (when (text-property-not-all beg end 'fontified t)
2529 (save-excursion 2531 (save-excursion
2530 (font-lock-fontify-region beg end) 2532 (font-lock-fontify-region beg end)
2531 (put-text-property beg end 'fontified t)) 2533 (put-text-property beg end 'fontified t)))
2532 ;; In an existing buffer 2534 ;; In an existing buffer
2533 (font-lock-ensure beg end))) 2535 (font-lock-ensure beg end))
2534 2536
2535 (while (< (point) end) 2537 (while (< (point) end)
2536 (let* ((bol (point)) 2538 (let* ((bol (point))