-;; Incremental search minor mode.
+;;; isearch.el --- incremental search minor mode.
+
;; Copyright (C) 1992 Free Software Foundation, Inc.
-;; LCD Archive Entry:
-;; isearch-mode|Daniel LaLiberte|liberte@cs.uiuc.edu
-;; |A minor mode replacement for isearch.el.
-;; |$Date: 1993/03/07 04:22:00 $|$Revision: 1.21 $|~/modes/isearch-mode.el
+;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
+
+;; |$Date: 1993/05/14 18:02:55 $|$Revision: 1.32 $
;; This file is not yet part of GNU Emacs, but it is based almost
;; entirely on isearch.el which is part of GNU Emacs.
;; file named COPYING. Among other things, the copyright notice
;; and this notice must be preserved on all copies.
+;;; Commentary:
+
;;;====================================================================
;; Instructions
;; isearch-forward, etc, will then use isearch-mode instead of
;; isearch.
-;; (fset 'isearch 'isearch-mode)
+;; (defalias 'isearch 'isearch-mode)
;; (autoload 'isearch-mode "isearch-mode")
;; For programmed use of isearch-mode, e.g. calling (isearch-forward),
;; of isearch-forward, etc. found in this file instead of those in
;; loaddefs.el. The simplest way to ensure this is to just load
;; isearch-mode explicitly in your .emacs instead of using the above
-;; fset and autoload.
+;; defalias and autoload.
;; (load "isearch-mode")
;; - Think about incorporating query-replace.
;; - Hooks and options for failed search.
+;;; Change Log:
+
;;;====================================================================
;;; Change History
-;;; $Header: /gd/gnu/emacs/19.0/lisp/RCS/isearch-mode.el,v 1.21 1993/03/07 04:22:00 rms Exp rms $
-;;; $Log: isearch-mode.el,v $
+;;; $Header: /gd/gnu/emacs/19.0/lisp/RCS/isearch.el,v 1.32 1993/05/14 18:02:55 rms Exp rms $
+;;; $Log: isearch.el,v $
+; Revision 1.32 1993/05/14 18:02:55 rms
+; (isearch-mode-map): Handle any length vector in keymap.
+; (isearch-char-to-string): Handle non-character events properly.
+;
+; Revision 1.31 1993/04/23 07:31:14 eric
+; Replaced all fsets with defaliases.
+;
+; Revision 1.30 1993/04/14 19:40:53 rms
+; Doc fixes.
+;
+; Revision 1.29 1993/03/30 19:42:10 rms
+; (isearch-done): Customize the message about mark.
+;
+; Revision 1.28 1993/03/30 19:38:34 rms
+; (isearch-mode-map): Delete the binding for C-h.
+;
+; Revision 1.27 1993/03/21 05:50:17 jimb
+; * isearch.el (isearch-switch-frame-handler): Call
+; handle-switch-frame instead of select-frame; it has been renamed.
+;
+; Revision 1.26 1993/03/17 17:17:05 eric
+; Add standard library headers.
+;
+; Revision 1.25 1993/03/17 16:44:50 eric
+; Add standard library headers.
+;
+; Revision 1.24 1993/03/17 15:58:09 eric
+; Add standard library headers.
+;
+; Revision 1.23 1993/03/07 20:17:27 rms
+; (isearch-other-meta-char): Call listify-key-sequence.
+; (isearch-unread): Don't call it here.
+; (isearch-mode-map): Bind the ASCII-equivalent function keys.
+;
+; Revision 1.22 1993/03/07 08:43:57 rms
+; (isearch-mode): Don't make a pre-command-hook.
+;
; Revision 1.21 1993/03/07 04:22:00 rms
; (isearch-unread): Find last list element by hand.
;
;;; 3/18/92 Fixed invalid-regexp.
;;; 3/18/92 Fixed yanking in regexps.
+;;; Code:
\f
;;;=========================================================================
;; Printing chars extend the selection by default.
(setq i ?\ )
- (while (< i 128)
+ (or (vectorp (nth 1 map))
+ (error "The initialization of isearch-mode-map must be updated"))
+ (while (< i (length (nth 1 map)))
(define-key map (make-string 1 i) 'isearch-printing-char)
(setq i (1+ i)))
(define-key map "\C-q" 'isearch-quote-char)
- ;; (define-key map "\r" 'isearch-return-char)
- ;; For version 19, RET (C-m) terminates search and LFD (C-j) matches eol.
- ;; We could make this conditional.
(define-key map "\r" 'isearch-exit)
(define-key map "\C-j" 'isearch-printing-char)
(define-key map "\t" 'isearch-printing-char)
(define-key map "\C-w" 'isearch-yank-word)
(define-key map "\C-y" 'isearch-yank-line)
+ ;; Bind the ASCII-equivalent "function keys" explicitly
+ ;; if we bind their equivalents,
+ ;; since otherwise the default binding would override.
+ ;; We bind [escape] below.
+ (define-key map [tab] 'isearch-printing-char)
+ (define-key map [delete] 'isearch-delete-char)
+ (define-key map [backspace] 'isearch-delete-char)
+ (define-key map [return] 'isearch-exit)
+ (define-key map [newline] 'isearch-printing-char)
+
;; Define keys for regexp chars * ? |.
;; Nothing special for + because it matches at least once.
(define-key map "*" 'isearch-*-char)
(define-key map "?" 'isearch-*-char)
(define-key map "|" 'isearch-|-char)
- ;; You can reenable global keys by binding them locally to nil.
- ;; For the help char this doesnt work quite as expected because
- ;; isearch-mode is not a major mode. Also the echo area is not
- ;; restored after the help command while isearch-mode is
- ;; still active. Furthermore, we should not assume that the
- ;; help-command is on C-h. But here is how it would be done:
- ;; (define-key map "\C-h" nil)
-
- ;; Instead bind C-h to special help command for isearch-mode.
- (define-key map "\C-h" 'isearch-mode-help)
+;;; Turned off because I find I expect to get the global definition--rms.
+;;; ;; Instead bind C-h to special help command for isearch-mode.
+;;; (define-key map "\C-h" 'isearch-mode-help)
;; To handle local bindings with meta char prefix keys, define
;; another full keymap. This must be done for any other prefix
;; keys as well, one full keymap per char of the prefix key. It
;; would be simpler to disable the global keymap, and/or have a
;; default local key binding for any key not otherwise bound.
- (define-key map (char-to-string meta-prefix-char) (make-sparse-keymap))
+ (let ((meta-map (make-sparse-keymap)))
+ (define-key map (char-to-string meta-prefix-char) meta-map)
+ (define-key map [escape] meta-map))
(define-key map (vector meta-prefix-char t) 'isearch-other-meta-char)
-;;; (setq i 0)
-;;; (while (< i 128)
-;;; (define-key map (char-to-string (+ 128 i));; Needs to be generalized.
-;;; 'isearch-other-meta-char)
-;;; (setq i (1+ i)))
(define-key map "\M-n" 'isearch-ring-advance)
(define-key map "\M-p" 'isearch-ring-retreat)
;;;===============================================================
;;; Entry points to isearch-mode.
;;; These four functions should replace those in loaddefs.el
-;;; An alternative is to fset isearch-forward etc to isearch-mode,
+;;; An alternative is to defalias isearch-forward etc to isearch-mode,
;;; and look at this-command to set the options accordingly.
(defun isearch-forward (&optional regexp-p no-recursive-edit)
;; If there was movement, mark the starting position.
;; Maybe should test difference between and set mark iff > threshold.
(if (/= (point) isearch-opoint)
- (push-mark isearch-opoint)
+ (progn
+ (push-mark isearch-opoint t)
+ (if transient-mark-mode
+ (setq mark-active nil))
+ (or executing-macro (> (minibuffer-depth) 0)
+ (message "Mark saved where search started")))
;; (message "") why is this needed?
)
(if isearch-small-window
(interactive) ;; Is this necessary?
;; First terminate isearch-mode.
(isearch-done)
- (select-frame (car (cdr (isearch-last-command-char)))))
+ (handle-switch-frame (car (cdr (isearch-last-command-char)))))
;;;========================================================
(isearch-process-search-char (isearch-last-command-char)))
-(fset 'isearch-other-control-char 'isearch-other-meta-char)
+(defalias 'isearch-other-control-char 'isearch-other-meta-char)
(defun isearch-other-meta-char ()
"Exit the search normally and reread this key sequence.
(interactive)
(cond ((eq search-exit-option 'edit)
(let ((key (this-command-keys)))
- (apply 'isearch-unread (append key nil)))
+ (apply 'isearch-unread (listify-key-sequence key)))
(isearch-edit-string))
(search-exit-option
(let ((key (this-command-keys)))
- (apply 'isearch-unread (append key nil)))
+ (apply 'isearch-unread (listify-key-sequence key)))
(isearch-done))
(t;; otherwise nil
(isearch-process-search-string (this-command-keys)
(isearch-process-search-char ?\n))
(defun isearch-printing-char ()
- "Any other printing character => add it to the search string and search."
+ "Add this ordinary printing character to the search string and search."
(interactive)
(isearch-process-search-char (isearch-last-command-char)))
(defun isearch-whitespace-chars ()
"Match all whitespace chars, if in regexp mode.
-If not in regexp mode, activate word search."
+If you want to search for just a space, type C-q SPC."
(interactive)
(if isearch-regexp
(if search-whitespace-regexp
(set-extent-face isearch-extent 'default)
(isearch-dehighlight t)))))
-(fset 'isearch-highlight (symbol-function 'isearch-lemacs-highlight))
-(fset 'isearch-dehighlight (symbol-function 'isearch-lemacs-dehighlight))
+(defalias 'isearch-highlight (symbol-function 'isearch-lemacs-highlight))
+(defalias 'isearch-dehighlight (symbol-function 'isearch-lemacs-dehighlight))
)
;;;===========================================================
;;; General utilities
-;; (fset 'isearch-member-equal (symbol-function 'member)) ; for emacs 19
+;; (defalias 'isearch-member-equal (symbol-function 'member)) ; for emacs 19
(defun isearch-member-equal (item list)
"Return non-nil if ITEM is `equal' to some item in LIST.
(defun isearch-char-to-string (c)
(if (integerp c)
(make-string 1 c)
- (make-string 1 (event-to-character c))))
+ (if (and (symbolp c) (get c 'ascii-character))
+ (make-string 1 (get c 'ascii-character))
+ (make-string 1 (event-to-character c)))))
(defun isearch-text-char-description (c)
(isearch-char-to-string c))
(defun isearch-unread (&rest char-or-events)
- (setq foo char-or-events)
;; General function to unread characters or events.
(if isearch-gnu-emacs-events
- (setq unread-command-events (listify-key-sequence char-or-events))
+ (setq unread-command-events
+ (append char-or-events unread-command-events))
(let ((char (if (cdr char-or-events)
(progn
(while (cdr char-or-events)
;;))
+;;; isearch.el ends here