all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* isearch.el patch for `M-e' to put point at mismatch position
@ 2011-05-16 21:36 Drew Adams
  2011-05-16 22:14 ` Juri Linkov
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Drew Adams @ 2011-05-16 21:36 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

The attached patch makes `M-e' (`isearch-edit-string') put point at the first
mismatch position (or the search-string end if no mismatch).

When you hit `M-e' you are ready to edit at the mismatch position.  This makes
it easy to change or insert a char or two to make the string match.  (`C-g', on
the other hand just removes all of the mismatch.)

(This feature complements the use of highlighting to show users where the
mismatch starts.)

[-- Attachment #2: isearch-2011-05-16.patch --]
[-- Type: application/octet-stream, Size: 1968 bytes --]

diff -cw isearch.el isearch-patched-2011-05-16.el
*** isearch.el	Mon May 16 11:38:22 2011
--- isearch-patched-2011-05-16.el	Mon May 16 14:21:04 2011
***************
*** 1060,1065 ****
--- 1060,1080 ----
  
  (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)
+         succ-msg)
+     (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))
+       (setq 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.
***************
*** 1139,1145 ****
  		(setq isearch-new-string
                        (read-from-minibuffer
                         (isearch-message-prefix nil nil isearch-nonincremental)
!                        isearch-string
                         minibuffer-local-isearch-map nil
                         (if isearch-regexp
  			   (cons 'regexp-search-ring
--- 1154,1160 ----
                   (setq isearch-new-string
                         (read-from-minibuffer
                          (isearch-message-prefix nil nil isearch-nonincremental)
!                         (cons isearch-string (1+ (isearch-fail-pos)))
                          minibuffer-local-isearch-map nil
                          (if isearch-regexp
                              (cons 'regexp-search-ring

Diff finished.  Mon May 16 14:23:06 2011

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-14 16:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-16 21:36 isearch.el patch for `M-e' to put point at mismatch position Drew Adams
2011-05-16 22:14 ` Juri Linkov
2011-05-16 22:37   ` Drew Adams
2011-05-17  3:08 ` Stefan Monnier
2011-05-27 20:54   ` Drew Adams
2011-05-28  1:27 ` Stefan Monnier
2011-09-10 11:54 ` Juri Linkov
2011-09-10 16:13   ` Drew Adams
2011-09-10 16:22     ` Drew Adams
2011-09-12 11:28       ` Juri Linkov
2011-09-12 14:58         ` Drew Adams
2011-09-14 16:08           ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.