Commit 2e4ad7e5 authored by Stefan Monnier's avatar Stefan Monnier

* 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.
parent ffe7ba8f
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
......
......@@ -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: "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment