File: hi-lock.el.html
With the hi-lock commands text matching interactively entered
regexp's can be highlighted. For example, M-x highlight-regexp
RET clearly RET RET will highlight all occurrences of clearly
using a yellow background face. New occurrences of clearly will
be highlighted as they are typed. M-x unhighlight-regexp RET
will remove the highlighting. Any existing face can be used for
highlighting and a set of appropriate faces is provided. The
regexps can be written into the current buffer in a form that will
be recognized the next time the corresponding file is read (when
file patterns is turned on).
Applications:
In program source code highlight a variable to quickly see all
places it is modified or referenced:
M-x highlight-regexp RET ground_contact_switches_closed RET RET
In a shell or other buffer that is showing lots of program
output, highlight the parts of the output you're interested in:
M-x highlight-regexp RET Total execution time [0-9]+ RET hi-blue-b RET
In buffers displaying tables, highlight the lines you're interested in:
M-x highlight-lines-matching-regexp RET January 2000 RET hi-black-b RET
When writing text, highlight personal cliches. This can be
amusing.
M-x highlight-phrase RET as can be seen RET RET
Setup:
Put the following code in your init file. This turns on
hi-lock mode and adds a "Regexp Highlighting" entry
to the edit menu.
(global-hi-lock-mode 1)
To enable the use of patterns found in files (presumably placed
there by hi-lock) include the following in your init file:
(setq hi-lock-file-patterns-policy 'ask)
If you get tired of being asked each time a file is loaded replace
ask with a function that returns t if patterns should be read.
You might also want to bind the hi-lock commands to more
finger-friendly sequences:
(keymap-set hi-lock-map "C-z C-h" 'highlight-lines-matching-regexp)
(keymap-set hi-lock-map "C-z i" 'hi-lock-find-patterns)
(keymap-set hi-lock-map "C-z h" 'highlight-regexp)
(keymap-set hi-lock-map "C-z p" 'highlight-phrase)
(keymap-set hi-lock-map "C-z r" 'unhighlight-regexp)
(keymap-set hi-lock-map "C-z b" 'hi-lock-write-interactive-patterns))
See the documentation for hi-lock-mode C-h f hi-lock-mode for
additional instructions.
Sample file patterns:
; Hi-lock: (("^;;; .*" (0 (quote hi-black-hb) t)))
; Hi-lock: ( ("make-variable-buffer-\\\\(local\\\\)" (0 font-lock-keyword-face)(1 'italic append)))))
; Hi-lock: end
Defined variables (19)
global-hi-lock-mode | Non-nil if Global Hi-Lock mode is enabled. |
global-hi-lock-mode-hook | Hook run after entering or leaving ‘global-hi-lock-mode’. |
hi-lock--hashcons-hash | Hash table used to hash cons regexps. |
hi-lock--unused-faces | List of faces that is not used and is available for highlighting new text. |
hi-lock-auto-select-face | When nil, highlighting commands prompt for the face to use. |
hi-lock-exclude-modes | List of major modes in which hi-lock will not run. |
hi-lock-face-defaults | Default face names for hi-lock interactive functions. |
hi-lock-file-patterns | Patterns found in file for hi-lock. Should not be changed. |
hi-lock-file-patterns-policy | Specify when hi-lock should use patterns found in file. |
hi-lock-file-patterns-prefix | String used to identify hi-lock patterns at the start of files. |
hi-lock-file-patterns-range | Limit of search in a buffer for hi-lock patterns. |
hi-lock-highlight-range | Size of area highlighted by hi-lock when font-lock not active. |
hi-lock-interactive-lighters | Human-readable lighters for ‘hi-lock-interactive-patterns’. |
hi-lock-interactive-patterns | Patterns provided to hi-lock by user. Should not be changed. |
hi-lock-map | Keymap for ‘hi-lock-mode’. |
hi-lock-menu | Menu for hi-lock mode. |
hi-lock-mode | Non-nil if Hi-Lock mode is enabled. |
hi-lock-mode-hook | Hook run after entering or leaving ‘hi-lock-mode’. |
hi-lock-use-overlays | Whether to always use overlays instead of font-lock rules. |
Defined functions (28)
global-hi-lock-mode | (&optional ARG) |
hi-lock--hashcons | (STRING) |
hi-lock-context-menu | (MENU CLICK) |
hi-lock-face-buffer | (REGEXP &optional FACE SUBEXP LIGHTER) |
hi-lock-face-phrase-buffer | (REGEXP &optional FACE) |
hi-lock-face-symbol-at-mouse | (EVENT) |
hi-lock-face-symbol-at-point | () |
hi-lock-find-patterns | () |
hi-lock-font-lock-hook | () |
hi-lock-keyword->face | (KEYWORD) |
hi-lock-line-face-buffer | (REGEXP &optional FACE) |
hi-lock-menu | (ARG1) |
hi-lock-mode | (&optional ARG) |
hi-lock-read-face-name | () |
hi-lock-read-regexp | (PROMPT) |
hi-lock-regexp-okay | (REGEXP) |
hi-lock-revert-buffer-rehighlight | () |
hi-lock-set-file-patterns | (PATTERNS) |
hi-lock-set-pattern | (REGEXP FACE &optional SUBEXP LIGHTER CASE-FOLD SPACES-REGEXP) |
hi-lock-unface-buffer | (REGEXP) |
hi-lock-unload-function | () |
hi-lock-write-interactive-patterns | () |
highlight-lines-matching-regexp | (REGEXP &optional FACE) |
highlight-phrase | (REGEXP &optional FACE) |
highlight-regexp | (REGEXP &optional FACE SUBEXP LIGHTER) |
highlight-symbol-at-mouse | (EVENT) |
highlight-symbol-at-point | () |
unhighlight-regexp | (REGEXP) |
Defined faces (11)
hi-aquamarine | Face for hi-lock mode. |
hi-black-b | Face for hi-lock mode. |
hi-black-hb | Face for hi-lock mode. |
hi-blue | Face for hi-lock mode. |
hi-blue-b | Face for hi-lock mode. |
hi-green | Face for hi-lock mode. |
hi-green-b | Face for hi-lock mode. |
hi-pink | Face for hi-lock mode. |
hi-red-b | Face for hi-lock mode. |
hi-salmon | Face for hi-lock mode. |
hi-yellow | Default face for hi-lock mode. |