]> git.eshelyaron.com Git - emacs.git/commitdiff
Comint: new user option for C-c M-r and C-c M-s
authorPhilipp Stephani <phst@google.com>
Wed, 26 Oct 2016 22:28:34 +0000 (00:28 +0200)
committerPhilipp Stephani <phst@google.com>
Tue, 22 Nov 2016 12:49:17 +0000 (13:49 +0100)
This option allows the user to specify where to place point after these
commands.

* comint.el (comint-move-point-for-matching-input): New user option.
(comint-previous-matching-input-from-input): Use user option.

etc/NEWS
lisp/comint.el

index 02e93e4f9fbb99b48f258ee730a5d9fb007ce44c..a65e2625214c72785d7d92b09ecdb59937ecc4d0 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -337,6 +337,12 @@ whose content matches a regexp; bound to '% g'.
 
 *** Support for opening links to man pages in Man or WoMan mode.
 
+** Comint
+
+---
+*** New user option 'comint-move-point-for-matching-input' to control
+where to place point after C-c M-r and C-c M-s.
+
 ** Compilation mode
 
 ---
index 919265fc33251ff955f29259c70984059fb6f8c2..b9c65b0d51294d9dcdf41e92a7568b62fce612ef 100644 (file)
@@ -283,6 +283,17 @@ This variable is buffer-local in all Comint buffers."
                 (const others))
   :group 'comint)
 
+(defcustom comint-move-point-for-matching-input 'after-input
+  "Controls where to place point after matching input.
+\\<comint-mode-map>This influences the commands \\[comint-previous-matching-input-from-input] and \\[comint-next-matching-input-from-input].
+If `after-input', point will be positioned after the input typed
+by the user, but before the rest of the history entry that has
+been inserted.  If `end-of-line', point will be positioned at the
+end of the current logical (not visual) line after insertion."
+  :type '(radio (const :tag "Stay after input" after-input)
+                (const :tag "Move to end of line" end-of-line))
+  :group 'comint)
+
 (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
 
 (defcustom comint-scroll-show-maximum-output t
@@ -1222,7 +1233,8 @@ If N is negative, search forwards for the -Nth following match."
     (comint-previous-matching-input
      (concat "^" (regexp-quote comint-matching-input-from-input-string))
      n)
-    (goto-char opoint)))
+    (when (eq comint-move-point-for-matching-input 'after-input)
+      (goto-char opoint))))
 
 (defun comint-next-matching-input-from-input (n)
   "Search forwards through input history for match for current input.