From 2e4ad7e5a46fe2e2bf725194d7fafe8052093a22 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 7 Dec 2012 11:48:42 -0500 Subject: [PATCH] * 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. --- lisp/ChangeLog | 8 ++++++++ lisp/hi-lock.el | 21 ++++++++++----------- 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 @@ +2012-12-07 Stefan Monnier + + * 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. + 2012-12-07 Chong Yidong * 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 "Face for hi-lock mode." :group 'hi-lock-faces) -(defvar hi-lock-file-patterns nil +(defvar-local hi-lock-file-patterns nil "Patterns found in file for hi-lock. Should not be changed.") +(put 'hi-lock-file-patterns 'permanent-local t) -(defvar hi-lock-interactive-patterns nil +(defvar-local hi-lock-interactive-patterns nil "Patterns provided to hi-lock by user. Should not be changed.") +(put 'hi-lock-interactive-patterns 'permanent-local t) (define-obsolete-variable-alias 'hi-lock-face-history 'hi-lock-face-defaults "23.1") @@ -236,11 +238,6 @@ that older functionality. This variable avoids multiple reminders.") Assumption is made if `hi-lock-mode' used in the *scratch* buffer while a library is being loaded.") -(make-variable-buffer-local 'hi-lock-interactive-patterns) -(put 'hi-lock-interactive-patterns 'permanent-local t) -(make-variable-buffer-local 'hi-lock-file-patterns) -(put 'hi-lock-file-patterns 'permanent-local t) - (defvar hi-lock-menu (let ((map (make-sparse-keymap "Hi Lock"))) (define-key-after map [highlight-regexp] @@ -474,8 +471,8 @@ updated as you type." (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp))) (when regexp (push regexp regexps))) ;; With font-locking on, check if the cursor is on an highlighted text. - ;; Checking for hi-lock face is a good heuristic. - (and (string-match "\\`hi-lock-" (face-name (face-at-point))) + ;; Checking for hi-lock face is a good heuristic. FIXME: use "hi-lock-". + (and (string-match "\\`hi-" (face-name (face-at-point))) (let* ((hi-text (buffer-substring-no-properties (previous-single-property-change (point) 'face) @@ -486,7 +483,8 @@ updated as you type." (dolist (hi-lock-pattern hi-lock-interactive-patterns) (let ((regexp (car hi-lock-pattern))) (if (string-match regexp hi-text) - (push regexp regexps)))))))) + (push regexp regexps)))))) + regexps)) (defvar-local hi-lock--last-face nil) @@ -531,7 +529,8 @@ then remove all hi-lock highlighting." (unless hi-lock-interactive-patterns (error "No highlighting to remove")) ;; Infer the regexp to un-highlight based on cursor position. - (let* ((defaults (hi-lock--regexps-at-point))) + (let* ((defaults (or (hi-lock--regexps-at-point) + (mapcar #'car hi-lock-interactive-patterns)))) (list (completing-read (if (null defaults) "Regexp to unhighlight: " -- 2.39.5