all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#55883: [PATCH] Update X Primary Selection with active regions
@ 2022-06-10  6:18 Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-06-10  6:52 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-06-10  6:18 UTC (permalink / raw)
  To: 55883

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

Severity: wishlist
Tags: patch

Attached are two patches to allow users that use xterm's OSC 52
clipboard support to have their primary selection updated with the
active region, to better match the behavior of running Emacs in X
locally.

This behavior is enabled automatically for supported terminals, and is
controlled by the existing `select-active-regions' variable.

Previous discussion:
https://lists.gnu.org/archive/html/emacs-devel/2022-06/msg00126.html

This should be covered by a corporate copyright assignment on file.

[-- Attachment #2: 0001-Use-display-selections-p-for-selecting-active-region.patch --]
[-- Type: text/x-patch, Size: 1457 bytes --]

From 5dee5a44fd0d3ad57ba7e40fd5b0542d70160c14 Mon Sep 17 00:00:00 2001
From: Duncan Findlay <duncf@google.com>
Date: Fri, 20 May 2022 00:17:51 -0700
Subject: [PATCH 1/2] Use `display-selections-p' for selecting active region

`display-selections-p' is documented as the preferred way to determine
capabilities, over `window-system'.  This allows supported text
terminals to indicate support for these selections.

* src/keyboard.c (command_loop_1): Replace call to `window-system'
with `display-selections-p' when deciding whether to update primary
selection.
---
 src/keyboard.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 55d710ed62..dc3c37e4d8 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1569,7 +1569,7 @@ command_loop_1 (void)
 	    {
 	      /* Even if not deactivating the mark, set PRIMARY if
 		 `select-active-regions' is non-nil.  */
-	      if (!NILP (Fwindow_system (Qnil))
+	      if (!NILP (call0 (Qdisplay_selections_p))
 		  /* Even if mark_active is non-nil, the actual buffer
 		     marker may not have been set yet (Bug#7044).  */
 		  && XMARKER (BVAR (current_buffer, mark))->buffer
@@ -12162,6 +12162,7 @@ syms_of_keyboard (void)
 
   DEFSYM (Qpolling_period, "polling-period");
 
+  DEFSYM (Qdisplay_selections_p, "display-selections-p");
   DEFSYM (Qgui_set_selection, "gui-set-selection");
 
   /* The primary selection.  */
-- 
2.36.1.476.g0c4daa206d-goog


[-- Attachment #3: 0002-Support-select-active-regions-with-xterm.patch --]
[-- Type: text/x-patch, Size: 2318 bytes --]

From 25bb187911e0444c5e1618650a061f0be317bee7 Mon Sep 17 00:00:00 2001
From: Duncan Findlay <duncf@google.com>
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


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

end of thread, other threads:[~2022-06-22 15:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-10  6:18 bug#55883: [PATCH] Update X Primary Selection with active regions Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-10  6:52 ` Eli Zaretskii
2022-06-11  1:59   ` Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-11  7:53     ` Eli Zaretskii
2022-06-14  5:57       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-14  6:36       ` Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-14 12:15         ` Eli Zaretskii
2022-06-15  2:01           ` Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-15 16:51             ` Eli Zaretskii
2022-06-18 11:13               ` Eli Zaretskii
2022-06-18 15:15                 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-18 16:09                   ` Eli Zaretskii
2022-06-22  1:58                     ` Duncan Findlay via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-22 13:02                       ` Eli Zaretskii
2022-06-22 15:37                       ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.