+2012-12-07 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * 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 <cyd@gnu.org>
* novice.el (disabled-command-function): Remove a spurious help
"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")
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]
(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)
(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)
(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: "