diff options
| author | Chong Yidong | 2012-08-14 14:52:59 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-14 14:52:59 +0800 |
| commit | a9f6f311c7ef2c36bb020d808b036f6f40e58237 (patch) | |
| tree | 86d45e59e274e406ec7ef003fcf874bf83e0ae35 | |
| parent | b4599732c30ebf9eaa49986d70d64800e2b93225 (diff) | |
| download | emacs-a9f6f311c7ef2c36bb020d808b036f6f40e58237.tar.gz emacs-a9f6f311c7ef2c36bb020d808b036f6f40e58237.zip | |
Fix highlight-regexp's use of Font Lock mode.
* hi-lock.el (hi-lock-mode): Do not unilaterally enable font lock.
(hi-lock-set-pattern): When deciding whether to use font lock or
overlays, look at font-lock-mode instead of font-lock-fontified.
(hi-lock-mode, hi-lock-line-face-buffer, hi-lock-unface-buffer)
(hi-lock-face-buffer, hi-lock-face-phrase-buffer): Doc fix.
Fixes: debbugs:12168
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/hi-lock.el | 72 |
2 files changed, 49 insertions, 32 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7ee7ee9d27f..285e69d9db1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-08-14 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * hi-lock.el (hi-lock-mode): Do not unilaterally enable font lock. | ||
| 4 | (hi-lock-set-pattern): When deciding whether to use font lock or | ||
| 5 | overlays, look at font-lock-mode instead of font-lock-fontified | ||
| 6 | (Bug#12168). | ||
| 7 | (hi-lock-mode, hi-lock-line-face-buffer, hi-lock-unface-buffer) | ||
| 8 | (hi-lock-face-buffer, hi-lock-face-phrase-buffer): Doc fix. | ||
| 9 | |||
| 1 | 2012-08-14 Daiki Ueno <ueno@unixuser.org> | 10 | 2012-08-14 Daiki Ueno <ueno@unixuser.org> |
| 2 | 11 | ||
| 3 | * subr.el (internal--after-with-selected-window): Fix typo | 12 | * subr.el (internal--after-with-selected-window): Fix typo |
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 2c2d08e19cc..644024a4b86 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el | |||
| @@ -287,12 +287,19 @@ With a prefix argument ARG, enable Hi Lock mode if ARG is | |||
| 287 | positive, and disable it otherwise. If called from Lisp, enable | 287 | positive, and disable it otherwise. If called from Lisp, enable |
| 288 | the mode if ARG is omitted or nil. | 288 | the mode if ARG is omitted or nil. |
| 289 | 289 | ||
| 290 | Issuing one the highlighting commands listed below will | 290 | Hi Lock mode is automatically enabled when you invoke any of the |
| 291 | automatically enable Hi Lock mode. To enable Hi Lock mode in all | 291 | highlighting commands listed below, such as \\[highlight-regexp]. |
| 292 | buffers, use `global-hi-lock-mode' or add (global-hi-lock-mode 1) | 292 | To enable Hi Lock mode in all buffers, use `global-hi-lock-mode' |
| 293 | to your init file. When Hi Lock mode is enabled, a \"Regexp | 293 | or add (global-hi-lock-mode 1) to your init file. |
| 294 | Highlighting\" submenu is added to the \"Edit\" menu. The | 294 | |
| 295 | commands in the submenu, which can be called interactively, are: | 295 | In buffers where Font Lock mode is enabled, patterns are |
| 296 | highlighted using font lock. In buffers where Font Lock mode is | ||
| 297 | disabled, patterns are applied using overlays; in this case, the | ||
| 298 | highlighting will not be updated as you type. | ||
| 299 | |||
| 300 | When Hi Lock mode is enabled, a \"Regexp Highlighting\" submenu | ||
| 301 | is added to the \"Edit\" menu. The commands in the submenu, | ||
| 302 | which can be called interactively, are: | ||
| 296 | 303 | ||
| 297 | \\[highlight-regexp] REGEXP FACE | 304 | \\[highlight-regexp] REGEXP FACE |
| 298 | Highlight matches of pattern REGEXP in current buffer with FACE. | 305 | Highlight matches of pattern REGEXP in current buffer with FACE. |
| @@ -326,12 +333,12 @@ When hi-lock is started and if the mode is not excluded or patterns | |||
| 326 | rejected, the beginning of the buffer is searched for lines of the | 333 | rejected, the beginning of the buffer is searched for lines of the |
| 327 | form: | 334 | form: |
| 328 | Hi-lock: FOO | 335 | Hi-lock: FOO |
| 329 | where FOO is a list of patterns. These are added to the font lock | 336 | |
| 330 | keywords already present. The patterns must start before position | 337 | where FOO is a list of patterns. The patterns must start before |
| 331 | \(number of characters into buffer) `hi-lock-file-patterns-range'. | 338 | position \(number of characters into buffer) |
| 332 | Patterns will be read until | 339 | `hi-lock-file-patterns-range'. Patterns will be read until |
| 333 | Hi-lock: end | 340 | Hi-lock: end is found. A mode is excluded if it's in the list |
| 334 | is found. A mode is excluded if it's in the list `hi-lock-exclude-modes'." | 341 | `hi-lock-exclude-modes'." |
| 335 | :group 'hi-lock | 342 | :group 'hi-lock |
| 336 | :lighter (:eval (if (or hi-lock-interactive-patterns | 343 | :lighter (:eval (if (or hi-lock-interactive-patterns |
| 337 | hi-lock-file-patterns) | 344 | hi-lock-file-patterns) |
| @@ -358,7 +365,6 @@ versions before 22 use the following in your .emacs file: | |||
| 358 | (if hi-lock-mode | 365 | (if hi-lock-mode |
| 359 | ;; Turned on. | 366 | ;; Turned on. |
| 360 | (progn | 367 | (progn |
| 361 | (unless font-lock-mode (font-lock-mode 1)) | ||
| 362 | (define-key-after menu-bar-edit-menu [hi-lock] | 368 | (define-key-after menu-bar-edit-menu [hi-lock] |
| 363 | (cons "Regexp Highlighting" hi-lock-menu)) | 369 | (cons "Regexp Highlighting" hi-lock-menu)) |
| 364 | (hi-lock-find-patterns) | 370 | (hi-lock-find-patterns) |
| @@ -392,12 +398,13 @@ versions before 22 use the following in your .emacs file: | |||
| 392 | ;;;###autoload | 398 | ;;;###autoload |
| 393 | (defun hi-lock-line-face-buffer (regexp &optional face) | 399 | (defun hi-lock-line-face-buffer (regexp &optional face) |
| 394 | "Set face of all lines containing a match of REGEXP to FACE. | 400 | "Set face of all lines containing a match of REGEXP to FACE. |
| 401 | Interactively, prompt for REGEXP then FACE, using a buffer-local | ||
| 402 | history list for REGEXP and a global history list for FACE. | ||
| 395 | 403 | ||
| 396 | Interactively, prompt for REGEXP then FACE. Buffer-local history | 404 | If Font Lock mode is enabled in the buffer, it is used to |
| 397 | list maintained for regexps, global history maintained for faces. | 405 | highlight REGEXP. If Font Lock mode is disabled, overlays are |
| 398 | \\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items, | 406 | used for highlighting; in this case, the highlighting will not be |
| 399 | and \\[next-history-element] to retrieve default values. | 407 | updated as you type." |
| 400 | \(See info node `Minibuffer History'.)" | ||
| 401 | (interactive | 408 | (interactive |
| 402 | (list | 409 | (list |
| 403 | (hi-lock-regexp-okay | 410 | (hi-lock-regexp-okay |
| @@ -416,12 +423,13 @@ and \\[next-history-element] to retrieve default values. | |||
| 416 | ;;;###autoload | 423 | ;;;###autoload |
| 417 | (defun hi-lock-face-buffer (regexp &optional face) | 424 | (defun hi-lock-face-buffer (regexp &optional face) |
| 418 | "Set face of each match of REGEXP to FACE. | 425 | "Set face of each match of REGEXP to FACE. |
| 426 | Interactively, prompt for REGEXP then FACE, using a buffer-local | ||
| 427 | history list for REGEXP and a global history list for FACE. | ||
| 419 | 428 | ||
| 420 | Interactively, prompt for REGEXP then FACE. Buffer-local history | 429 | If Font Lock mode is enabled in the buffer, it is used to |
| 421 | list maintained for regexps, global history maintained for faces. | 430 | highlight REGEXP. If Font Lock mode is disabled, overlays are |
| 422 | \\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items, | 431 | used for highlighting; in this case, the highlighting will not be |
| 423 | and \\[next-history-element] to retrieve default values. | 432 | updated as you type." |
| 424 | \(See info node `Minibuffer History'.)" | ||
| 425 | (interactive | 433 | (interactive |
| 426 | (list | 434 | (list |
| 427 | (hi-lock-regexp-okay | 435 | (hi-lock-regexp-okay |
| @@ -436,9 +444,13 @@ and \\[next-history-element] to retrieve default values. | |||
| 436 | ;;;###autoload | 444 | ;;;###autoload |
| 437 | (defun hi-lock-face-phrase-buffer (regexp &optional face) | 445 | (defun hi-lock-face-phrase-buffer (regexp &optional face) |
| 438 | "Set face of each match of phrase REGEXP to FACE. | 446 | "Set face of each match of phrase REGEXP to FACE. |
| 439 | |||
| 440 | Whitespace in REGEXP converted to arbitrary whitespace and initial | 447 | Whitespace in REGEXP converted to arbitrary whitespace and initial |
| 441 | lower-case letters made case insensitive." | 448 | lower-case letters made case insensitive. |
| 449 | |||
| 450 | If Font Lock mode is enabled in the buffer, it is used to | ||
| 451 | highlight REGEXP. If Font Lock mode is disabled, overlays are | ||
| 452 | used for highlighting; in this case, the highlighting will not be | ||
| 453 | updated as you type." | ||
| 442 | (interactive | 454 | (interactive |
| 443 | (list | 455 | (list |
| 444 | (hi-lock-regexp-okay | 456 | (hi-lock-regexp-okay |
| @@ -456,12 +468,8 @@ lower-case letters made case insensitive." | |||
| 456 | ;;;###autoload | 468 | ;;;###autoload |
| 457 | (defun hi-lock-unface-buffer (regexp) | 469 | (defun hi-lock-unface-buffer (regexp) |
| 458 | "Remove highlighting of each match to REGEXP set by hi-lock. | 470 | "Remove highlighting of each match to REGEXP set by hi-lock. |
| 459 | 471 | Interactively, prompt for REGEXP, accepting only regexps | |
| 460 | Interactively, prompt for REGEXP. Buffer-local history of inserted | 472 | previously inserted by hi-lock interactive functions." |
| 461 | regexp's maintained. Will accept only regexps inserted by hi-lock | ||
| 462 | interactive functions. \(See `hi-lock-interactive-patterns'.\) | ||
| 463 | \\<minibuffer-local-must-match-map>Use \\[minibuffer-complete] to complete a partially typed regexp. | ||
| 464 | \(See info node `Minibuffer History'.\)" | ||
| 465 | (interactive | 473 | (interactive |
| 466 | (if (and (display-popup-menus-p) | 474 | (if (and (display-popup-menus-p) |
| 467 | (listp last-nonmenu-event) | 475 | (listp last-nonmenu-event) |
| @@ -573,7 +581,7 @@ not suitable." | |||
| 573 | (let ((pattern (list regexp (list 0 (list 'quote face) t)))) | 581 | (let ((pattern (list regexp (list 0 (list 'quote face) t)))) |
| 574 | (unless (member pattern hi-lock-interactive-patterns) | 582 | (unless (member pattern hi-lock-interactive-patterns) |
| 575 | (push pattern hi-lock-interactive-patterns) | 583 | (push pattern hi-lock-interactive-patterns) |
| 576 | (if font-lock-fontified | 584 | (if font-lock-mode |
| 577 | (progn | 585 | (progn |
| 578 | (font-lock-add-keywords nil (list pattern) t) | 586 | (font-lock-add-keywords nil (list pattern) t) |
| 579 | (font-lock-fontify-buffer)) | 587 | (font-lock-fontify-buffer)) |