unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Duncan Findlay via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 55883@debbugs.gnu.org
Subject: bug#55883: [PATCH] Update X Primary Selection with active regions
Date: Mon, 13 Jun 2022 23:36:13 -0700	[thread overview]
Message-ID: <CAPANw+Mrgkz_yxcYy2ZwxtSoasia-z7xpRdmeCC6aApRNwdGFg@mail.gmail.com> (raw)
In-Reply-To: <8335gbzled.fsf@gnu.org>

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

On Sat, Jun 11, 2022 at 12:53 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > 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.

Done.

> > +*** 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.

Done.

> > --- 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.

OK, so the goal is to check the xterm--set-selection terminal
parameter and variable xterm-select-active-regions before selecting
the active region in deactivate-mark in simple.el.

We could do this in display-selections-p, but given that these
variables are not obviously related to display-selections-p, it seems
to me we probably want to do this check in deactivate-mark instead.
Does that seem reasonable to you?

> > +(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'."

Done, thanks.

> > @@ -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.)

This seems to work -- is there a better way?

!NILP (SYMBOL_VAL (XSYMBOL (Qxterm_select_active_regions)))

> > @@ -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.

Done.

I've also addressed Po's comments about long conditionals.

Thanks

Duncan

[-- Attachment #2: 0001-Support-select-active-regions-with-xterm.patch --]
[-- Type: application/x-patch, Size: 4230 bytes --]

  parent reply	other threads:[~2022-06-14  6:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPANw+Mrgkz_yxcYy2ZwxtSoasia-z7xpRdmeCC6aApRNwdGFg@mail.gmail.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=55883@debbugs.gnu.org \
    --cc=duncf@google.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).