emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 c1401d1c6c: * lisp/vc/diff-mode.el (diff-font-lock-keywords): C


From: Juri Linkov
Subject: emacs-29 c1401d1c6c: * lisp/vc/diff-mode.el (diff-font-lock-keywords): Check for limit.
Date: Mon, 9 Jan 2023 02:54:52 -0500 (EST)

branch: emacs-29
commit c1401d1c6c834c4b264cc2435f562b28bc9c83a8
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/vc/diff-mode.el (diff-font-lock-keywords): Check for limit.
    
    This check is necessary since 'diff-beginning-of-hunk' can move
    not only backwards, but also forwards (bug#60660).
---
 lisp/vc/diff-mode.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index acfd2c30f0..eb01dede56 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -485,17 +485,19 @@ use the face `diff-removed' for removed lines, and the 
face
          ;; if below, use `diff-added'.
          (save-match-data
            (let ((limit (save-excursion (diff-beginning-of-hunk))))
-             (if (save-excursion (re-search-backward 
diff-context-mid-hunk-header-re limit t))
-                 diff-indicator-added-face
-               diff-indicator-removed-face)))))
+              (when (< limit (point))
+                (if (save-excursion (re-search-backward 
diff-context-mid-hunk-header-re limit t))
+                   diff-indicator-added-face
+                 diff-indicator-removed-face))))))
      (2 (if diff-use-changed-face
            'diff-changed-unspecified
          ;; Otherwise, use the same method as above.
          (save-match-data
            (let ((limit (save-excursion (diff-beginning-of-hunk))))
-             (if (save-excursion (re-search-backward 
diff-context-mid-hunk-header-re limit t))
-                 'diff-added
-               'diff-removed))))))
+             (when (< limit (point))
+                (if (save-excursion (re-search-backward 
diff-context-mid-hunk-header-re limit t))
+                   'diff-added
+                 'diff-removed)))))))
     ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
      (0 'diff-header) (1 'diff-index prepend))
     ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]