/[emacs]/emacs/lisp/hi-lock.el
ViewVC logotype

Diff of /emacs/lisp/hi-lock.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by cyd, Tue Nov 29 22:28:59 2005 UTC revision 1.35 by eliz, Sat Dec 10 11:47:28 2005 UTC
# Line 58  Line 58 
58  ;;    hi-lock mode and adds a "Regexp Highlighting" entry  ;;    hi-lock mode and adds a "Regexp Highlighting" entry
59  ;;    to the edit menu.  ;;    to the edit menu.
60  ;;  ;;
61  ;;    (hi-lock-mode 1)  ;;    (global-hi-lock-mode 1)
62  ;;  ;;
63  ;;    You might also want to bind the hi-lock commands to more  ;;    You might also want to bind the hi-lock commands to more
64  ;;    finger-friendly sequences:  ;;    finger-friendly sequences:
# Line 188  calls." Line 188  calls."
188  (defvar hi-lock-file-patterns-prefix "Hi-lock"  (defvar hi-lock-file-patterns-prefix "Hi-lock"
189    "Regexp for finding hi-lock patterns at top of file.")    "Regexp for finding hi-lock patterns at top of file.")
190    
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.")
196    
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.")
201    
202  (make-variable-buffer-local 'hi-lock-interactive-patterns)  (make-variable-buffer-local 'hi-lock-interactive-patterns)
203  (put 'hi-lock-interactive-patterns 'permanent-local t)  (put 'hi-lock-interactive-patterns 'permanent-local t)
204  (make-variable-buffer-local 'hi-lock-regexp-history)  (make-variable-buffer-local 'hi-lock-regexp-history)
# Line 238  calls." Line 249  calls."
249    
250    
251  ;;;###autoload  ;;;###autoload
252  (define-minor-mode hi-lock-buffer-mode  (define-minor-mode hi-lock-mode
253    "Toggle minor mode for interactively adding font-lock highlighting patterns.    "Toggle minor mode for interactively adding font-lock highlighting patterns.
254    
255  If ARG positive turn hi-lock on.  Issuing a hi-lock command will also  If ARG positive turn hi-lock on.  Issuing a hi-lock command will also
256  turn hi-lock on.  When hi-lock is turned on, a \"Regexp Highlighting\"  turn hi-lock on; to turn hi-lock on in all buffers use
257  submenu is added to the \"Edit\" menu.  The commands in the submenu,  global-hi-lock-mode or in your .emacs file (global-hi-lock-mode 1).
258  which can be called interactively, are:  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:
261    
262  \\[highlight-regexp] REGEXP FACE  \\[highlight-regexp] REGEXP FACE
263    Highlight matches of pattern REGEXP in current buffer with FACE.    Highlight matches of pattern REGEXP in current buffer with FACE.
# Line 283  is found. A mode is excluded if it's in Line 296  is found. A mode is excluded if it's in
296    :lighter " H"    :lighter " H"
297    :global nil    :global nil
298    :keymap hi-lock-map    :keymap hi-lock-map
299    (if hi-lock-buffer-mode    (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:
311    
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.        ;; Turned on.
318        (progn        (progn
319          (unless font-lock-mode (font-lock-mode 1))          (unless font-lock-mode (font-lock-mode 1))
# Line 294  is found. A mode is excluded if it's in Line 324  is found. A mode is excluded if it's in
324      ;; Turned off.      ;; Turned off.
325      (when (or hi-lock-interactive-patterns      (when (or hi-lock-interactive-patterns
326                hi-lock-file-patterns)                hi-lock-file-patterns)
327        (when hi-lock-interactive-patterns        (when hi-lock-interactive-patterns
328          (font-lock-remove-keywords nil hi-lock-interactive-patterns)          (font-lock-remove-keywords nil hi-lock-interactive-patterns)
329          (setq hi-lock-interactive-patterns nil))          (setq hi-lock-interactive-patterns nil))
330        (when hi-lock-file-patterns        (when hi-lock-file-patterns
# Line 306  is found. A mode is excluded if it's in Line 336  is found. A mode is excluded if it's in
336      (remove-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook t)))      (remove-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook t)))
337    
338  ;;;###autoload  ;;;###autoload
339  (define-global-minor-mode hi-lock-mode  (define-global-minor-mode global-hi-lock-mode
340    hi-lock-buffer-mode turn-on-hi-lock-if-enabled    hi-lock-mode turn-on-hi-lock-if-enabled
341    :group 'hi-lock)    :group 'hi-lock)
342      
343  (defun turn-on-hi-lock-if-enabled ()  (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)    (unless (memq major-mode hi-lock-exclude-modes)
346      (hi-lock-buffer-mode 1)))      (hi-lock-mode 1)))
347    
348  ;;;###autoload  ;;;###autoload
349  (defalias 'highlight-lines-matching-regexp 'hi-lock-line-face-buffer)  (defalias 'highlight-lines-matching-regexp 'hi-lock-line-face-buffer)
# Line 332  list maintained for regexps, global hist Line 363  list maintained for regexps, global hist
363                             nil nil 'hi-lock-regexp-history))                             nil nil 'hi-lock-regexp-history))
364      (hi-lock-read-face-name)))      (hi-lock-read-face-name)))
365    (or (facep face) (setq face 'hi-yellow))    (or (facep face) (setq face 'hi-yellow))
366    (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))    (unless hi-lock-mode (hi-lock-mode 1))
367    (hi-lock-set-pattern    (hi-lock-set-pattern
368     ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ?     ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ?
369     ;; or a trailing $ in REGEXP will be interpreted correctly.     ;; or a trailing $ in REGEXP will be interpreted correctly.
# Line 357  list maintained for regexps, global hist Line 388  list maintained for regexps, global hist
388                             nil nil 'hi-lock-regexp-history))                             nil nil 'hi-lock-regexp-history))
389      (hi-lock-read-face-name)))      (hi-lock-read-face-name)))
390    (or (facep face) (setq face 'hi-yellow))    (or (facep face) (setq face 'hi-yellow))
391    (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))    (unless hi-lock-mode (hi-lock-mode 1))
392    (hi-lock-set-pattern regexp face))    (hi-lock-set-pattern regexp face))
393    
394  ;;;###autoload  ;;;###autoload
# Line 377  lower-case letters made case insensitive Line 408  lower-case letters made case insensitive
408                              nil nil 'hi-lock-regexp-history)))                              nil nil 'hi-lock-regexp-history)))
409      (hi-lock-read-face-name)))      (hi-lock-read-face-name)))
410    (or (facep face) (setq face 'hi-yellow))    (or (facep face) (setq face 'hi-yellow))
411    (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))    (unless hi-lock-mode (hi-lock-mode 1))
412    (hi-lock-set-pattern regexp face))    (hi-lock-set-pattern regexp face))
413    
414  ;;;###autoload  ;;;###autoload
# Line 535  not suitable." Line 566  not suitable."
566                  (setq all-patterns (append (read (current-buffer)) all-patterns))                  (setq all-patterns (append (read (current-buffer)) all-patterns))
567                (error (message "Invalid pattern list expression at %d"                (error (message "Invalid pattern list expression at %d"
568                                (line-number-at-pos)))))))                                (line-number-at-pos)))))))
569        (when hi-lock-buffer-mode (hi-lock-set-file-patterns all-patterns))        (when hi-lock-mode (hi-lock-set-file-patterns all-patterns))
570        (if (interactive-p)        (if (interactive-p)
571          (message "Hi-lock added %d patterns." (length all-patterns))))))          (message "Hi-lock added %d patterns." (length all-patterns))))))
572    
# Line 544  not suitable." Line 575  not suitable."
575    (if font-lock-mode    (if font-lock-mode
576        (progn (font-lock-add-keywords nil hi-lock-file-patterns)        (progn (font-lock-add-keywords nil hi-lock-file-patterns)
577               (font-lock-add-keywords nil hi-lock-interactive-patterns))               (font-lock-add-keywords nil hi-lock-interactive-patterns))
578      (hi-lock-buffer-mode -1)))      (hi-lock-mode -1)))
579    
580  (provide 'hi-lock)  (provide 'hi-lock)
581    

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26