Thanks to Christopher Allan Webber, fix typo.
[bpt/emacs.git] / lisp / hi-lock.el
index 86e62ee..99eeb69 100644 (file)
@@ -23,7 +23,7 @@
 ;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
-;; 
+;;
 ;;  With the hi-lock commands text matching interactively entered
 ;;  regexp's can be highlighted.  For example, `M-x highlight-regexp
 ;;  RET clearly RET RET' will highlight all occurrences of `clearly'
@@ -58,7 +58,7 @@
 ;;    to the edit menu.
 ;;
 ;;    (hi-lock-mode 1)
-;;  
+;;
 ;;    You might also want to bind the hi-lock commands to more
 ;;    finger-friendly sequences:
 
@@ -83,7 +83,6 @@
 (eval-and-compile
   (require 'font-lock))
 
-;;;###autoload
 (defgroup hi-lock-interactive-text-highlighting nil
   "Interactively add and remove font-lock patterns for highlighting text."
   :group 'faces)
@@ -260,7 +259,7 @@ which can be called interactively, are:
   Highlight matches of phrase PHRASE in current buffer with FACE.
   (PHRASE can be any REGEXP, but spaces will be replaced by matches
   to whitespace and initial lower-case letters will become case insensitive.)
+
 \\[highlight-lines-matching-regexp] REGEXP FACE
   Highlight lines containing matches of REGEXP in current buffer with FACE.
 
@@ -392,7 +391,7 @@ interactive functions.  \(See `hi-lock-interactive-patterns'.\)
 \\<minibuffer-local-must-match-map>Use \\[minibuffer-complete] to complete a partially typed regexp.
 \(See info node `Minibuffer History'.\)"
   (interactive
-   (if (vectorp (this-command-keys))
+   (if (and (display-popup-menus-p) (vectorp (this-command-keys)))
        (catch 'snafu
         (or
          (x-popup-menu
@@ -537,21 +536,22 @@ Optional argument END is maximum excursion."
     (let ((all-patterns nil)
           (target-regexp (concat "\\<" hi-lock-file-patterns-prefix ":")))
       (save-excursion
-        (widen)
-        (goto-char (point-min))
-        (re-search-forward target-regexp
-                           (+ (point) hi-lock-file-patterns-range) t)
-        (beginning-of-line)
-        (while (and (re-search-forward target-regexp (+ (point) 100) t)
-                   (not (looking-at "\\s-*end")))
-          (let ((patterns
-                (condition-case nil
-                    (read (current-buffer))
-                  (error  (message
-                           (format "Could not read expression at %d"
-                                   (hi-lock-current-line))) nil))))
-            (if patterns
-                (setq all-patterns (append patterns all-patterns))))))
+       (save-restriction
+         (widen)
+         (goto-char (point-min))
+         (re-search-forward target-regexp
+                            (+ (point) hi-lock-file-patterns-range) t)
+         (beginning-of-line)
+         (while (and (re-search-forward target-regexp (+ (point) 100) t)
+                     (not (looking-at "\\s-*end")))
+           (let ((patterns
+                  (condition-case nil
+                      (read (current-buffer))
+                    (error  (message
+                             (format "Could not read expression at %d"
+                                     (hi-lock-current-line))) nil))))
+             (if patterns
+                 (setq all-patterns (append patterns all-patterns)))))))
       (when hi-lock-mode (hi-lock-set-file-patterns all-patterns))
       (if (interactive-p)
         (message (format "Hi-lock added %d patterns." (length all-patterns)))))))
@@ -564,4 +564,5 @@ Optional argument END is maximum excursion."
 
 (provide 'hi-lock)
 
+;;; arch-tag: d2e8fd07-4cc9-4c6f-a200-1e729bc54066
 ;;; hi-lock.el ends here