]> git.eshelyaron.com Git - emacs.git/commitdiff
More font-lock improvements for diff-mode
authorJuri Linkov <juri@linkov.net>
Tue, 18 Dec 2018 23:10:09 +0000 (01:10 +0200)
committerJuri Linkov <juri@linkov.net>
Tue, 18 Dec 2018 23:10:09 +0000 (01:10 +0200)
* 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.

lisp/replace.el
lisp/vc/diff-mode.el

index dcae12e9b762f3b06878e0255db132f32895a7d7..b8f231eb55d3bdd704a70967382a894732d7f203 100644 (file)
@@ -1907,10 +1907,8 @@ See also `multi-occur'."
       global-matches)))
 
 (defun occur-engine-line (beg end &optional keep-props)
-  (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
-          (text-property-not-all beg end 'fontified t))
-      (if (fboundp 'jit-lock-fontify-now)
-         (jit-lock-fontify-now beg end)))
+  (if (and keep-props font-lock-mode)
+      (font-lock-ensure beg end))
   (if (and keep-props (not (eq occur-excluded-properties t)))
       (let ((str (buffer-substring beg end)))
        (remove-list-of-text-properties
index 549f49a8d13fa917e7eb493de638f660795677da..043d22d14b33a85543f825123032cfcbb757a37c 100644 (file)
@@ -255,7 +255,7 @@ in wrong fontification.  This is the fastest option, but less reliable."
   "Keymap for `diff-minor-mode'.  See also `diff-mode-shared-map'.")
 
 (define-minor-mode diff-auto-refine-mode
-  "Toggle automatic diff hunk highlighting (Diff Auto Refine mode).
+  "Toggle automatic diff hunk finer highlighting (Diff Auto Refine mode).
 
 Diff Auto Refine mode is a buffer-local minor mode used with
 `diff-mode'.  When enabled, Emacs automatically highlights
@@ -435,7 +435,9 @@ and the face `diff-added' for added lines.")
                'diff-removed))))))
     ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
      (0 'diff-header) (1 'diff-index prepend))
+    ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)
     ("^Only in .*\n" . 'diff-nonexistent)
+    ("^Binary files .* differ\n" . 'diff-file-header)
     ("^\\(#\\)\\(.*\\)"
      (1 font-lock-comment-delimiter-face)
      (2 font-lock-comment-face))
@@ -1785,7 +1787,7 @@ NOPROMPT, if non-nil, means not to prompt the user."
                                 (vc-working-revision file)))))
           (buf (if revision
                     (let ((vc-find-revision-no-save t))
-                      (vc-find-revision file revision diff-vc-backend))
+                      (vc-find-revision (expand-file-name file) revision diff-vc-backend))
                   (find-file-noselect file))))
       ;; Update the user preference if he so wished.
       (when (> (prefix-numeric-value other-file) 8)
@@ -2321,9 +2323,9 @@ fixed, visit it in a buffer."
       ;; FIXME: Include the first space for context-style hunks!
       (while (re-search-forward "^[-+! ]" limit t)
         (let ((spec (alist-get (char-before)
-                               '((?+ . (left-fringe diff-fringe-add diff-added))
-                                 (?- . (left-fringe diff-fringe-del diff-removed))
-                                 (?! . (left-fringe diff-fringe-rep diff-changed))
+                               '((?+ . (left-fringe diff-fringe-add diff-indicator-added))
+                                 (?- . (left-fringe diff-fringe-del diff-indicator-removed))
+                                 (?! . (left-fringe diff-fringe-rep diff-indicator-changed))
                                  (?\s . (left-fringe diff-fringe-nul))))))
           (put-text-property (match-beginning 0) (match-end 0) 'display spec))))
     ;; Mimicks the output of Magit's diff.
@@ -2523,14 +2525,14 @@ hunk text is not found in the source file."
 
     (when (and beg end)
       (goto-char beg)
-      (when (text-property-not-all beg end 'fontified t)
-        (if file
-            ;; In a temporary or cached buffer
+      (if file
+          ;; In a temporary or cached buffer
+          (when (text-property-not-all beg end 'fontified t)
             (save-excursion
               (font-lock-fontify-region beg end)
-              (put-text-property beg end 'fontified t))
-          ;; In an existing buffer
-          (font-lock-ensure beg end)))
+              (put-text-property beg end 'fontified t)))
+        ;; In an existing buffer
+        (font-lock-ensure beg end))
 
       (while (< (point) end)
         (let* ((bol (point))