* lisp/hi-lock.el (hi-lock-revert-buffer-rehighlight): Restore same faces.
authorJuri Linkov <juri@linkov.net>
Thu, 20 Jun 2024 16:49:30 +0000 (19:49 +0300)
committerJuri Linkov <juri@linkov.net>
Thu, 20 Jun 2024 16:49:30 +0000 (19:49 +0300)
After reverting the buffer apply all previous patterns with exactly
the same faces as were assigned to patterns before.

lisp/hi-lock.el

index 3c26cc845098174987f10a6040ae51a19c4c99b1..64b84cdf8596965a907f2bff84df9896db0194fd 100644 (file)
@@ -868,11 +868,10 @@ SPACES-REGEXP is a regexp to substitute spaces in font-lock search."
 Apply the previous patterns after reverting the buffer."
   (when-let ((patterns hi-lock-interactive-lighters))
     (lambda ()
-      (setq hi-lock-interactive-lighters nil
-            hi-lock-interactive-patterns nil)
-      (let ((hi-lock-auto-select-face t))
-        (dolist (pattern (reverse patterns))
-          (highlight-regexp (car pattern) (hi-lock-read-face-name)))))))
+      (when hi-lock-interactive-lighters
+        (hi-lock-unface-buffer t))
+      (dolist (pattern (reverse patterns))
+        (highlight-regexp (car pattern) (cadr (nth 1 (caddr pattern))))))))
 
 (defvar hi-lock--hashcons-hash
   (make-hash-table :test 'equal :weakness t)