diff options
| author | Visuwesh | 2022-07-23 09:15:24 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-07-23 09:15:24 +0200 |
| commit | e5de76b72e75aaa04d83331ebc4d72dadd7eed77 (patch) | |
| tree | df4aefd780e606e5301473de9ef0765c337f9554 | |
| parent | 97abe8511a829861f6efb865209ac2dd0e7ae129 (diff) | |
| download | emacs-e5de76b72e75aaa04d83331ebc4d72dadd7eed77.tar.gz emacs-e5de76b72e75aaa04d83331ebc4d72dadd7eed77.zip | |
New user option to disable deleting current input in comint mouse-2
* 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.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/comint.el | 15 |
2 files changed, 16 insertions, 4 deletions
| @@ -996,6 +996,11 @@ The user option 'comint-terminfo-terminal' and the variable | |||
| 996 | 'system-uses-terminfo' can now be set as connection-local variables to | 996 | 'system-uses-terminfo' can now be set as connection-local variables to |
| 997 | change the terminal used on a remote host. | 997 | change the terminal used on a remote host. |
| 998 | 998 | ||
| 999 | --- | ||
| 1000 | *** New user option 'comint-delete-old-input' | ||
| 1001 | When set to nil, this prevents comint from deleting the current input | ||
| 1002 | when inserting previous input using '<mouse-2>'. | ||
| 1003 | |||
| 999 | ** Mwheel | 1004 | ** Mwheel |
| 1000 | 1005 | ||
| 1001 | --- | 1006 | --- |
diff --git a/lisp/comint.el b/lisp/comint.el index d52623c00ae..3ed04f098c7 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -905,6 +905,12 @@ series of processes in the same Comint buffer. The hook | |||
| 905 | "Return non-nil if STR contains non-whitespace syntax." | 905 | "Return non-nil if STR contains non-whitespace syntax." |
| 906 | (not (string-match "\\`\\s *\\'" str))) | 906 | (not (string-match "\\`\\s *\\'" str))) |
| 907 | 907 | ||
| 908 | (defcustom comint-delete-old-input t | ||
| 909 | "When non-nil, delete old input on inserting previous input with \\<comint-mode-map>\\[comint-insert-input]." | ||
| 910 | :type 'boolean | ||
| 911 | :group 'comint | ||
| 912 | :version "29.1") | ||
| 913 | |||
| 908 | (defun comint-insert-input (event) | 914 | (defun comint-insert-input (event) |
| 909 | "In a Comint buffer, set the current input to the previous input at point. | 915 | "In a Comint buffer, set the current input to the previous input at point. |
| 910 | If there is no previous input at point, run the command specified | 916 | 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')." | |||
| 936 | ;; Otherwise, insert the previous input. | 942 | ;; Otherwise, insert the previous input. |
| 937 | (goto-char (point-max)) | 943 | (goto-char (point-max)) |
| 938 | ;; First delete any old unsent input at the end | 944 | ;; First delete any old unsent input at the end |
| 939 | (delete-region | 945 | (when comint-delete-old-input |
| 940 | (or (marker-position comint-accum-marker) | 946 | (delete-region |
| 941 | (process-mark (get-buffer-process (current-buffer)))) | 947 | (or (marker-position comint-accum-marker) |
| 942 | (point)) | 948 | (process-mark (get-buffer-process (current-buffer)))) |
| 949 | (point))) | ||
| 943 | ;; Insert the input at point | 950 | ;; Insert the input at point |
| 944 | (insert input))))) | 951 | (insert input))))) |
| 945 | 952 | ||