From 25bb187911e0444c5e1618650a061f0be317bee7 Mon Sep 17 00:00:00 2001 From: Duncan Findlay Date: Thu, 2 Jun 2022 20:23:44 -0700 Subject: [PATCH 2/2] Support `select-active-regions' with xterm This allows Emacs to save the active region to the user's primary selection on supported terminals. This behavior is controlled by the existing `select-active-regions' variable. * lisp/frame.el (display-selections-p): For text terminals, return terminal parameter `display-selections-p` to indicate selection support. * lisp/term/xterm.el (xterm--init-activate-set-selection): Set the `display-selections-p` terminal parameter. --- etc/NEWS | 5 +++++ lisp/frame.el | 2 ++ lisp/term/xterm.el | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index cd4b1b06ec..17c98b772c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -477,6 +477,11 @@ This is in addition to previously-supported ways of discovering 24-bit color support: either via the "RGB" or "setf24" capabilities, or if the 'COLORTERM' environment variable is set to the value "truecolor". +*** Primary selection of active regions with xterm setSelection support. +On supported terminals, the active region may be saved to the X +primary selection. This behavior is controlled by the +'select-active-regions' variable. + ** ERT +++ diff --git a/lisp/frame.el b/lisp/frame.el index 27f99fb7d2..e926dff201 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2164,6 +2164,8 @@ display-selections-p (not (null dos-windows-version)))) ((memq frame-type '(x w32 ns pgtk)) t) + ((eq frame-type t) + (terminal-parameter display 'display-selections-p)) (t nil)))) diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index a7e257f41c..f6add0fbf2 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -946,7 +946,8 @@ xterm--init-activate-get-selection (defun xterm--init-activate-set-selection () "Terminal initialization for `gui-set-selection'." - (set-terminal-parameter nil 'xterm--set-selection t)) + (set-terminal-parameter nil 'xterm--set-selection t) + (set-terminal-parameter nil 'display-selections-p t)) (defun xterm--init-frame-title () "Terminal initialization for XTerm frame titles." -- 2.36.1.476.g0c4daa206d-goog