comparison lisp/hi-lock.el @ 103056:b6361d016a5a

* hi-lock.el (hi-lock--inhibit-font-lock-hook): New var. (hi-lock-set-pattern, hi-lock-font-lock-hook): Use it (Bug#3068).
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 23 Apr 2009 01:34:54 +0000
parents a9dc0e7c3f2b
children b78ceb253d15
comparison
equal deleted inserted replaced
103055:3aba158ceebe 103056:b6361d016a5a
562 (not (equal prefix (car hi-lock-face-defaults)))) 562 (not (equal prefix (car hi-lock-face-defaults))))
563 (length prefix) 0))) 563 (length prefix) 0)))
564 'face-name-history 564 'face-name-history
565 (cdr hi-lock-face-defaults)))) 565 (cdr hi-lock-face-defaults))))
566 566
567 (defvar hi-lock--inhibit-font-lock-hook nil
568 "Inhibit the action of `hi-lock-font-lock-hook'.
569 This is used by `hi-lock-set-pattern'.")
570
567 (defun hi-lock-set-pattern (regexp face) 571 (defun hi-lock-set-pattern (regexp face)
568 "Highlight REGEXP with face FACE." 572 "Highlight REGEXP with face FACE."
569 (let ((pattern (list regexp (list 0 (list 'quote face) t)))) 573 (let ((pattern (list regexp (list 0 (list 'quote face) t)))
574 ;; The call to `font-lock-add-keywords' below might disable
575 ;; and re-enable font-lock mode. If so, we don't want
576 ;; `hi-lock-font-lock-hook' to run. This can be removed once
577 ;; Bug#635 is fixed. -- cyd
578 (hi-lock--inhibit-font-lock-hook t))
570 (unless (member pattern hi-lock-interactive-patterns) 579 (unless (member pattern hi-lock-interactive-patterns)
571 (font-lock-add-keywords nil (list pattern) t) 580 (font-lock-add-keywords nil (list pattern) t)
572 (push pattern hi-lock-interactive-patterns) 581 (push pattern hi-lock-interactive-patterns)
573 (if font-lock-fontified 582 (if font-lock-fontified
574 (font-lock-fontify-buffer) 583 (font-lock-fontify-buffer)
630 (if (interactive-p) 639 (if (interactive-p)
631 (message "Hi-lock added %d patterns." (length all-patterns))))))) 640 (message "Hi-lock added %d patterns." (length all-patterns)))))))
632 641
633 (defun hi-lock-font-lock-hook () 642 (defun hi-lock-font-lock-hook ()
634 "Add hi-lock patterns to font-lock's." 643 "Add hi-lock patterns to font-lock's."
635 (if font-lock-mode 644 (unless hi-lock--inhibit-font-lock-hook
636 (progn 645 (if font-lock-mode
637 (font-lock-add-keywords nil hi-lock-file-patterns t) 646 (progn
638 (font-lock-add-keywords nil hi-lock-interactive-patterns t)) 647 (font-lock-add-keywords nil hi-lock-file-patterns t)
639 (hi-lock-mode -1))) 648 (font-lock-add-keywords nil hi-lock-interactive-patterns t))
649 (hi-lock-mode -1))))
640 650
641 (defvar hi-lock-string-serialize-hash 651 (defvar hi-lock-string-serialize-hash
642 (make-hash-table :test 'equal) 652 (make-hash-table :test 'equal)
643 "Hash table used to assign unique numbers to strings.") 653 "Hash table used to assign unique numbers to strings.")
644 654