* help.el (help-for-help-internal): Don't purecopy the text (bug#4560).
[bpt/emacs.git] / lisp / isearch.el
index c65fb1a..bf2f073 100644 (file)
@@ -1,7 +1,8 @@
 ;;; isearch.el --- incremental search minor mode
 
-;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
+;;   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;;   Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
 ;; Maintainer: FSF
@@ -176,7 +177,7 @@ or to the end of the buffer for a backward search.")
   "Function to save a function restoring the mode-specific Isearch state
 to the search status stack.")
 
-(defvar isearch-filter-predicate 'isearch-filter-invisible
+(defvar isearch-filter-predicate 'isearch-filter-visible
   "Predicate that filters the search hits that would normally be available.
 Search hits that dissatisfy the predicate are skipped.  The function
 has two arguments: the positions of start and end of text matched by
@@ -321,7 +322,7 @@ A value of nil means highlight all matches."
   "Face for lazy highlighting of matches other than the current one."
   :group 'lazy-highlight
   :group 'basic-faces)
-(put 'isearch-lazy-highlight-face 'face-alias 'lazy-highlight)
+(define-obsolete-face-alias 'isearch-lazy-highlight-face 'lazy-highlight "22.1")
 (defvar lazy-highlight-face 'lazy-highlight)
 (define-obsolete-variable-alias 'isearch-lazy-highlight-face
                                 'lazy-highlight-face
@@ -346,7 +347,7 @@ A value of nil means highlight all matches."
 (eval-when-compile (require 'help-macro))
 
 (make-help-screen isearch-help-for-help-internal
-  "Type a help option: [bkm] or ?"
+  (purecopy "Type a help option: [bkm] or ?")
   "You have typed %THIS-KEY%, the help character.  Type a Help option:
 \(Type \\<help-map>\\[help-quit] to exit the Help command.)
 
@@ -543,9 +544,9 @@ Each set is a vector of the form:
 (defvar isearch-just-started nil)
 (defvar isearch-start-hscroll 0)       ; hscroll when starting the search.
 
-; case-fold-search while searching.
-;   either nil, t, or 'yes.  'yes means the same as t except that mixed
-;   case in the search string is ignored.
+;; case-fold-search while searching.
+;;   either nil, t, or 'yes.  'yes means the same as t except that mixed
+;;   case in the search string is ignored.
 (defvar isearch-case-fold-search nil)
 
 (defvar isearch-last-case-fold-search nil)
@@ -954,7 +955,7 @@ REGEXP if non-nil says use the regexp search ring."
 ;;   ;; First terminate isearch-mode.
 ;;   (isearch-done)
 ;;   (isearch-clean-overlays)
-;;   (handle-switch-frame (car (cdr last-command-char))))
+;;   (handle-switch-frame (car (cdr last-command-event))))
 
 \f
 ;; The search status structure and stack.
@@ -1522,8 +1523,7 @@ or it might return the position of the end of the line."
   (interactive "p")
   (if (eobp)
       (insert
-       (save-excursion
-         (set-buffer (cadr (buffer-list)))
+       (with-current-buffer (cadr (buffer-list))
          (buffer-substring-no-properties
           (point) (progn (forward-char arg) (point)))))
     (forward-char arg)))
@@ -1948,8 +1948,7 @@ Isearch mode."
                      (windowp window)
                      (or (> (minibuffer-depth) 0)
                          (not (window-minibuffer-p window))))
-                (save-excursion
-                  (set-buffer (window-buffer window))
+                (with-current-buffer (window-buffer window)
                   (isearch-done)
                   (isearch-clean-overlays))
               (isearch-done)
@@ -1984,7 +1983,7 @@ Isearch mode."
 (defun isearch-printing-char ()
   "Add this ordinary printing character to the search string and search."
   (interactive)
-  (let ((char last-command-char))
+  (let ((char last-command-event))
     (if (= char ?\S-\ )
        (setq char ?\s))
     (if current-input-method
@@ -2215,14 +2214,22 @@ update the match data, and return point."
   (let* ((func (isearch-search-fun))
          (pos1 (save-excursion (funcall func string bound noerror)))
          pos2)
-    (when (and (char-table-p translation-table-for-input)
-               (multibyte-string-p string)
-               ;; Minor optimization.
-               (string-match-p "[^[:ascii:]]" string))
+    (when (and
+          ;; Avoid "obsolete" warnings for translation-table-for-input.
+          (with-no-warnings
+            (char-table-p translation-table-for-input))
+          (multibyte-string-p string)
+          ;; Minor optimization.
+          (string-match-p "[^[:ascii:]]" string))
       (let ((translated
              (apply 'string
                     (mapcar (lambda (c)
-                              (or (aref translation-table-for-input c) c))
+                              (or
+                              ;; Avoid "obsolete" warnings for
+                              ;; translation-table-for-input.
+                              (with-no-warnings
+                                (aref translation-table-for-input c))
+                              c))
                             string)))
             match-data)
         (when translated
@@ -2254,7 +2261,7 @@ update the match data, and return point."
            (isearch-no-upper-case-p isearch-string isearch-regexp)))
   (condition-case lossage
       (let ((inhibit-point-motion-hooks
-            (and (eq isearch-filter-predicate 'isearch-filter-invisible)
+            (and (eq isearch-filter-predicate 'isearch-filter-visible)
                  search-invisible))
            (inhibit-quit nil)
            (case-fold-search isearch-case-fold-search)
@@ -2448,10 +2455,11 @@ update the match data, and return point."
                  nil)
              (setq isearch-hidden t)))))))
 
-(defun isearch-filter-invisible (beg end)
-  "Default predicate to filter out invisible text.
-It filters search hits to those that are visible (at least partially),
-unless invisible text too can be searched."
+(defun isearch-filter-visible (beg end)
+  "Test whether the current search hit is visible at least partially.
+Return non-nil if the text from BEG to END is visible to Isearch as
+determined by `isearch-range-invisible' unless invisible text can be
+searched too when `search-invisible' is t."
   (or (eq search-invisible t)
       (not (isearch-range-invisible beg end))))
 
@@ -2488,8 +2496,8 @@ since they have special meaning in a regexp."
 
 (defun isearch-text-char-description (c)
   (cond
-   ((< c ?\s) (format "^%c" (+ c 64)))
-   ((= c ?\^?) "^?")
+   ((< c ?\s) (propertize (format "^%c" (+ c 64)) 'face 'escape-glyph))
+   ((= c ?\^?) (propertize "^?" 'face 'escape-glyph))
    (t (char-to-string c))))
 
 ;; General function to unread characters or events.