*** empty log message ***
[emacs.git] / lisp / hi-lock.el
blobc3e2d814767210144478d15ef24173b614ace638
1 ;;; hi-lock.el --- minor mode for interactive automatic highlighting
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: David M. Koppelman, koppel@ee.lsu.edu
7 ;; Keywords: faces, minor-mode, matching, display
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; With the hi-lock commands text matching interactively entered
29 ;; regexp's can be highlighted. For example, `M-x highlight-regexp
30 ;; RET clearly RET RET' will highlight all occurrences of `clearly'
31 ;; using a yellow background face. New occurrences of `clearly' will
32 ;; be highlighted as they are typed. `M-x unhighlight-regexp RET'
33 ;; will remove the highlighting. Any existing face can be used for
34 ;; highlighting and a set of appropriate faces is provided. The
35 ;; regexps can be written into the current buffer in a form that will
36 ;; be recognized the next time the corresponding file is read.
38 ;; Applications:
40 ;; In program source code highlight a variable to quickly see all
41 ;; places it is modified or referenced:
42 ;; M-x highlight-regexp ground_contact_switches_closed RET RET
44 ;; In a shell or other buffer that is showing lots of program
45 ;; output, highlight the parts of the output you're interested in:
46 ;; M-x highlight-regexp Total execution time [0-9]+ RET hi-blue-b RET
48 ;; In buffers displaying tables, highlight the lines you're interested in:
49 ;; M-x highlight-lines-matching-regexp January 2000 RET hi-black-b RET
51 ;; When writing text, highlight personal cliches. This can be
52 ;; amusing.
53 ;; M-x highlight-phrase as can be seen RET RET
55 ;; Setup:
57 ;; Put the following code in your .emacs file. This turns on
58 ;; hi-lock mode and adds a "Regexp Highlighting" entry
59 ;; to the edit menu.
61 ;; (global-hi-lock-mode 1)
63 ;; You might also want to bind the hi-lock commands to more
64 ;; finger-friendly sequences:
66 ;; (define-key hi-lock-map "\C-z\C-h" 'highlight-lines-matching-regexp)
67 ;; (define-key hi-lock-map "\C-zi" 'hi-lock-find-patterns)
68 ;; (define-key hi-lock-map "\C-zh" 'highlight-regexp)
69 ;; (define-key hi-lock-map "\C-zp" 'highlight-phrase)
70 ;; (define-key hi-lock-map "\C-zr" 'unhighlight-regexp)
71 ;; (define-key hi-lock-map "\C-zb" 'hi-lock-write-interactive-patterns))
73 ;; See the documentation for hi-lock-mode `C-h f hi-lock-mode' for
74 ;; additional instructions.
76 ;; Sample file patterns:
78 ; Hi-lock: (("^;;; .*" (0 (quote hi-black-hb) t)))
79 ; Hi-lock: ( ("make-variable-buffer-\\(local\\)" (0 font-lock-keyword-face)(1 'italic append)))))
80 ; Hi-lock: end
82 ;;; Code:
84 (eval-and-compile
85 (require 'font-lock))
87 (defgroup hi-lock nil
88 "Interactively add and remove font-lock patterns for highlighting text."
89 :link '(custom-manual "(emacs)Highlight Interactively")
90 :group 'font-lock)
92 (defcustom hi-lock-file-patterns-range 10000
93 "Limit of search in a buffer for hi-lock patterns.
94 When a file is visited and hi-lock mode is on patterns starting
95 up to this limit are added to font-lock's patterns. See documentation
96 of functions `hi-lock-mode' and `hi-lock-find-patterns'."
97 :type 'integer
98 :group 'hi-lock)
100 (defcustom hi-lock-exclude-modes
101 '(rmail-mode mime/viewer-mode gnus-article-mode)
102 "List of major modes in which hi-lock will not run.
103 For security reasons since font lock patterns can specify function
104 calls."
105 :type '(repeat symbol)
106 :group 'hi-lock)
109 (defgroup hi-lock-faces nil
110 "Faces for hi-lock."
111 :group 'hi-lock
112 :group 'faces)
114 (defface hi-yellow
115 '((((min-colors 88) (background dark))
116 (:background "yellow1" :foreground "black"))
117 (((background dark)) (:background "yellow" :foreground "black"))
118 (((min-colors 88)) (:background "yellow1"))
119 (t (:background "yellow")))
120 "Default face for hi-lock mode."
121 :group 'hi-lock-faces)
123 (defface hi-pink
124 '((((background dark)) (:background "pink" :foreground "black"))
125 (t (:background "pink")))
126 "Face for hi-lock mode."
127 :group 'hi-lock-faces)
129 (defface hi-green
130 '((((min-colors 88) (background dark))
131 (:background "green1" :foreground "black"))
132 (((background dark)) (:background "green" :foreground "black"))
133 (((min-colors 88)) (:background "green1"))
134 (t (:background "green")))
135 "Face for hi-lock mode."
136 :group 'hi-lock-faces)
138 (defface hi-blue
139 '((((background dark)) (:background "light blue" :foreground "black"))
140 (t (:background "light blue")))
141 "Face for hi-lock mode."
142 :group 'hi-lock-faces)
144 (defface hi-black-b
145 '((t (:weight bold)))
146 "Face for hi-lock mode."
147 :group 'hi-lock-faces)
149 (defface hi-blue-b
150 '((((min-colors 88)) (:weight bold :foreground "blue1"))
151 (t (:weight bold :foreground "blue")))
152 "Face for hi-lock mode."
153 :group 'hi-lock-faces)
155 (defface hi-green-b
156 '((((min-colors 88)) (:weight bold :foreground "green1"))
157 (t (:weight bold :foreground "green")))
158 "Face for hi-lock mode."
159 :group 'hi-lock-faces)
161 (defface hi-red-b
162 '((((min-colors 88)) (:weight bold :foreground "red1"))
163 (t (:weight bold :foreground "red")))
164 "Face for hi-lock mode."
165 :group 'hi-lock-faces)
167 (defface hi-black-hb
168 '((t (:weight bold :height 1.67 :inherit variable-pitch)))
169 "Face for hi-lock mode."
170 :group 'hi-lock-faces)
172 (defvar hi-lock-file-patterns nil
173 "Patterns found in file for hi-lock. Should not be changed.")
175 (defvar hi-lock-interactive-patterns nil
176 "Patterns provided to hi-lock by user. Should not be changed.")
178 (defvar hi-lock-face-history
179 (list "hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b"
180 "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
181 "History list of faces for hi-lock interactive functions.")
183 ;(dolist (f hi-lock-face-history) (unless (facep f) (error "%s not a face" f)))
185 (defvar hi-lock-regexp-history nil
186 "History of regexps used for interactive fontification.")
188 (defvar hi-lock-file-patterns-prefix "Hi-lock"
189 "Regexp for finding hi-lock patterns at top of file.")
191 (defvar hi-lock-archaic-interface-message-used nil
192 "True if user alerted that global-hi-lock-mode is now the global switch.
193 Earlier versions of hi-lock used hi-lock-mode as the global switch,
194 the message is issued if it appears that hi-lock-mode is used assuming
195 that older functionality. This variable avoids multiple reminders.")
197 (defvar hi-lock-archaic-interface-deduce nil
198 "If non-nil, sometimes assume that hi-lock-mode means global-hi-lock-mode.
199 Assumption is made if hi-lock-mode used in the *scratch* buffer while
200 a library is being loaded.")
202 (make-variable-buffer-local 'hi-lock-interactive-patterns)
203 (put 'hi-lock-interactive-patterns 'permanent-local t)
204 (make-variable-buffer-local 'hi-lock-regexp-history)
205 (put 'hi-lock-regexp-history 'permanent-local t)
206 (make-variable-buffer-local 'hi-lock-file-patterns)
207 (put 'hi-lock-file-patterns 'permanent-local t)
209 (defvar hi-lock-menu (make-sparse-keymap "Hi Lock")
210 "Menu for hi-lock mode.")
212 (define-key-after hi-lock-menu [highlight-regexp]
213 '(menu-item "Highlight Regexp..." highlight-regexp
214 :help "Highlight text matching PATTERN (a regexp)."))
216 (define-key-after hi-lock-menu [highlight-phrase]
217 '(menu-item "Highlight Phrase..." highlight-phrase
218 :help "Highlight text matching PATTERN (a regexp processed to match phrases)."))
220 (define-key-after hi-lock-menu [highlight-lines-matching-regexp]
221 '(menu-item "Highlight Lines..." highlight-lines-matching-regexp
222 :help "Highlight lines containing match of PATTERN (a regexp).."))
224 (define-key-after hi-lock-menu [unhighlight-regexp]
225 '(menu-item "Remove Highlighting..." unhighlight-regexp
226 :help "Remove previously entered highlighting pattern."
227 :enable hi-lock-interactive-patterns))
229 (define-key-after hi-lock-menu [hi-lock-write-interactive-patterns]
230 '(menu-item "Patterns to Buffer" hi-lock-write-interactive-patterns
231 :help "Insert interactively added REGEXPs into buffer at point."
232 :enable hi-lock-interactive-patterns))
234 (define-key-after hi-lock-menu [hi-lock-find-patterns]
235 '(menu-item "Patterns from Buffer" hi-lock-find-patterns
236 :help "Use patterns (if any) near top of buffer."))
238 (defvar hi-lock-map (make-sparse-keymap "Hi Lock")
239 "Key map for hi-lock.")
241 (define-key hi-lock-map "\C-xwi" 'hi-lock-find-patterns)
242 (define-key hi-lock-map "\C-xwl" 'highlight-lines-matching-regexp)
243 (define-key hi-lock-map "\C-xwp" 'highlight-phrase)
244 (define-key hi-lock-map "\C-xwh" 'highlight-regexp)
245 (define-key hi-lock-map "\C-xwr" 'unhighlight-regexp)
246 (define-key hi-lock-map "\C-xwb" 'hi-lock-write-interactive-patterns)
248 ;; Visible Functions
251 ;;;###autoload
252 (define-minor-mode hi-lock-mode
253 "Toggle minor mode for interactively adding font-lock highlighting patterns.
255 If ARG positive turn hi-lock on. Issuing a hi-lock command will also
256 turn hi-lock on; to turn hi-lock on in all buffers use
257 global-hi-lock-mode or in your .emacs file (global-hi-lock-mode 1).
258 When hi-lock is turned on, a \"Regexp Highlighting\" submenu is added
259 to the \"Edit\" menu. The commands in the submenu, which can be
260 called interactively, are:
262 \\[highlight-regexp] REGEXP FACE
263 Highlight matches of pattern REGEXP in current buffer with FACE.
265 \\[highlight-phrase] PHRASE FACE
266 Highlight matches of phrase PHRASE in current buffer with FACE.
267 (PHRASE can be any REGEXP, but spaces will be replaced by matches
268 to whitespace and initial lower-case letters will become case insensitive.)
270 \\[highlight-lines-matching-regexp] REGEXP FACE
271 Highlight lines containing matches of REGEXP in current buffer with FACE.
273 \\[unhighlight-regexp] REGEXP
274 Remove highlighting on matches of REGEXP in current buffer.
276 \\[hi-lock-write-interactive-patterns]
277 Write active REGEXPs into buffer as comments (if possible). They will
278 be read the next time file is loaded or when the \\[hi-lock-find-patterns] command
279 is issued. The inserted regexps are in the form of font lock keywords.
280 (See `font-lock-keywords') They may be edited and re-loaded with \\[hi-lock-find-patterns],
281 any valid `font-lock-keywords' form is acceptable.
283 \\[hi-lock-find-patterns]
284 Re-read patterns stored in buffer (in the format produced by \\[hi-lock-write-interactive-patterns]).
286 When hi-lock is started and if the mode is not excluded, the
287 beginning of the buffer is searched for lines of the form:
288 Hi-lock: FOO
289 where FOO is a list of patterns. These are added to the font lock keywords
290 already present. The patterns must start before position (number
291 of characters into buffer) `hi-lock-file-patterns-range'. Patterns
292 will be read until
293 Hi-lock: end
294 is found. A mode is excluded if it's in the list `hi-lock-exclude-modes'."
295 :group 'hi-lock
296 :lighter " H"
297 :global nil
298 :keymap hi-lock-map
299 (when (and (equal (buffer-name) "*scratch*")
300 load-in-progress
301 (not (interactive-p))
302 (not hi-lock-archaic-interface-message-used))
303 (setq hi-lock-archaic-interface-message-used t)
304 (if hi-lock-archaic-interface-deduce
305 (global-hi-lock-mode hi-lock-mode)
306 (warn
307 "Possible archaic use of (hi-lock-mode).
308 Use (global-hi-lock-mode 1) in .emacs to enable hi-lock for all buffers,
309 use (hi-lock-mode 1) for individual buffers. For compatibility with Emacs
310 versions before 22 use the following in your .emacs file:
312 (if (functionp 'global-hi-lock-mode)
313 (global-hi-lock-mode 1)
314 (hi-lock-mode 1))
315 ")))
316 (if hi-lock-mode
317 ;; Turned on.
318 (progn
319 (unless font-lock-mode (font-lock-mode 1))
320 (define-key-after menu-bar-edit-menu [hi-lock]
321 (cons "Regexp Highlighting" hi-lock-menu))
322 (hi-lock-find-patterns)
323 (add-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook nil t))
324 ;; Turned off.
325 (when (or hi-lock-interactive-patterns
326 hi-lock-file-patterns)
327 (when hi-lock-interactive-patterns
328 (font-lock-remove-keywords nil hi-lock-interactive-patterns)
329 (setq hi-lock-interactive-patterns nil))
330 (when hi-lock-file-patterns
331 (font-lock-remove-keywords nil hi-lock-file-patterns)
332 (setq hi-lock-file-patterns nil))
333 (if font-lock-mode
334 (font-lock-fontify-buffer)))
335 (define-key-after menu-bar-edit-menu [hi-lock] nil)
336 (remove-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook t)))
338 ;;;###autoload
339 (define-global-minor-mode global-hi-lock-mode
340 hi-lock-mode turn-on-hi-lock-if-enabled
341 :group 'hi-lock)
343 (defun turn-on-hi-lock-if-enabled ()
344 (setq hi-lock-archaic-interface-message-used t)
345 (unless (memq major-mode hi-lock-exclude-modes)
346 (hi-lock-mode 1)))
348 ;;;###autoload
349 (defalias 'highlight-lines-matching-regexp 'hi-lock-line-face-buffer)
350 ;;;###autoload
351 (defun hi-lock-line-face-buffer (regexp &optional face)
352 "Set face of all lines containing a match of REGEXP to FACE.
354 Interactively, prompt for REGEXP then FACE. Buffer-local history
355 list maintained for regexps, global history maintained for faces.
356 \\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
357 \(See info node `Minibuffer History')"
358 (interactive
359 (list
360 (hi-lock-regexp-okay
361 (read-from-minibuffer "Regexp to highlight line: "
362 (cons (or (car hi-lock-regexp-history) "") 1 )
363 nil nil 'hi-lock-regexp-history))
364 (hi-lock-read-face-name)))
365 (or (facep face) (setq face 'hi-yellow))
366 (unless hi-lock-mode (hi-lock-mode 1))
367 (hi-lock-set-pattern
368 ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ?
369 ;; or a trailing $ in REGEXP will be interpreted correctly.
370 (concat "^.*\\(?:" regexp "\\).*$") face))
373 ;;;###autoload
374 (defalias 'highlight-regexp 'hi-lock-face-buffer)
375 ;;;###autoload
376 (defun hi-lock-face-buffer (regexp &optional face)
377 "Set face of each match of REGEXP to FACE.
379 Interactively, prompt for REGEXP then FACE. Buffer-local history
380 list maintained for regexps, global history maintained for faces.
381 \\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
382 \(See info node `Minibuffer History')"
383 (interactive
384 (list
385 (hi-lock-regexp-okay
386 (read-from-minibuffer "Regexp to highlight: "
387 (cons (or (car hi-lock-regexp-history) "") 1 )
388 nil nil 'hi-lock-regexp-history))
389 (hi-lock-read-face-name)))
390 (or (facep face) (setq face 'hi-yellow))
391 (unless hi-lock-mode (hi-lock-mode 1))
392 (hi-lock-set-pattern regexp face))
394 ;;;###autoload
395 (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer)
396 ;;;###autoload
397 (defun hi-lock-face-phrase-buffer (regexp &optional face)
398 "Set face of each match of phrase REGEXP to FACE.
400 Whitespace in REGEXP converted to arbitrary whitespace and initial
401 lower-case letters made case insensitive."
402 (interactive
403 (list
404 (hi-lock-regexp-okay
405 (hi-lock-process-phrase
406 (read-from-minibuffer "Phrase to highlight: "
407 (cons (or (car hi-lock-regexp-history) "") 1 )
408 nil nil 'hi-lock-regexp-history)))
409 (hi-lock-read-face-name)))
410 (or (facep face) (setq face 'hi-yellow))
411 (unless hi-lock-mode (hi-lock-mode 1))
412 (hi-lock-set-pattern regexp face))
414 ;;;###autoload
415 (defalias 'unhighlight-regexp 'hi-lock-unface-buffer)
416 ;;;###autoload
417 (defun hi-lock-unface-buffer (regexp)
418 "Remove highlighting of each match to REGEXP set by hi-lock.
420 Interactively, prompt for REGEXP. Buffer-local history of inserted
421 regexp's maintained. Will accept only regexps inserted by hi-lock
422 interactive functions. \(See `hi-lock-interactive-patterns'.\)
423 \\<minibuffer-local-must-match-map>Use \\[minibuffer-complete] to complete a partially typed regexp.
424 \(See info node `Minibuffer History'.\)"
425 (interactive
426 (if (and (display-popup-menus-p) (vectorp (this-command-keys)))
427 (catch 'snafu
429 (x-popup-menu
431 (cons
432 `keymap
433 (cons "Select Pattern to Unhighlight"
434 (mapcar (lambda (pattern)
435 (list (car pattern)
436 (format
437 "%s (%s)" (car pattern)
438 (symbol-name
439 (car
440 (cdr (car (cdr (car (cdr pattern))))))))
441 (cons nil nil)
442 (car pattern)))
443 hi-lock-interactive-patterns))))
444 ;; If the user clicks outside the menu, meaning that they
445 ;; change their mind, x-popup-menu returns nil, and
446 ;; interactive signals a wrong number of arguments error.
447 ;; To prevent that, we return an empty string, which will
448 ;; effectively disable the rest of the function.
449 (throw 'snafu '(""))))
450 (let ((history-list (mapcar (lambda (p) (car p))
451 hi-lock-interactive-patterns)))
452 (unless hi-lock-interactive-patterns
453 (error "No highlighting to remove"))
454 (list
455 (completing-read "Regexp to unhighlight: "
456 hi-lock-interactive-patterns nil t
457 (car (car hi-lock-interactive-patterns))
458 (cons 'history-list 1))))))
459 (let ((keyword (assoc regexp hi-lock-interactive-patterns)))
460 (when keyword
461 (font-lock-remove-keywords nil (list keyword))
462 (setq hi-lock-interactive-patterns
463 (delq keyword hi-lock-interactive-patterns))
464 (font-lock-fontify-buffer))))
466 ;;;###autoload
467 (defun hi-lock-write-interactive-patterns ()
468 "Write interactively added patterns, if any, into buffer at point.
470 Interactively added patterns are those normally specified using
471 `highlight-regexp' and `highlight-lines-matching-regexp'; they can
472 be found in variable `hi-lock-interactive-patterns'."
473 (interactive)
474 (if (null hi-lock-interactive-patterns)
475 (error "There are no interactive patterns"))
476 (let ((beg (point)))
477 (mapcar
478 (lambda (pattern)
479 (insert (format "Hi-lock: (%s)\n" (prin1-to-string pattern))))
480 hi-lock-interactive-patterns)
481 (comment-region beg (point)))
482 (when (> (point) hi-lock-file-patterns-range)
483 (warn "Inserted keywords not close enough to top of file")))
485 ;; Implementation Functions
487 (defun hi-lock-process-phrase (phrase)
488 "Convert regexp PHRASE to a regexp that matches phrases.
490 Blanks in PHRASE replaced by regexp that matches arbitrary whitespace
491 and initial lower-case letters made case insensitive."
492 (let ((mod-phrase nil))
493 (setq mod-phrase
494 (replace-regexp-in-string
495 "\\<[a-z]" (lambda (m) (format "[%s%s]" (upcase m) m)) phrase))
496 (setq mod-phrase
497 (replace-regexp-in-string
498 "\\s-+" "[ \t\n]+" mod-phrase nil t))))
500 (defun hi-lock-regexp-okay (regexp)
501 "Return REGEXP if it appears suitable for a font-lock pattern.
503 Otherwise signal an error. A pattern that matches the null string is
504 not suitable."
505 (if (string-match regexp "")
506 (error "Regexp cannot match an empty string")
507 regexp))
509 (defun hi-lock-read-face-name ()
510 "Read face name from minibuffer with completion and history."
511 (intern (completing-read
512 "Highlight using face: "
513 obarray 'facep t
514 (cons (car hi-lock-face-history)
515 (let ((prefix
516 (try-completion
517 (substring (car hi-lock-face-history) 0 1)
518 (mapcar (lambda (f) (cons f f))
519 hi-lock-face-history))))
520 (if (and (stringp prefix)
521 (not (equal prefix (car hi-lock-face-history))))
522 (length prefix) 0)))
523 '(hi-lock-face-history . 0))))
525 (defun hi-lock-set-pattern (regexp face)
526 "Highlight REGEXP with face FACE."
527 (let ((pattern (list regexp (list 0 (list 'quote face) t))))
528 (unless (member pattern hi-lock-interactive-patterns)
529 (font-lock-add-keywords nil (list pattern))
530 (push pattern hi-lock-interactive-patterns)
531 (let ((buffer-undo-list t)
532 (inhibit-read-only t)
533 (mod (buffer-modified-p)))
534 (save-excursion
535 (goto-char (point-min))
536 (while (re-search-forward regexp (point-max) t)
537 (put-text-property
538 (match-beginning 0) (match-end 0) 'face face)
539 (goto-char (match-end 0))))
540 (set-buffer-modified-p mod)))))
542 (defun hi-lock-set-file-patterns (patterns)
543 "Replace file patterns list with PATTERNS and refontify."
544 (when (or hi-lock-file-patterns patterns)
545 (font-lock-remove-keywords nil hi-lock-file-patterns)
546 (setq hi-lock-file-patterns patterns)
547 (font-lock-add-keywords nil hi-lock-file-patterns)
548 (font-lock-fontify-buffer)))
550 (defun hi-lock-find-patterns ()
551 "Find patterns in current buffer for hi-lock."
552 (interactive)
553 (unless (memq major-mode hi-lock-exclude-modes)
554 (let ((all-patterns nil)
555 (target-regexp (concat "\\<" hi-lock-file-patterns-prefix ":")))
556 (save-excursion
557 (save-restriction
558 (widen)
559 (goto-char (point-min))
560 (re-search-forward target-regexp
561 (+ (point) hi-lock-file-patterns-range) t)
562 (beginning-of-line)
563 (while (and (re-search-forward target-regexp (+ (point) 100) t)
564 (not (looking-at "\\s-*end")))
565 (condition-case nil
566 (setq all-patterns (append (read (current-buffer)) all-patterns))
567 (error (message "Invalid pattern list expression at %d"
568 (line-number-at-pos)))))))
569 (when hi-lock-mode (hi-lock-set-file-patterns all-patterns))
570 (if (interactive-p)
571 (message "Hi-lock added %d patterns." (length all-patterns))))))
573 (defun hi-lock-font-lock-hook ()
574 "Add hi lock patterns to font-lock's."
575 (if font-lock-mode
576 (progn (font-lock-add-keywords nil hi-lock-file-patterns)
577 (font-lock-add-keywords nil hi-lock-interactive-patterns))
578 (hi-lock-mode -1)))
580 (provide 'hi-lock)
582 ;; arch-tag: d2e8fd07-4cc9-4c6f-a200-1e729bc54066
583 ;;; hi-lock.el ends here