diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2009-04-23 01:34:54 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2009-04-23 01:34:54 +0000 |
commit | 474749510e6da2f8250dd599f20bdc38c153f344 (patch) | |
tree | 6e5b5f1355584b0494de67691e0956b893f3fde1 /lisp/hi-lock.el | |
parent | 493dcf2c9b64d5eb8ef8e218cf1da65ab5f21e92 (diff) | |
download | emacs-474749510e6da2f8250dd599f20bdc38c153f344.tar.gz |
* hi-lock.el (hi-lock--inhibit-font-lock-hook): New var.
(hi-lock-set-pattern, hi-lock-font-lock-hook): Use it (Bug#3068).
Diffstat (limited to 'lisp/hi-lock.el')
-rw-r--r-- | lisp/hi-lock.el | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 3bc8c8b1abd..672f399d9a1 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -564,9 +564,18 @@ not suitable." 'face-name-history (cdr hi-lock-face-defaults)))) +(defvar hi-lock--inhibit-font-lock-hook nil + "Inhibit the action of `hi-lock-font-lock-hook'. +This is used by `hi-lock-set-pattern'.") + (defun hi-lock-set-pattern (regexp face) "Highlight REGEXP with face FACE." - (let ((pattern (list regexp (list 0 (list 'quote face) t)))) + (let ((pattern (list regexp (list 0 (list 'quote face) t))) + ;; The call to `font-lock-add-keywords' below might disable + ;; and re-enable font-lock mode. If so, we don't want + ;; `hi-lock-font-lock-hook' to run. This can be removed once + ;; Bug#635 is fixed. -- cyd + (hi-lock--inhibit-font-lock-hook t)) (unless (member pattern hi-lock-interactive-patterns) (font-lock-add-keywords nil (list pattern) t) (push pattern hi-lock-interactive-patterns) @@ -632,11 +641,12 @@ not suitable." (defun hi-lock-font-lock-hook () "Add hi-lock patterns to font-lock's." - (if font-lock-mode - (progn - (font-lock-add-keywords nil hi-lock-file-patterns t) - (font-lock-add-keywords nil hi-lock-interactive-patterns t)) - (hi-lock-mode -1))) + (unless hi-lock--inhibit-font-lock-hook + (if font-lock-mode + (progn + (font-lock-add-keywords nil hi-lock-file-patterns t) + (font-lock-add-keywords nil hi-lock-interactive-patterns t)) + (hi-lock-mode -1)))) (defvar hi-lock-string-serialize-hash (make-hash-table :test 'equal) |