[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isearch-allow-move [Was: isearch-allow-prefix]
From: |
Juri Linkov |
Subject: |
Re: isearch-allow-move [Was: isearch-allow-prefix] |
Date: |
Fri, 07 Jun 2013 23:04:15 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> You could then use it to erase the entire search string and then
> convert a forward search into backward search by another C-b.
Converting a forward search into backward search turned out to be
a very good idea. After trying it I see that this is the most
natural thing to do.
The updated part of the patch is below (most code should be
refactored to more general functions, so the remaining code
should leave about 30 lines here):
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2013-06-05 20:57:09 +0000
+++ lisp/isearch.el 2013-06-07 19:55:08 +0000
@@ -2336,6 +2540,72 @@ (defun isearch-other-meta-char (&optiona
(isearch-back-into-window (eq ab-bel 'above) isearch-point)
(goto-char isearch-point)))
(isearch-update))
+ ;; Handle a motion function.
+ ((and (or isearch-allow-move isearch-allow-move-temporarily)
+ (progn (setq key (isearch-reread-key-sequence-naturally
keylist))
+ (setq keylist (listify-key-sequence key))
+ (setq main-event (aref key 0))
+ (setq move-command (or
+ (isearch-lookup-move-key key)
+ (isearch-lookup-move-key
+ ;; Use the last key in the sequence.
+ (vector (aref key (1- (length
key)))))))
+ isearch-success))
+ (setq prefix-arg arg)
+ (let* ((old-point (point))
+ (new-point (save-excursion
+ (condition-case ()
+ (command-execute move-command)
+ (error nil))
+ (point))))
+ ;; Change search direction between forward and backward.
+ (when (and isearch-other-end
+ (not isearch-error) ; for regexp incomplete input
+ (if isearch-forward
+ (< new-point isearch-other-end)
+ (> new-point isearch-other-end)))
+ (setq isearch-forward (not isearch-forward))
+ (setq isearch-string "" isearch-message "")
+ (setq old-point isearch-other-end))
+ (if (< old-point new-point)
+ ;; Add text to the search string.
+ (if isearch-forward
+ (isearch-yank-string
+ (buffer-substring-no-properties old-point new-point))
+ ;; In backward search delete text from beginning of search
string.
+ (setq isearch-string (substring isearch-string
+ (min (- new-point old-point)
+ (length isearch-string))
+ (length isearch-string))
+ isearch-message (mapconcat
'isearch-text-char-description
+ isearch-string ""))
+ (setq isearch-yank-flag t)
+ (goto-char new-point)
+ (isearch-search-and-update))
+ (if isearch-forward
+ (progn
+ ;; Delete text from the search string.
+ (setq isearch-string (substring isearch-string 0
+ (max (- (length
isearch-string)
+ (- old-point
new-point)) 0))
+ isearch-message (mapconcat
'isearch-text-char-description
+ isearch-string ""))
+ (setq isearch-yank-flag t)
+ (isearch-search-and-update))
+ ;; In backward search add text to beginning of search string.
+ (setq isearch-string
+ (concat
+ (if isearch-regexp
+ (regexp-quote
+ (buffer-substring-no-properties old-point
new-point))
+ (buffer-substring-no-properties old-point new-point))
+ isearch-string)
+ isearch-message (mapconcat 'isearch-text-char-description
+ isearch-string ""))
+ (setq isearch-yank-flag t)
+ (goto-char new-point)
+ (isearch-search-and-update))))
+ (setq isearch-allow-move-temporarily t))
;; A mouse click on the isearch message starts editing the search
string
((and (eq (car-safe main-event) 'down-mouse-1)
(window-minibuffer-p (posn-window (event-start main-event))))
- Re: isearch-allow-move [Was: isearch-allow-prefix], (continued)
- Re: isearch-allow-move [Was: isearch-allow-prefix], Alan Mackenzie, 2013/06/06
- Re: isearch-allow-move [Was: isearch-allow-prefix], Juri Linkov, 2013/06/07
- Re: isearch-allow-move [Was: isearch-allow-prefix], Alan Mackenzie, 2013/06/07
- Re: isearch-allow-move [Was: isearch-allow-prefix], Juri Linkov, 2013/06/07
- Re: isearch-allow-move [Was: isearch-allow-prefix], Juri Linkov, 2013/06/09
- Re: isearch-allow-move [Was: isearch-allow-prefix], Juri Linkov, 2013/06/11
- Re: isearch-allow-move [Was: isearch-allow-prefix],
Juri Linkov <=