diff options
| -rw-r--r-- | lisp/hi-lock.el | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 516bee67dd0..3c26cc84509 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el | |||
| @@ -376,7 +376,9 @@ use (hi-lock-mode 1) for individual buffers."))) | |||
| 376 | (hi-lock-find-patterns) | 376 | (hi-lock-find-patterns) |
| 377 | (add-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook nil t) | 377 | (add-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook nil t) |
| 378 | ;; Remove regexps from font-lock-keywords (bug#13891). | 378 | ;; Remove regexps from font-lock-keywords (bug#13891). |
| 379 | (add-hook 'change-major-mode-hook (lambda () (hi-lock-mode -1)) nil t)) | 379 | (add-hook 'change-major-mode-hook (lambda () (hi-lock-mode -1)) nil t) |
| 380 | (add-hook 'revert-buffer-restore-functions | ||
| 381 | #'hi-lock-revert-buffer-rehighlight nil t)) | ||
| 380 | ;; Turned off. | 382 | ;; Turned off. |
| 381 | (when (or hi-lock-interactive-patterns | 383 | (when (or hi-lock-interactive-patterns |
| 382 | hi-lock-file-patterns) | 384 | hi-lock-file-patterns) |
| @@ -390,7 +392,9 @@ use (hi-lock-mode 1) for individual buffers."))) | |||
| 390 | (remove-overlays nil nil 'hi-lock-overlay t) | 392 | (remove-overlays nil nil 'hi-lock-overlay t) |
| 391 | (font-lock-flush)) | 393 | (font-lock-flush)) |
| 392 | (define-key-after menu-bar-edit-menu [hi-lock] nil) | 394 | (define-key-after menu-bar-edit-menu [hi-lock] nil) |
| 393 | (remove-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook t))) | 395 | (remove-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook t) |
| 396 | (remove-hook 'revert-buffer-restore-functions | ||
| 397 | #'hi-lock-revert-buffer-rehighlight t))) | ||
| 394 | 398 | ||
| 395 | ;;;###autoload | 399 | ;;;###autoload |
| 396 | (define-globalized-minor-mode global-hi-lock-mode | 400 | (define-globalized-minor-mode global-hi-lock-mode |
| @@ -859,6 +863,17 @@ SPACES-REGEXP is a regexp to substitute spaces in font-lock search." | |||
| 859 | (font-lock-add-keywords nil hi-lock-file-patterns t) | 863 | (font-lock-add-keywords nil hi-lock-file-patterns t) |
| 860 | (font-lock-add-keywords nil hi-lock-interactive-patterns t))) | 864 | (font-lock-add-keywords nil hi-lock-interactive-patterns t))) |
| 861 | 865 | ||
| 866 | (defun hi-lock-revert-buffer-rehighlight () | ||
| 867 | "Rehighlight hi-lock patterns after `revert-buffer'. | ||
| 868 | Apply the previous patterns after reverting the buffer." | ||
| 869 | (when-let ((patterns hi-lock-interactive-lighters)) | ||
| 870 | (lambda () | ||
| 871 | (setq hi-lock-interactive-lighters nil | ||
| 872 | hi-lock-interactive-patterns nil) | ||
| 873 | (let ((hi-lock-auto-select-face t)) | ||
| 874 | (dolist (pattern (reverse patterns)) | ||
| 875 | (highlight-regexp (car pattern) (hi-lock-read-face-name))))))) | ||
| 876 | |||
| 862 | (defvar hi-lock--hashcons-hash | 877 | (defvar hi-lock--hashcons-hash |
| 863 | (make-hash-table :test 'equal :weakness t) | 878 | (make-hash-table :test 'equal :weakness t) |
| 864 | "Hash table used to hash cons regexps.") | 879 | "Hash table used to hash cons regexps.") |