aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-08-14 14:52:59 +0800
committerChong Yidong2012-08-14 14:52:59 +0800
commita9f6f311c7ef2c36bb020d808b036f6f40e58237 (patch)
tree86d45e59e274e406ec7ef003fcf874bf83e0ae35
parentb4599732c30ebf9eaa49986d70d64800e2b93225 (diff)
downloademacs-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/ChangeLog9
-rw-r--r--lisp/hi-lock.el72
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 @@
12012-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
12012-08-14 Daiki Ueno <ueno@unixuser.org> 102012-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
287positive, and disable it otherwise. If called from Lisp, enable 287positive, and disable it otherwise. If called from Lisp, enable
288the mode if ARG is omitted or nil. 288the mode if ARG is omitted or nil.
289 289
290Issuing one the highlighting commands listed below will 290Hi Lock mode is automatically enabled when you invoke any of the
291automatically enable Hi Lock mode. To enable Hi Lock mode in all 291highlighting commands listed below, such as \\[highlight-regexp].
292buffers, use `global-hi-lock-mode' or add (global-hi-lock-mode 1) 292To enable Hi Lock mode in all buffers, use `global-hi-lock-mode'
293to your init file. When Hi Lock mode is enabled, a \"Regexp 293or add (global-hi-lock-mode 1) to your init file.
294Highlighting\" submenu is added to the \"Edit\" menu. The 294
295commands in the submenu, which can be called interactively, are: 295In buffers where Font Lock mode is enabled, patterns are
296highlighted using font lock. In buffers where Font Lock mode is
297disabled, patterns are applied using overlays; in this case, the
298highlighting will not be updated as you type.
299
300When Hi Lock mode is enabled, a \"Regexp Highlighting\" submenu
301is added to the \"Edit\" menu. The commands in the submenu,
302which 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
326rejected, the beginning of the buffer is searched for lines of the 333rejected, the beginning of the buffer is searched for lines of the
327form: 334form:
328 Hi-lock: FOO 335 Hi-lock: FOO
329where FOO is a list of patterns. These are added to the font lock 336
330keywords already present. The patterns must start before position 337where FOO is a list of patterns. The patterns must start before
331\(number of characters into buffer) `hi-lock-file-patterns-range'. 338position \(number of characters into buffer)
332Patterns will be read until 339`hi-lock-file-patterns-range'. Patterns will be read until
333 Hi-lock: end 340Hi-lock: end is found. A mode is excluded if it's in the list
334is 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.
401Interactively, prompt for REGEXP then FACE, using a buffer-local
402history list for REGEXP and a global history list for FACE.
395 403
396Interactively, prompt for REGEXP then FACE. Buffer-local history 404If Font Lock mode is enabled in the buffer, it is used to
397list maintained for regexps, global history maintained for faces. 405highlight REGEXP. If Font Lock mode is disabled, overlays are
398\\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items, 406used for highlighting; in this case, the highlighting will not be
399and \\[next-history-element] to retrieve default values. 407updated 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.
426Interactively, prompt for REGEXP then FACE, using a buffer-local
427history list for REGEXP and a global history list for FACE.
419 428
420Interactively, prompt for REGEXP then FACE. Buffer-local history 429If Font Lock mode is enabled in the buffer, it is used to
421list maintained for regexps, global history maintained for faces. 430highlight REGEXP. If Font Lock mode is disabled, overlays are
422\\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items, 431used for highlighting; in this case, the highlighting will not be
423and \\[next-history-element] to retrieve default values. 432updated 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
440Whitespace in REGEXP converted to arbitrary whitespace and initial 447Whitespace in REGEXP converted to arbitrary whitespace and initial
441lower-case letters made case insensitive." 448lower-case letters made case insensitive.
449
450If Font Lock mode is enabled in the buffer, it is used to
451highlight REGEXP. If Font Lock mode is disabled, overlays are
452used for highlighting; in this case, the highlighting will not be
453updated 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 471Interactively, prompt for REGEXP, accepting only regexps
460Interactively, prompt for REGEXP. Buffer-local history of inserted 472previously inserted by hi-lock interactive functions."
461regexp's maintained. Will accept only regexps inserted by hi-lock
462interactive 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))