/[emacs]/emacs/lisp/isearch.el
ViewVC logotype

Diff of /emacs/lisp/isearch.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.221.2.3 by miles, Mon Jun 28 07:28:42 2004 UTC revision 1.221.2.4 by miles, Tue Jul 6 02:56:04 2004 UTC
# Line 1  Line 1 
1  ;;; isearch.el --- incremental search minor mode  ;;; isearch.el --- incremental search minor mode
2    
3  ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 1999, 2000, 01, 2003, 2004  ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999,
4  ;;   Free Software Foundation, Inc.  ;;   2000, 2001, 2003, 2004  Free Software Foundation, Inc.
5    
6  ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>  ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
7  ;; Maintainer: FSF  ;; Maintainer: FSF
# Line 59  Line 59 
59    
60  ;; TODO  ;; TODO
61  ;; - Integrate the emacs 19 generalized command history.  ;; - Integrate the emacs 19 generalized command history.
 ;; - Think about incorporating query-replace.  
62  ;; - Hooks and options for failed search.  ;; - Hooks and options for failed search.
63    
64  ;;; Change Log:  ;;; Change Log:
# Line 290  Default value, nil, means edit the strin Line 289  Default value, nil, means edit the strin
289      (define-key map " " 'isearch-whitespace-chars)      (define-key map " " 'isearch-whitespace-chars)
290      (define-key map [?\S-\ ] 'isearch-whitespace-chars)      (define-key map [?\S-\ ] 'isearch-whitespace-chars)
291    
292      (define-key map "\C-w" 'isearch-yank-word-or-char)      (define-key map    "\C-w" 'isearch-yank-word-or-char)
293      (define-key map "\C-y" 'isearch-yank-line)      (define-key map "\M-\C-w" 'isearch-del-char)
294        (define-key map "\M-\C-y" 'isearch-yank-char)
295        (define-key map    "\C-y" 'isearch-yank-line)
296    
297      ;; Define keys for regexp chars * ? |.      ;; Define keys for regexp chars * ? |.
298      ;; Nothing special for + because it matches at least once.      ;; Nothing special for + because it matches at least once.
# Line 332  Default value, nil, means edit the strin Line 333  Default value, nil, means edit the strin
333      (define-key map "\M-r" 'isearch-toggle-regexp)      (define-key map "\M-r" 'isearch-toggle-regexp)
334      (define-key map "\M-e" 'isearch-edit-string)      (define-key map "\M-e" 'isearch-edit-string)
335    
336        (define-key map [?\M-%] 'isearch-query-replace)
337        (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
338    
339      map)      map)
340    "Keymap for `isearch-mode'.")    "Keymap for `isearch-mode'.")
341    
342  (defvar minibuffer-local-isearch-map  (defvar minibuffer-local-isearch-map
343    (let ((map (make-sparse-keymap)))    (let ((map (make-sparse-keymap)))
344      (set-keymap-parent map minibuffer-local-map)      (set-keymap-parent map minibuffer-local-map)
345      (define-key map "\r" 'isearch-nonincremental-exit-minibuffer)      (define-key map "\r"    'isearch-nonincremental-exit-minibuffer)
346      (define-key map "\M-n" 'isearch-ring-advance-edit)      (define-key map "\M-n"  'isearch-ring-advance-edit)
347      (define-key map "\M-p" 'isearch-ring-retreat-edit)      (define-key map [next]  'isearch-ring-advance-edit)
348        (define-key map [down]  'isearch-ring-advance-edit)
349        (define-key map "\M-p"  'isearch-ring-retreat-edit)
350        (define-key map [prior] 'isearch-ring-retreat-edit)
351        (define-key map [up]    'isearch-ring-retreat-edit)
352      (define-key map "\M-\t" 'isearch-complete-edit)      (define-key map "\M-\t" 'isearch-complete-edit)
353      (define-key map "\C-s" 'isearch-forward-exit-minibuffer)      (define-key map "\C-s"  'isearch-forward-exit-minibuffer)
354      (define-key map "\C-r" 'isearch-reverse-exit-minibuffer)      (define-key map "\C-r"  'isearch-reverse-exit-minibuffer)
355        (define-key map "\C-f"  'isearch-yank-char-in-minibuffer)
356        (define-key map [right] 'isearch-yank-char-in-minibuffer)
357      map)      map)
358    "Keymap for editing isearch strings in the minibuffer.")    "Keymap for editing isearch strings in the minibuffer.")
359    
# Line 445  As you type characters, they add to the Line 455  As you type characters, they add to the
455  The following non-printing keys are bound in `isearch-mode-map'.  The following non-printing keys are bound in `isearch-mode-map'.
456    
457  Type \\[isearch-delete-char] to cancel last input item from end of search string.  Type \\[isearch-delete-char] to cancel last input item from end of search string.
 Type \\[isearch-del-char] to cancel last character from end of search string.  
458  Type \\[isearch-exit] to exit, leaving point at location found.  Type \\[isearch-exit] to exit, leaving point at location found.
459  Type LFD (C-j) to match end of line.  Type LFD (C-j) to match end of line.
460  Type \\[isearch-repeat-forward] to search again forward,\  Type \\[isearch-repeat-forward] to search again forward,\
461   \\[isearch-repeat-backward] to search again backward.   \\[isearch-repeat-backward] to search again backward.
462  Type \\[isearch-yank-char] to yank character from buffer onto end of search\  Type \\[isearch-yank-word-or-char] to yank word from buffer onto end of search\
463   string and search for it.   string and search for it.
464  Type \\[isearch-yank-word] to yank word from buffer onto end of search\  Type \\[isearch-del-char] to delete character from end of search string.
465    Type \\[isearch-yank-char] to yank char from buffer onto end of search\
466   string and search for it.   string and search for it.
467  Type \\[isearch-yank-line] to yank rest of line onto end of search string\  Type \\[isearch-yank-line] to yank rest of line onto end of search string\
468   and search for it.   and search for it.
# Line 788  The following additional command keys ar Line 798  The following additional command keys ar
798  \\[isearch-ring-retreat-edit] to replace the search string with the previous item in the search ring.  \\[isearch-ring-retreat-edit] to replace the search string with the previous item in the search ring.
799  \\[isearch-complete-edit] to complete the search string using the search ring.  \\[isearch-complete-edit] to complete the search string using the search ring.
800  \\<isearch-mode-map>  \\<isearch-mode-map>
801  If first char entered is \\[isearch-yank-word], then do word search instead."  If first char entered is \\[isearch-yank-word-or-char], then do word search instead."
802    
803    ;; This code is very hairy for several reasons, explained in the code.    ;; This code is very hairy for several reasons, explained in the code.
804    ;; Mainly, isearch-mode must be terminated while editing and then restarted.    ;; Mainly, isearch-mode must be terminated while editing and then restarted.
# Line 1044  Use `isearch-exit' to quit without signa Line 1054  Use `isearch-exit' to quit without signa
1054    (sit-for 1)    (sit-for 1)
1055    (isearch-update))    (isearch-update))
1056    
1057    (defun isearch-query-replace ()
1058      "Start query-replace with string to replace from last search string."
1059      (interactive)
1060      (barf-if-buffer-read-only)
1061      (let ((case-fold-search isearch-case-fold-search))
1062        (isearch-done)
1063        (isearch-clean-overlays)
1064        (and isearch-forward isearch-other-end (goto-char isearch-other-end))
1065        (perform-replace
1066         isearch-string
1067         (query-replace-read-to isearch-string "Query replace" isearch-regexp)
1068         t isearch-regexp isearch-word)))
1069    
1070    (defun isearch-query-replace-regexp ()
1071      "Start query-replace-regexp with string to replace from last search string."
1072      (interactive)
1073      (let ((query-replace-interactive t)
1074            (case-fold-search isearch-case-fold-search))
1075        ;; Put search string into the right ring
1076        (setq isearch-regexp t)
1077        (isearch-done)
1078        (isearch-clean-overlays)
1079        (and isearch-forward isearch-other-end (goto-char isearch-other-end))
1080        (call-interactively 'query-replace-regexp)))
1081    
1082    
1083  (defun isearch-delete-char ()  (defun isearch-delete-char ()
1084    "Discard last input item and move point back.    "Discard last input item and move point back.
1085  If no previous match was done, just beep."  If no previous match was done, just beep."
# Line 1053  If no previous match was done, just beep Line 1089  If no previous match was done, just beep
1089      (isearch-pop-state))      (isearch-pop-state))
1090    (isearch-update))    (isearch-update))
1091    
1092  (defun isearch-del-char ()  (defun isearch-del-char (&optional arg)
1093    "Discard last character and move point back.    "Delete character from end of search string and search again.
1094  If there is no previous character, just beep."  If search string is empty, just beep."
1095    (interactive)    (interactive "p")
1096    (if (equal isearch-string "")    (if (= 0 (length isearch-string))
1097        (ding)        (ding)
1098      (setq isearch-string (substring isearch-string 0 -1)      (setq isearch-string (substring isearch-string 0 (- (or arg 1)))
1099            isearch-message (mapconcat 'isearch-text-char-description            isearch-message (mapconcat 'isearch-text-char-description
1100                                       isearch-string "")))                                       isearch-string "")
1101              ;; Don't move cursor in reverse search.
1102              isearch-yank-flag t))
1103    (isearch-search-and-update))    (isearch-search-and-update))
1104    
1105  (defun isearch-yank-string (string)  (defun isearch-yank-string (string)
# Line 1123  might return the position of the end of Line 1161  might return the position of the end of
1161            (goto-char isearch-other-end))            (goto-char isearch-other-end))
1162       (buffer-substring-no-properties (point) (funcall jumpform)))))       (buffer-substring-no-properties (point) (funcall jumpform)))))
1163    
1164  (defun isearch-yank-char ()  (defun isearch-yank-char-in-minibuffer (&optional arg)
1165      "Pull next character from buffer into end of search string in minibuffer."
1166      (interactive "p")
1167      (if (eobp)
1168          (insert
1169           (save-excursion
1170             (set-buffer (cadr (buffer-list)))
1171             (buffer-substring-no-properties
1172              (point) (progn (forward-char arg) (point)))))
1173        (forward-char arg)))
1174    
1175    (defun isearch-yank-char (&optional arg)
1176    "Pull next character from buffer into search string."    "Pull next character from buffer into search string."
1177    (interactive)    (interactive "p")
1178    (isearch-yank-internal (lambda () (forward-char 1) (point))))    (isearch-yank-internal (lambda () (forward-char arg) (point))))
1179    
1180  (defun isearch-yank-word-or-char ()  (defun isearch-yank-word-or-char ()
1181    "Pull next character or word from buffer into search string."    "Pull next character or word from buffer into search string."
# Line 2327  CASE-FOLD non-nil means the search was c Line 2376  CASE-FOLD non-nil means the search was c
2376          isearch-case-fold-search case-fold)          isearch-case-fold-search case-fold)
2377    (isearch-search))    (isearch-search))
2378    
2379  ;;; arch-tag: 74850515-f7d8-43a6-8a2c-ca90a4c1e675  ;; arch-tag: 74850515-f7d8-43a6-8a2c-ca90a4c1e675
2380  ;;; isearch.el ends here  ;;; isearch.el ends here

Legend:
Removed from v.1.221.2.3  
changed lines
  Added in v.1.221.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26