summaryrefslogtreecommitdiff
path: root/lisp/isearch.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el60
1 files changed, 32 insertions, 28 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 3b04fa270b0..ebe2e8fa009 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -7,6 +7,7 @@
;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
;; Maintainer: FSF
;; Keywords: matching
+;; Package: emacs
;; This file is part of GNU Emacs.
@@ -156,6 +157,9 @@ command history."
(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'
@@ -235,7 +239,7 @@ Default value, nil, means edit the string instead."
"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))
@@ -464,7 +468,9 @@ This is like `describe-bindings', but displays only Isearch keys."
(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)
@@ -872,7 +878,8 @@ It is called by the function `isearch-forward' and other related functions."
(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.
@@ -1480,14 +1487,10 @@ If search string is empty, just beep."
(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."
@@ -1542,14 +1545,18 @@ or it might return the position of the end of the line."
(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 ()
@@ -1712,9 +1719,10 @@ Scroll-bar or mode-line events are processed appropriately."
;; 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
@@ -1731,12 +1739,11 @@ Scroll-bar or mode-line events are processed appropriately."
(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)
@@ -1761,7 +1768,7 @@ Scroll-bar or mode-line events are processed appropriately."
"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)
@@ -1825,7 +1832,8 @@ Otherwise return nil."
(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)
@@ -1986,12 +1994,6 @@ Isearch mode."
(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)
@@ -2533,7 +2535,7 @@ since they have special meaning in a regexp."
(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
@@ -2669,6 +2671,8 @@ Attempt to do the search exactly the way the pending Isearch would."
;; 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)))