bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55883: [PATCH] Update X Primary Selection with active regions


From: Eli Zaretskii
Subject: bug#55883: [PATCH] Update X Primary Selection with active regions
Date: Sat, 11 Jun 2022 10:53:14 +0300

> From: Duncan Findlay <duncf@google.com>
> Date: Fri, 10 Jun 2022 18:59:47 -0700
> Cc: 55883@debbugs.gnu.org
> 
> Attached is an updated version that I believe addresses all the
> concerns raised on the mailing list.
> 
> Given the changes don't split so cleanly into two any more, I've
> combined them into a single patch.

Thanks.  A few minor issues with this version:

> * src/keyboard.c (command_loop_1): Check terminal parameter
> `display-selections-p' for text terminals when deciding whether
> to update primary selection.
> * lisp/frame.el (display-selections-p): Return terminal
> parameter `display-selections-p' to indicate selection support.
> * lisp/term/xterm.el (xterm-select-active-regions): New
> defcustom.  (xterm--init-activate-set-selection): Set
> the `display-selections-p' terminal parameter.

Please mention the bug number in the log message.

> +*** Select active regions with xterm selection support.
> +On terminals with xterm setSelection support, the active region may be
> +saved to the X primary selection, following the
> +'select-active-regions' variable. This support is enabled with
> +'xterm-select-active-regions'.  ^^

Our convention is to leave 2 spaces between sentences in
documentation.

> --- 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)
> +     ((terminal-parameter display 'display-selections-p)
> +      t)

This should test xterm--set-selection parameter.

> +(defcustom xterm-select-active-regions nil
> +  "If non-nil, on a terminal with setSelection support, Emacs will
> +also update the primary selection with the active region, based
> +on the value of `select-active-regions'."

The first line of a doc string should be a complete sentence.  So this
doc strings should be reworded to comply with this convention.  For
example:

    "If non-nil, update PRIMARY X selection on text-mode frames.
  On a text-mode terminal that supports setSelection command, if
  this variable is non-nil, Emacs will set the PRIMARY selection
  from the active region, according to `select-active-regions'."

> @@ -946,7 +953,9 @@ 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)
> +  (when xterm-select-active-regions
> +    (set-terminal-parameter nil 'display-selections-p t)))

I see no reason to introduce a new terminal parameter with non-trivial
semantics.  Moreover, this consults the value of
xterm-select-active-regions only once, so if the user later modifies
the value of the option, the terminal parameter will stay at its stale
value.

I think the code should instead check the value of
xterm-select-active-regions in keyboard.c, where it decides whether to
set PRIMARY.  (Let me know if you need guidance for how to reference a
Lisp variable from C.)

> @@ -1569,7 +1570,8 @@ 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 (Fwindow_system (Qnil)) ||
> +                !NILP (Fterminal_parameter (Qnil, Qdisplay_selections_p)))

This should be looking at the xterm--set-selection parameter instead,
and test the value of xterm-select-active-regions in addition, as
described above.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]