;;; 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
:type 'boolean
:group 'isearch)
-(defcustom search-whitespace-regexp "\\s-+"
+(defcustom search-whitespace-regexp (purecopy "\\s-+")
"If non-nil, regular expression to match a sequence of whitespace chars.
This applies to regular expression incremental search.
When you put a space or spaces in the incremental regexp, it stands for
"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
"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
(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.)
(define-key map "\M-\t" 'isearch-complete-edit)
(define-key map "\C-s" 'isearch-forward-exit-minibuffer)
(define-key map "\C-r" 'isearch-reverse-exit-minibuffer)
- (define-key map "\C-w" 'isearch-edit-string-set-word)
(define-key map "\C-f" 'isearch-yank-char-in-minibuffer)
(define-key map [right] 'isearch-yank-char-in-minibuffer)
map)
(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)
;; ;; 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.
(isearch-abort) ;; outside of let to restore outside global values
)))
-;; Obsolete usage of `C-s M-e C-w'. Remove after 23.1.
-(defvar isearch-new-word)
-(defun isearch-edit-string-set-word ()
- "Do word search after exiting `isearch-edit-string'."
- (interactive)
- (message "This feature is obsolete since 23.1; use `M-s w' instead.")
- (setq isearch-word t isearch-new-word t))
-
-
(defun isearch-nonincremental-exit-minibuffer ()
(interactive)
(setq isearch-nonincremental t)
(interactive
(list
(cond
- (isearch-word (concat "\\b" (regexp-quote isearch-string) "\\b"))
+ (isearch-word (concat "\\b" (replace-regexp-in-string
+ "\\W+" "\\W+"
+ (replace-regexp-in-string
+ "^\\W+\\|\\W+$" "" isearch-string)
+ nil t)
+ "\\b"))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))
(if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
(search-upper-case nil))
(occur regexp nlines)))
-(declare-function hi-lock-regexp-okay "hi-lock" (regexp))
(declare-function hi-lock-read-face-name "hi-lock" ())
(defun isearch-highlight-regexp ()
(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)))
(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)
(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
(funcall isearch-search-fun-function)
(cond
(isearch-word
- ;; Use lax versions to not fail at the end of the word while the user
- ;; adds and removes characters in the search string
- (if (not (eq (length isearch-string)
- (length (isearch-string-state (car isearch-cmds)))))
- (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax)
- (if isearch-forward 'word-search-forward 'word-search-backward)))
+ ;; Use lax versions to not fail at the end of the word while
+ ;; the user adds and removes characters in the search string
+ ;; (or when using nonincremental word isearch)
+ (if (or isearch-nonincremental
+ (eq (length isearch-string)
+ (length (isearch-string-state (car isearch-cmds)))))
+ (if isearch-forward 'word-search-forward 'word-search-backward)
+ (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax)))
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(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
(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)
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))))
(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.