all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh)
@ 2013-01-10 15:18 Le Wang
  2013-12-18  3:03 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Le Wang @ 2013-01-10 15:18 UTC (permalink / raw)
  To: 13404

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

I like to bind comint-previous-matching-input-from-input to M-p,
however the current behavior is to find the first match and move the
point to the end of the line.

The point should not be moved so that I can press M-p again to find
the next match.

This is how this command works in zsh and bash.

Patch included.


-- 
Le

[-- Attachment #2: comint.el_keep_point_in_place.diff --]
[-- Type: application/octet-stream, Size: 1820 bytes --]

diff -u -L /Applications/Emacs.app/Contents/Resources/lisp/comint.el.gz -L \#\<buffer\ comint.el.gz\> /var/folders/67/lwk_jwy110g_30xzbytk25zw0000gn/T/jka-com5040Dr /var/folders/67/lwk_jwy110g_30xzbytk25zw0000gn/T/buffer-content-504zXA
--- /Applications/Emacs.app/Contents/Resources/lisp/comint.el.gz
+++ #<buffer comint.el.gz>
@@ -1209,18 +1209,20 @@
 With prefix argument N, search for Nth previous match.
 If N is negative, search forwards for the -Nth following match."
   (interactive "p")
-  (if (not (memq last-command '(comint-previous-matching-input-from-input
-				comint-next-matching-input-from-input)))
-      ;; Starting a new search
-      (setq comint-matching-input-from-input-string
-	    (buffer-substring
-	     (or (marker-position comint-accum-marker)
-		 (process-mark (get-buffer-process (current-buffer))))
-	     (point))
-	    comint-input-ring-index nil))
-  (comint-previous-matching-input
-   (concat "^" (regexp-quote comint-matching-input-from-input-string))
-   n))
+  (let ((old-point (point)))
+    (if (not (memq last-command '(comint-previous-matching-input-from-input
+                                  comint-next-matching-input-from-input)))
+        ;; Starting a new search
+        (setq comint-matching-input-from-input-string
+              (buffer-substring
+               (or (marker-position comint-accum-marker)
+                   (process-mark (get-buffer-process (current-buffer))))
+               (point))
+              comint-input-ring-index nil))
+    (comint-previous-matching-input
+     (concat "^" (regexp-quote comint-matching-input-from-input-string))
+     n)
+    (goto-char old-point)))
 
 (defun comint-next-matching-input-from-input (n)
   "Search forwards through input history for match for current input.

Diff finished.  Thu Jan  3 09:05:41 2013

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

* bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh)
  2013-01-10 15:18 bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh) Le Wang
@ 2013-12-18  3:03 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2013-12-18  3:03 UTC (permalink / raw)
  To: Le Wang; +Cc: 13404-done

Le Wang <l26wang@gmail.com> writes:

> I like to bind comint-previous-matching-input-from-input to M-p,
> however the current behavior is to find the first match and move the
> point to the end of the line.
>
> The point should not be moved so that I can press M-p again to find
> the next match.
>
> This is how this command works in zsh and bash.

Looks reasonable.  I've committed your patch, thanks.





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

end of thread, other threads:[~2013-12-18  3:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 15:18 bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh) Le Wang
2013-12-18  3:03 ` Chong Yidong

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.