* lisp/isearch.el: Let M-e start with point at the first mismatched char.

(isearch-fail-pos): New function.
(isearch-edit-string): Use it.
This commit is contained in:
Drew Adams 2011-05-27 22:26:53 -03:00 committed by Stefan Monnier
parent 66e2e71d55
commit b74aa22b0a
2 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2011-05-28 Drew Adams <drew.adams@oracle.com>
* isearch.el: Let M-e start with point at the first mismatched char.
(isearch-fail-pos): New function.
(isearch-edit-string): Use it.
2011-05-28 Dmitry Kurochkin <dmitry.kurochkin@gmail.com> (tiny change)
* isearch.el (isearch-range-invisible): Use invisible-p (bug#8721).

View file

@ -1062,6 +1062,22 @@ nonincremental search instead via `isearch-edit-string'."
(defvar minibuffer-history-symbol) ;; from external package gmhist.el
(defun isearch-fail-pos ()
"Position of first mismatch in search string, or its length if none."
(let ((cmds isearch-cmds))
(if (and isearch-success (not isearch-error))
(length isearch-message)
(while (or (not (isearch-success-state (car cmds)))
(isearch-error-state (car cmds)))
(pop cmds))
(let ((succ-msg (and cmds (isearch-message-state (car cmds)))))
(if (and (stringp succ-msg)
(< (length succ-msg) (length isearch-message))
(equal succ-msg
(substring isearch-message 0 (length succ-msg))))
(length succ-msg)
0)))))
(defun isearch-edit-string ()
"Edit the search string in the minibuffer.
The following additional command keys are active while editing.
@ -1141,7 +1157,7 @@ If first char entered is \\[isearch-yank-word-or-char], then do word search inst
(setq isearch-new-string
(read-from-minibuffer
(isearch-message-prefix nil nil isearch-nonincremental)
isearch-string
(cons isearch-string (1+ (isearch-fail-pos)))
minibuffer-local-isearch-map nil
(if isearch-regexp
(cons 'regexp-search-ring