From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#55883: [PATCH] Update X Primary Selection with active regions Date: Sat, 11 Jun 2022 10:53:14 +0300 Message-ID: <8335gbzled.fsf@gnu.org> References: <834k0t104u.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24741"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55883@debbugs.gnu.org To: Duncan Findlay Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 11 09:54:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzvwp-0006D7-Vp for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 09:54:20 +0200 Original-Received: from localhost ([::1]:56300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzvwo-0000zO-Jv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 03:54:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzvwZ-0000p2-Ex for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 03:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzvwZ-0000mU-6N for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 03:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nzvwZ-0003CR-4O for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 03:54:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jun 2022 07:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55883 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 55883-submit@debbugs.gnu.org id=B55883.165493400812229 (code B ref 55883); Sat, 11 Jun 2022 07:54:03 +0000 Original-Received: (at 55883) by debbugs.gnu.org; 11 Jun 2022 07:53:28 +0000 Original-Received: from localhost ([127.0.0.1]:51791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nzvvz-0003BA-VS for submit@debbugs.gnu.org; Sat, 11 Jun 2022 03:53:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nzvvx-0003Au-RF for 55883@debbugs.gnu.org; Sat, 11 Jun 2022 03:53:26 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzvvs-0000hr-DL; Sat, 11 Jun 2022 03:53:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=oyoB8vdiOZmsDkRuckfPiLVMMEQpaz4TA/rHdO5XwHw=; b=fpceIn+asUZa P4YgaEp3jCt6V0lCf4AYkobPrLc4rQ1UxN5+PcfjIdCI53E/LHBhZkIErUfWVSjhg9PV5t3Jfat/t rIP9vNAcp6Al9ubsHjWJqFGJqYUb5dVDUDgE1eTgiOuWgs45ZuMMPr8eZq1dRhZzNfpzCdfFS76NS e7UfW81Z3OKvOOlY+UsLkeA+8Pgvp6Rqmel6Q7hvxSIajlcvifFKnpfBNPm6//ZA1bd0IWvzEXfmh 9L5x869WPQj0JL3Evu7F6XcrR/BVwccjWxXfc9pc8ANIMKUSvy0eStegR1eVQtVfBaT/j4TdbQS99 l5Sr8QK5IBzxnzAnoWLSlw==; Original-Received: from [87.69.77.57] (port=3823 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzvvr-0005A6-Ji; Sat, 11 Jun 2022 03:53:20 -0400 In-Reply-To: (message from Duncan Findlay on Fri, 10 Jun 2022 18:59:47 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234252 Archived-At: > From: Duncan Findlay > 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.