aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-12-07 11:48:42 -0500
committerStefan Monnier2012-12-07 11:48:42 -0500
commit2e4ad7e5a46fe2e2bf725194d7fafe8052093a22 (patch)
treee3a0a6641173dbc774e4384d89e5e884f1e20f10
parentffe7ba8f156fd3fb5afc78e50148b28b7584c622 (diff)
downloademacs-2e4ad7e5a46fe2e2bf725194d7fafe8052093a22.tar.gz
emacs-2e4ad7e5a46fe2e2bf725194d7fafe8052093a22.zip
* lisp/hi-lock.el (hi-lock-unface-buffer): If there's no matching regexp at
point, still provide some default. (hi-lock--regexps-at-point): Don't enforce a "hi-lock-" prefix on face names, since we don't use it right now. Actually return the list. (hi-lock-file-patterns, hi-lock-interactive-patterns): Use defvar-local.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/hi-lock.el21
2 files changed, 18 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 18dc2e962ad..d94a18820e2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-12-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * hi-lock.el (hi-lock-unface-buffer): If there's no matching regexp at
4 point, still provide some default.
5 (hi-lock--regexps-at-point): Don't enforce a "hi-lock-" prefix on face
6 names, since we don't use it right now. Actually return the list.
7 (hi-lock-file-patterns, hi-lock-interactive-patterns): Use defvar-local.
8
12012-12-07 Chong Yidong <cyd@gnu.org> 92012-12-07 Chong Yidong <cyd@gnu.org>
2 10
3 * novice.el (disabled-command-function): Remove a spurious help 11 * novice.el (disabled-command-function): Remove a spurious help
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 02635eea413..de875c72593 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -205,11 +205,13 @@ When non-nil, each hi-lock command will cycle through faces in
205 "Face for hi-lock mode." 205 "Face for hi-lock mode."
206 :group 'hi-lock-faces) 206 :group 'hi-lock-faces)
207 207
208(defvar hi-lock-file-patterns nil 208(defvar-local hi-lock-file-patterns nil
209 "Patterns found in file for hi-lock. Should not be changed.") 209 "Patterns found in file for hi-lock. Should not be changed.")
210(put 'hi-lock-file-patterns 'permanent-local t)
210 211
211(defvar hi-lock-interactive-patterns nil 212(defvar-local hi-lock-interactive-patterns nil
212 "Patterns provided to hi-lock by user. Should not be changed.") 213 "Patterns provided to hi-lock by user. Should not be changed.")
214(put 'hi-lock-interactive-patterns 'permanent-local t)
213 215
214(define-obsolete-variable-alias 'hi-lock-face-history 216(define-obsolete-variable-alias 'hi-lock-face-history
215 'hi-lock-face-defaults "23.1") 217 'hi-lock-face-defaults "23.1")
@@ -236,11 +238,6 @@ that older functionality. This variable avoids multiple reminders.")
236Assumption is made if `hi-lock-mode' used in the *scratch* buffer while 238Assumption is made if `hi-lock-mode' used in the *scratch* buffer while
237a library is being loaded.") 239a library is being loaded.")
238 240
239(make-variable-buffer-local 'hi-lock-interactive-patterns)
240(put 'hi-lock-interactive-patterns 'permanent-local t)
241(make-variable-buffer-local 'hi-lock-file-patterns)
242(put 'hi-lock-file-patterns 'permanent-local t)
243
244(defvar hi-lock-menu 241(defvar hi-lock-menu
245 (let ((map (make-sparse-keymap "Hi Lock"))) 242 (let ((map (make-sparse-keymap "Hi Lock")))
246 (define-key-after map [highlight-regexp] 243 (define-key-after map [highlight-regexp]
@@ -474,8 +471,8 @@ updated as you type."
474 (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp))) 471 (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp)))
475 (when regexp (push regexp regexps))) 472 (when regexp (push regexp regexps)))
476 ;; With font-locking on, check if the cursor is on an highlighted text. 473 ;; With font-locking on, check if the cursor is on an highlighted text.
477 ;; Checking for hi-lock face is a good heuristic. 474 ;; Checking for hi-lock face is a good heuristic. FIXME: use "hi-lock-".
478 (and (string-match "\\`hi-lock-" (face-name (face-at-point))) 475 (and (string-match "\\`hi-" (face-name (face-at-point)))
479 (let* ((hi-text 476 (let* ((hi-text
480 (buffer-substring-no-properties 477 (buffer-substring-no-properties
481 (previous-single-property-change (point) 'face) 478 (previous-single-property-change (point) 'face)
@@ -486,7 +483,8 @@ updated as you type."
486 (dolist (hi-lock-pattern hi-lock-interactive-patterns) 483 (dolist (hi-lock-pattern hi-lock-interactive-patterns)
487 (let ((regexp (car hi-lock-pattern))) 484 (let ((regexp (car hi-lock-pattern)))
488 (if (string-match regexp hi-text) 485 (if (string-match regexp hi-text)
489 (push regexp regexps)))))))) 486 (push regexp regexps))))))
487 regexps))
490 488
491(defvar-local hi-lock--last-face nil) 489(defvar-local hi-lock--last-face nil)
492 490
@@ -531,7 +529,8 @@ then remove all hi-lock highlighting."
531 (unless hi-lock-interactive-patterns 529 (unless hi-lock-interactive-patterns
532 (error "No highlighting to remove")) 530 (error "No highlighting to remove"))
533 ;; Infer the regexp to un-highlight based on cursor position. 531 ;; Infer the regexp to un-highlight based on cursor position.
534 (let* ((defaults (hi-lock--regexps-at-point))) 532 (let* ((defaults (or (hi-lock--regexps-at-point)
533 (mapcar #'car hi-lock-interactive-patterns))))
535 (list 534 (list
536 (completing-read (if (null defaults) 535 (completing-read (if (null defaults)
537 "Regexp to unhighlight: " 536 "Regexp to unhighlight: "