Subject: bug#21737: Acknowledgement (24.5; Minor feature request: `comint-previous-matching-input-from-input' and point)

From: Stephen Perry <[email-masked]>
Date: Fri, 13 Nov 2015 22:30:45 +0000

How about this for a patch?  It’s my first so be kind :-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e70fe88..8d61226 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -283,6 +283,14 @@ comint-move-point-for-output
 		 (const others))
   :group 'comint)
 
+(defcustom comint-move-point-to-end-on-match nil
+  "Controls whether point moves to the end of the matched input.
+If nil, then point remains in the current position.
+If t, point moves to the end of matched input."
+  :type '(choice (const :tag "off" nil)
+                 (const t))
+  :group 'comint)
+
 (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
 
 (defcustom comint-scroll-show-maximum-output t
@@ -1220,7 +1228,8 @@ comint-previous-matching-input-from-input
     (comint-previous-matching-input
      (concat "^" (regexp-quote comint-matching-input-from-input-string))
      n)
-    (goto-char opoint)))
+    (unless comint-move-point-to-end-on-match
+      (goto-char opoint))))
 
 (defun comint-next-matching-input-from-input (n)
   "Search forwards through input history for match for current input.