unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56646: User option to disable deleting current input when using mouse-2 in comint
@ 2022-07-19 16:34 Visuwesh
  2022-07-23  7:15 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Visuwesh @ 2022-07-19 16:34 UTC (permalink / raw)
  To: 56646

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

Tags: patch

mouse-2 in comint can be used to reinsert old inputs however, it
unconditionally deletes the current (unsent) input.  This makes it
impossible to use the mouse-2 command to further act on the previous
input.  For example, consider you're doing something like this in a
Python REPL:

    >>> foo()
    ... some output... you verify that it is okay
    >>> bar(|

With the point being |, you say mouse-2 when the pointer is over foo().
Currently comint-mode makes the last prompt become

    >>> foo()

which is not so helpful.  Attached patch adds a new user option to turn
off this deletion so you may get...

    >>> bar(foo()|

instead, which, IMHO, is more useful.


In GNU Emacs 29.0.50 (build 22, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2022-07-17 built on astatine
Repository revision: 5db4ec20fe4b428e15aa53208c9a9bfb037c0f30
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
 --without-xaw3d --without-gconf --without-libsystemd --without-cairo'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-user-option-to-disable-deleting-current-input-in.patch --]
[-- Type: text/patch, Size: 2341 bytes --]

From 6d2631be4582b38b1bf4eb78d3b8bbd6c687b0d6 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Tue, 19 Jul 2022 21:56:02 +0530
Subject: [PATCH] New user option to disable deleting current input in comint
 mouse-2

* 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: Announce the user option.
---
 etc/NEWS       |  5 +++++
 lisp/comint.el | 15 +++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 604e30ce25..213b358cc2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -990,6 +990,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
 
 ---
diff --git a/lisp/comint.el b/lisp/comint.el
index d52623c00a..3ed04f098c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -905,6 +905,12 @@ comint-nonblank-p
   "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 @@ comint-insert-input
         ;; 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
-- 
2.35.1


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

* bug#56646: User option to disable deleting current input when using mouse-2 in comint
  2022-07-19 16:34 bug#56646: User option to disable deleting current input when using mouse-2 in comint Visuwesh
@ 2022-07-23  7:15 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  7:15 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56646

Visuwesh <visuweshm@gmail.com> writes:

> which is not so helpful.  Attached patch adds a new user option to turn
> off this deletion so you may get...
>
>     >>> bar(foo()|
>
> instead, which, IMHO, is more useful.

Makes sense to me.  Pushed to Emacs 29.







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

end of thread, other threads:[~2022-07-23  7:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 16:34 bug#56646: User option to disable deleting current input when using mouse-2 in comint Visuwesh
2022-07-23  7:15 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).