]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/hi-lock.el (hi-lock-unface-buffer): If there's no matching regexp at
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Dec 2012 16:48:42 +0000 (11:48 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Dec 2012 16:48:42 +0000 (11:48 -0500)
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
lisp/hi-lock.el

index 18dc2e962ade2405b915087b9ab554fd1be2d5d2..d94a18820e221dddba0091832c2a57bcf994ed7a 100644 (file)
@@ -1,3 +1,11 @@
+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
index 02635eea41328cff19de127c0dbc49dfe38a50d4..de875c72593a280276090a587d2a325044b88ce3 100644 (file)
@@ -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: "