aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/isearch.el
diff options
context:
space:
mode:
authorJuri Linkov <[email protected]>2004-07-01 09:54:51 +0000
committerJuri Linkov <[email protected]>2004-07-01 09:54:51 +0000
commit74820eb5215e5e21f084c70e7770e0a04c1f6033 (patch)
tree58bdf1d4bff5031d2d88f1a78154243912ae46df /lisp/isearch.el
parentc5dea9580caaa7f74e7c7c0b2fe2ac1b8480637e (diff)
(isearch-mode-map): Bind C-M-w to isearch-del-char,
C-M-y to isearch-yank-char. Bind M-% to isearch-query-replace, C-M-% to isearch-query-replace-regexp. (minibuffer-local-isearch-map): Add arrow key bindings. Bind C-f to isearch-yank-char-in-minibuffer. (isearch-forward): Doc fix. (isearch-edit-string): Doc fix. (isearch-query-replace, isearch-query-replace-regexp): New funs. (isearch-del-char): Add optional arg. Set isearch-yank-flag to t. (isearch-yank-char): Add optional arg. (isearch-yank-char-in-minibuffer): New fun.
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el91
1 files changed, 70 insertions, 21 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 3898aa13f6..d30c7c6cc6 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -294,8 +294,10 @@ Default value, nil, means edit the string instead."
(define-key map " " 'isearch-whitespace-chars)
(define-key map [?\S-\ ] 'isearch-whitespace-chars)
- (define-key map "\C-w" 'isearch-yank-word-or-char)
- (define-key map "\C-y" 'isearch-yank-line)
+ (define-key map "\C-w" 'isearch-yank-word-or-char)
+ (define-key map "\M-\C-w" 'isearch-del-char)
+ (define-key map "\M-\C-y" 'isearch-yank-char)
+ (define-key map "\C-y" 'isearch-yank-line)
;; Define keys for regexp chars * ? |.
;; Nothing special for + because it matches at least once.
@@ -336,18 +338,27 @@ Default value, nil, means edit the string instead."
(define-key map "\M-r" 'isearch-toggle-regexp)
(define-key map "\M-e" 'isearch-edit-string)
+ (define-key map (kbd "M-%") 'isearch-query-replace)
+ (define-key map (kbd "C-M-%") 'isearch-query-replace-regexp)
+
map)
"Keymap for `isearch-mode'.")
(defvar minibuffer-local-isearch-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
- (define-key map "\r" 'isearch-nonincremental-exit-minibuffer)
- (define-key map "\M-n" 'isearch-ring-advance-edit)
- (define-key map "\M-p" 'isearch-ring-retreat-edit)
+ (define-key map "\r" 'isearch-nonincremental-exit-minibuffer)
+ (define-key map "\M-n" 'isearch-ring-advance-edit)
+ (define-key map [next] 'isearch-ring-advance-edit)
+ (define-key map [down] 'isearch-ring-advance-edit)
+ (define-key map "\M-p" 'isearch-ring-retreat-edit)
+ (define-key map [prior] 'isearch-ring-retreat-edit)
+ (define-key map [up] 'isearch-ring-retreat-edit)
(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-s" 'isearch-forward-exit-minibuffer)
+ (define-key map "\C-r" 'isearch-reverse-exit-minibuffer)
+ (define-key map "\C-f" 'isearch-yank-char-in-minibuffer)
+ (define-key map [right] 'isearch-yank-char-in-minibuffer)
map)
"Keymap for editing isearch strings in the minibuffer.")
@@ -449,14 +460,14 @@ As you type characters, they add to the search string and are found.
The following non-printing keys are bound in `isearch-mode-map'.
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.
Type \\[isearch-exit] to exit, leaving point at location found.
Type LFD (C-j) to match end of line.
Type \\[isearch-repeat-forward] to search again forward,\
\\[isearch-repeat-backward] to search again backward.
-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\
string and search for it.
-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.
+Type \\[isearch-yank-char] to yank char from buffer onto end of search\
string and search for it.
Type \\[isearch-yank-line] to yank rest of line onto end of search string\
and search for it.
@@ -792,7 +803,7 @@ The following additional command keys are active while editing.
\\[isearch-ring-retreat-edit] to replace the search string with the previous item in the search ring.
\\[isearch-complete-edit] to complete the search string using the search ring.
\\<isearch-mode-map>
-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."
;; This code is very hairy for several reasons, explained in the code.
;; Mainly, isearch-mode must be terminated while editing and then restarted.
@@ -1048,6 +1059,31 @@ Use `isearch-exit' to quit without signaling."
(sit-for 1)
(isearch-update))
+(defun isearch-query-replace ()
+ "Start query-replace with string to replace from last search string."
+ (interactive)
+ (let ((query-replace-interactive 'initial)
+ (case-fold-search isearch-case-fold-search))
+ ;; Put search string into the right ring
+ (setq isearch-regexp nil)
+ (isearch-done)
+ (isearch-clean-overlays)
+ (and isearch-forward isearch-other-end (goto-char isearch-other-end))
+ (call-interactively 'query-replace)))
+
+(defun isearch-query-replace-regexp ()
+ "Start query-replace-regexp with string to replace from last search string."
+ (interactive)
+ (let ((query-replace-interactive 'initial)
+ (case-fold-search isearch-case-fold-search))
+ ;; Put search string into the right ring
+ (setq isearch-regexp t)
+ (isearch-done)
+ (isearch-clean-overlays)
+ (and isearch-forward isearch-other-end (goto-char isearch-other-end))
+ (call-interactively 'query-replace-regexp)))
+
+
(defun isearch-delete-char ()
"Discard last input item and move point back.
If no previous match was done, just beep."
@@ -1057,15 +1093,17 @@ If no previous match was done, just beep."
(isearch-pop-state))
(isearch-update))
-(defun isearch-del-char ()
- "Discard last character and move point back.
-If there is no previous character, just beep."
- (interactive)
- (if (equal isearch-string "")
+(defun isearch-del-char (&optional arg)
+ "Delete character from end of search string and search again.
+If search string is empty, just beep."
+ (interactive "p")
+ (if (= 0 (length isearch-string))
(ding)
- (setq isearch-string (substring isearch-string 0 -1)
+ (setq isearch-string (substring isearch-string 0 (- (or arg 1)))
isearch-message (mapconcat 'isearch-text-char-description
- isearch-string "")))
+ isearch-string "")
+ ;; Don't move cursor in reverse search.
+ isearch-yank-flag t))
(isearch-search-and-update))
(defun isearch-yank-string (string)
@@ -1127,10 +1165,21 @@ might return the position of the end of the line."
(goto-char isearch-other-end))
(buffer-substring-no-properties (point) (funcall jumpform)))))
-(defun isearch-yank-char ()
+(defun isearch-yank-char-in-minibuffer (&optional arg)
+ "Pull next character from buffer into end of search string in minibuffer."
+ (interactive "p")
+ (if (eobp)
+ (insert
+ (save-excursion
+ (set-buffer (cadr (buffer-list)))
+ (buffer-substring-no-properties
+ (point) (progn (forward-char arg) (point)))))
+ (forward-char arg)))
+
+(defun isearch-yank-char (&optional arg)
"Pull next character from buffer into search string."
- (interactive)
- (isearch-yank-internal (lambda () (forward-char 1) (point))))
+ (interactive "p")
+ (isearch-yank-internal (lambda () (forward-char arg) (point))))
(defun isearch-yank-word-or-char ()
"Pull next character or word from buffer into search string."