diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-03 09:45:32 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-03 09:47:18 +0200 |
commit | e1c893f4a3ae005a76f34d2393fccb9a219abed1 (patch) | |
tree | 343e717f91aeb73831fcb1b7c2a3f5670dc1cd00 | |
parent | 4bdae17a74f1b6ea6b81066ce31f7ff5b45d3379 (diff) | |
download | emacs-e1c893f4a3ae005a76f34d2393fccb9a219abed1.tar.gz |
Allow not putting pasted text onto the kill ring under xterm
* lisp/term/xterm.el (xterm-paste): Don't put pasted text onto the
kill ring (bug#28868).
(xterm-store-paste-on-kill-ring): New user option.
-rw-r--r-- | etc/NEWS | 7 | ||||
-rw-r--r-- | lisp/term/xterm.el | 19 |
2 files changed, 23 insertions, 3 deletions
@@ -3152,6 +3152,13 @@ It used to be mapped to 'print' but we couldn't find a terminal that uses this sequence for any kind of 'Print' key. This makes the Menu key (see https://en.wikipedia.org/wiki/Menu_key) work for `context-menu-mode` in Xterm. + +--- +** New user option 'xterm-store-paste-on-kill-ring'. +If non-nil (the default), Emacs pushes pasted text onto the kill ring +(if using an xterm-like terminal that supports bracketed paste). +Setting this to nil inhibits that. + * Incompatible Lisp Changes in Emacs 28.1 diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 43a89ff31f7..de5f000089a 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -73,6 +73,13 @@ string bytes that can be copied is 3/4 of this value." :version "27.1" :type 'boolean) +(defcustom xterm-store-paste-on-kill-ring t + "If non-nil, pasting text into Emacs will put the text onto the kill ring. +This user option is only heeded when using a terminal using xterm +capabilities, and only when that terminal understands bracketed paste." + :version "28.1" + :type 'boolean) + (defconst xterm-paste-ending-sequence "\e[201~" "Characters sent by the terminal to end a bracketed paste.") @@ -100,9 +107,15 @@ Return the pasted text as a string." (interactive "e") (unless (eq (car-safe event) 'xterm-paste) (error "xterm-paste must be found to xterm-paste event")) - (let* ((pasted-text (nth 1 event)) - (interprogram-paste-function (lambda () pasted-text))) - (yank))) + (let ((pasted-text (nth 1 event))) + (if xterm-store-paste-on-kill-ring + ;; Put the text onto the kill ring and then insert it into the + ;; buffer. + (let ((interprogram-paste-function (lambda () pasted-text))) + (yank)) + ;; Insert the text without putting it onto the kill ring. + (push-mark) + (insert-for-yank pasted-text)))) ;; Put xterm-paste itself in global-map because, after translation, ;; it's just a normal input event. |