all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Le Wang <l26wang@gmail.com>
To: 13404@debbugs.gnu.org
Subject: bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh)
Date: Thu, 10 Jan 2013 23:18:30 +0800	[thread overview]
Message-ID: <CAM=K+ipw=CqF9b3zmY3B9SfbL-UKC2kgviAqaj9Wp29GwdgJMw@mail.gmail.com> (raw)

[-- 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

             reply	other threads:[~2013-01-10 15:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 15:18 Le Wang [this message]
2013-12-18  3:03 ` bug#13404: comint-previous-matching-input-from-input is broken (as compared to bash/zsh) Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM=K+ipw=CqF9b3zmY3B9SfbL-UKC2kgviAqaj9Wp29GwdgJMw@mail.gmail.com' \
    --to=l26wang@gmail.com \
    --cc=13404@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.