]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/hi-lock.el (hi-lock-revert-buffer-rehighlight): Improve (bug#57534).
authorJuri Linkov <juri@linkov.net>
Thu, 27 Jun 2024 17:05:58 +0000 (20:05 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 28 Jun 2024 06:12:34 +0000 (08:12 +0200)
Instead of detecting invalidated overlays, use the same condition
as in 'hi-lock-set-pattern', and always re-highlight overlays,
because even when overlays stays on their original positions,
there is a need to highlight more matches possibly added after revert.

(cherry picked from commit 280c91782afa0c6ae667785b806da58e6be102ae)

lisp/hi-lock.el

index 648a33163235de2b306a3234833053466c0536fe..e1fa992cb12d076f6793a911070d5b1366e7c7b0 100644 (file)
@@ -879,12 +879,13 @@ Apply the previous patterns after reverting the buffer."
           (let ((hi-lock-file-patterns-policy policy))
             (hi-lock-mode 1))
           (setq rehighlight t))
-        ;; When hi-lock overlays were relocated to the top
-        (when (seq-some (lambda (o) (overlay-get o 'hi-lock-overlay))
-                        (overlays-in (point-min) (point-min)))
+        ;; When using hi-lock overlays, then need to update them
+        (unless (and font-lock-mode (font-lock-specified-p major-mode)
+                     (not hi-lock-use-overlays))
           (hi-lock-unface-buffer t)
           (setq rehighlight t))
         (when rehighlight
+          (setq hi-lock--unused-faces hi-lock-face-defaults)
           (dolist (pattern (reverse patterns))
             (let ((face (hi-lock-keyword->face (cdr pattern))))
               (highlight-regexp (car pattern) face)