;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
;; Maintainer: FSF
;; Keywords: matching
+;; Package: emacs
;; This file is part of GNU Emacs.
(defvar isearch-mode-hook nil
"Function(s) to call after starting up an incremental search.")
+(defvar isearch-update-post-hook nil
+ "Function(s) to call after isearch has found matches in the buffer.")
+
(defvar isearch-mode-end-hook nil
"Function(s) to call after terminating an incremental search.
When these functions are called, `isearch-mode-end-hook-quit'
"Face for highlighting Isearch matches."
:group 'isearch
:group 'basic-faces)
-(defvar isearch 'isearch)
+(defvar isearch-face 'isearch)
(defface isearch-fail
'((((class color) (min-colors 88) (background light))
(define-key map "\M-\C-y" 'isearch-yank-char)
(define-key map "\C-y" 'isearch-yank-line)
- (define-key map "\C-h" isearch-help-map)
+ (define-key map (char-to-string help-char) isearch-help-map)
+ (define-key map [help] isearch-help-map)
+ (define-key map [f1] isearch-help-map)
(define-key map "\M-n" 'isearch-ring-advance)
(define-key map "\M-p" 'isearch-ring-retreat)
(isearch-lazy-highlight-new-loop))
;; We must prevent the point moving to the end of composition when a
;; part of the composition has just been searched.
- (setq disable-point-adjustment t))
+ (setq disable-point-adjustment t)
+ (run-hooks 'isearch-update-post-hook))
(defun isearch-done (&optional nopush edit)
"Exit Isearch mode.
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(if isearch-regexp (setq string (regexp-quote string)))
- (setq isearch-string (concat isearch-string string)
- isearch-message
- (concat isearch-message
- (mapconcat 'isearch-text-char-description
- string ""))
- ;; Don't move cursor in reverse search.
- isearch-yank-flag t)
- (isearch-search-and-update))
+ ;; Don't move cursor in reverse search.
+ (setq isearch-yank-flag t)
+ (isearch-process-search-string
+ string (mapconcat 'isearch-text-char-description string "")))
(defun isearch-yank-kill ()
"Pull string from kill ring into search string."
(interactive "p")
(isearch-yank-internal (lambda () (forward-char arg) (point))))
+(declare-function subword-forward "subword" (&optional arg))
(defun isearch-yank-word-or-char ()
- "Pull next character or word from buffer into search string."
+ "Pull next character, subword or word from buffer into search string.
+Subword is used when `subword-mode' is activated. "
(interactive)
(isearch-yank-internal
(lambda ()
(if (or (= (char-syntax (or (char-after) 0)) ?w)
(= (char-syntax (or (char-after (1+ (point))) 0)) ?w))
- (forward-word 1)
+ (if (and (boundp 'subword-mode) subword-mode)
+ (subword-forward 1)
+ (forward-word 1))
(forward-char 1)) (point))))
(defun isearch-yank-word ()
;; attempts this, we scroll the text back again.
;;
;; We implement this feature with a property called `isearch-scroll'.
-;; If a command's symbol has the value t for this property it is a
-;; scrolling command. The feature needs to be enabled by setting the
-;; customizable variable `isearch-allow-scroll' to a non-nil value.
+;; If a command's symbol has the value t for this property or for the
+;; `scroll-command' property, it is a scrolling command. The feature
+;; needs to be enabled by setting the customizable variable
+;; `isearch-allow-scroll' to a non-nil value.
;;
;; The universal argument commands (e.g. C-u) in simple.el are marked
;; as scrolling commands, and isearch.el has been amended to allow
(if (fboundp 'w32-handle-scroll-bar-event)
(put 'w32-handle-scroll-bar-event 'isearch-scroll t))
-;; Commands which scroll the window:
+;; Commands which scroll the window (some scroll commands
+;; already have the `scroll-command' property on them):
(put 'recenter 'isearch-scroll t)
(put 'recenter-top-bottom 'isearch-scroll t)
(put 'reposition-window 'isearch-scroll t)
-(put 'scroll-up 'isearch-scroll t)
-(put 'scroll-down 'isearch-scroll t)
;; Commands which act on the other window
(put 'list-buffers 'isearch-scroll t)
"Whether scrolling is allowed during incremental search.
If non-nil, scrolling commands can be used in Isearch mode.
However, the current match will never scroll offscreen.
-If nil, scolling commands will first cancel Isearch mode."
+If nil, scrolling commands will first cancel Isearch mode."
:type 'boolean
:group 'isearch)
(let* ((overriding-terminal-local-map nil)
(binding (key-binding key-seq)))
(and binding (symbolp binding) (commandp binding)
- (eq (get binding 'isearch-scroll) t)
+ (or (eq (get binding 'isearch-scroll) t)
+ (eq (get binding 'scroll-command) t))
binding)))
(defalias 'isearch-other-control-char 'isearch-other-meta-char)
(setq char (unibyte-char-to-multibyte char)))
(isearch-process-search-char char))))
-(defun isearch-return-char ()
- "Convert return into newline for incremental search."
- (interactive)
- (isearch-process-search-char ?\n))
-(make-obsolete 'isearch-return-char 'isearch-printing-char "19.7")
-
(defun isearch-printing-char ()
"Add this ordinary printing character to the search string and search."
(interactive)
(setq isearch-overlay (make-overlay beg end))
;; 1001 is higher than lazy's 1000 and ediff's 100+
(overlay-put isearch-overlay 'priority 1001)
- (overlay-put isearch-overlay 'face isearch))))
+ (overlay-put isearch-overlay 'face isearch-face))))
(defun isearch-dehighlight ()
(when isearch-overlay
;; Clear RETRY unless the search predicate says
;; to skip this search hit.
(if (or (not success)
+ (= (point) bound) ; like (bobp) (eobp) in `isearch-search'.
+ (= (match-beginning 0) (match-end 0))
(funcall isearch-filter-predicate
(match-beginning 0) (match-end 0)))
(setq retry nil)))