diff options
author | Drew Adams <drew.adams@oracle.com> | 2011-05-27 22:26:53 -0300 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-05-27 22:26:53 -0300 |
commit | b74aa22b0a69709a67f33fb446da3c22f7ea340c (patch) | |
tree | 88c7804922ccb7835e1ea2cc07a31ec115dda385 /lisp/isearch.el | |
parent | 66e2e71d556785cd10270931c6fc0424b9dea6a6 (diff) | |
download | emacs-b74aa22b0a69709a67f33fb446da3c22f7ea340c.tar.gz emacs-b74aa22b0a69709a67f33fb446da3c22f7ea340c.tar.bz2 emacs-b74aa22b0a69709a67f33fb446da3c22f7ea340c.zip |
* lisp/isearch.el: Let M-e start with point at the first mismatched char.
(isearch-fail-pos): New function.
(isearch-edit-string): Use it.
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r-- | lisp/isearch.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 1bb08d1ebb4..7f018ab14c7 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -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 |