]> git.eshelyaron.com Git - emacs.git/commitdiff
New user option to disable deleting current input in comint mouse-2
authorVisuwesh <visuweshm@gmail.com>
Sat, 23 Jul 2022 07:15:24 +0000 (09:15 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 23 Jul 2022 07:15:24 +0000 (09:15 +0200)
* etc/NEWS: Announce the user option (bug#56646).
* lisp/comint.el (comint-delete-old-input): New user option to disable
deleting current input when insert an old input using mouse-2.
(comint-insert-input): Use it.

etc/NEWS
lisp/comint.el

index a143550f0366dc3080fc958c50851cdce6c55c51..666699e8c6684ea4afd5a865f5df5855c385f98d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -996,6 +996,11 @@ The user option 'comint-terminfo-terminal' and the variable
 'system-uses-terminfo' can now be set as connection-local variables to
 change the terminal used on a remote host.
 
+---
+*** New user option 'comint-delete-old-input'
+When set to nil, this prevents comint from deleting the current input
+when inserting previous input using '<mouse-2>'.
+
 ** Mwheel
 
 ---
index d52623c00ae9a1d9fa35fbe2b6f3a68d31f138bd..3ed04f098c79e6af07f8a7b3112f4d5ab9569d43 100644 (file)
@@ -905,6 +905,12 @@ series of processes in the same Comint buffer.  The hook
   "Return non-nil if STR contains non-whitespace syntax."
   (not (string-match "\\`\\s *\\'" str)))
 
+(defcustom comint-delete-old-input t
+  "When non-nil, delete old input on inserting previous input with \\<comint-mode-map>\\[comint-insert-input]."
+  :type 'boolean
+  :group 'comint
+  :version "29.1")
+
 (defun comint-insert-input (event)
   "In a Comint buffer, set the current input to the previous input at point.
 If there is no previous input at point, run the command specified
@@ -936,10 +942,11 @@ by the global keymap (usually `mouse-yank-at-click')."
         ;; Otherwise, insert the previous input.
         (goto-char (point-max))
         ;; First delete any old unsent input at the end
-        (delete-region
-         (or (marker-position comint-accum-marker)
-             (process-mark (get-buffer-process (current-buffer))))
-         (point))
+        (when comint-delete-old-input
+          (delete-region
+           (or (marker-position comint-accum-marker)
+               (process-mark (get-buffer-process (current-buffer))))
+           (point)))
         ;; Insert the input at point
         (insert input)))))
 \f