]> code.delx.au - gnu-emacs/blobdiff - lisp/hi-lock.el
Quiet, woman. (Sorry...).
[gnu-emacs] / lisp / hi-lock.el
index 418a98f3f3a3bb496190753d4e652ba544d77f5f..0273de14edd71287e6842732eb936b782bc7f16a 100644 (file)
@@ -1,7 +1,7 @@
 ;;; hi-lock.el --- minor mode for interactive automatic highlighting
 
 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009 Free Software Foundation, Inc.
+;;   2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: David M. Koppelman <koppel@ece.lsu.edu>
 ;; Keywords: faces, minor-mode, matching, display
@@ -564,23 +564,15 @@ 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)))
-       ;; 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))
+  (let ((pattern (list regexp (list 0 (list 'quote face) t))))
     (unless (member pattern hi-lock-interactive-patterns)
-      (font-lock-add-keywords nil (list pattern) t)
       (push pattern hi-lock-interactive-patterns)
       (if font-lock-fontified
-          (font-lock-fontify-buffer)
+         (progn
+           (font-lock-add-keywords nil (list pattern) t)
+           (font-lock-fontify-buffer))
         (let* ((serial (hi-lock-string-serialize regexp))
                (range-min (- (point) (/ hi-lock-highlight-range 2)))
                (range-max (+ (point) (/ hi-lock-highlight-range 2)))
@@ -641,12 +633,9 @@ This is used by `hi-lock-set-pattern'.")
 
 (defun hi-lock-font-lock-hook ()
   "Add hi-lock patterns to font-lock's."
-  (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))))
+  (when font-lock-fontified
+    (font-lock-add-keywords nil hi-lock-file-patterns t)
+    (font-lock-add-keywords nil hi-lock-interactive-patterns t)))
 
 (defvar hi-lock-string-serialize-hash
   (make-hash-table :test 'equal)