(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.
(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.")
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.
\\[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.
(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)))
+
+\f
(defun isearch-delete-char ()
"Discard last input item and move point back.
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)
(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."