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.devel Subject: Re: Set X primary selection with Emacs in xterm Date: Fri, 10 Jun 2022 22:38:50 +0300 Message-ID: <83ilp8z4tx.fsf@gnu.org> References: <83y1yecjzx.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15035"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Duncan Findlay Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 10 21:39:52 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nzkU2-0003fT-9S for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Jun 2022 21:39:50 +0200 Original-Received: from localhost ([::1]:55770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzkU0-0003I0-Qp for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Jun 2022 15:39:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzkT5-00029p-Tw for emacs-devel@gnu.org; Fri, 10 Jun 2022 15:38:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:35714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzkT5-0006pR-JB; Fri, 10 Jun 2022 15:38:51 -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=ekBnRhf7LdbK/W2cxm5ERJwhcXajV0+MAelcNMC01Tc=; b=qOed1zz/L/vr 6B/BVtXGaw5/RiRin8TontR1MKF1tC6MPolBUYDRz+6jyyhNfQA5vvs+Ugb8DxM7EGPFjU3eaeO6Y eSqdNGVLvnGh7qOkfAFeAVda6jix51WXWtX6K1H0IU6kKKPa8c9cVfolb5umbBa01cOhvMr4LPHdA 1UbTnhaRanGbuSUSkFjeCuOfIqCDG0MMPzheBkbByFJ11DhQ9U7vqtmB4YpfJoQDhtkuWam4nx2Ro GkN46BB9R/UqO14QViveKeR0sxEWxL4Gxf/H1kFsXe7dMFimNZge0JZW5I9ohXgWn9beZ846WVtt6 weAhC5lIoS7g7hAHYc0Cbw==; Original-Received: from [87.69.77.57] (port=2869 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 1nzkT5-0008W2-1p; Fri, 10 Jun 2022 15:38:51 -0400 In-Reply-To: (message from Duncan Findlay on Fri, 10 Jun 2022 11:10:50 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291006 Archived-At: > From: Duncan Findlay > Date: Fri, 10 Jun 2022 11:10:50 -0700 > Cc: emacs-devel@gnu.org > > On Thu, Jun 2, 2022 at 11:56 PM Eli Zaretskii wrote: > > > Thanks. I think we should solve this differently. I don't think it's > > a good idea to call arbitrary Lisp from input-processing loop in > > keyboard.c, anymore than we already do (which is already too much, > > IMNSHO), especially if we envision advices for that code. > > > > We should instead modify the condition in command_loop_1 to support > > terminals that can set GUI selections. terminal-parameter is a > > primitive written in C, so command_loop_1 could call it directly (it > > should also pay attention to the defcustom described below). > > I considered this, but given that we're making the same decision in > lisp/simple.el (deactivate-mark) using display-selections-p, the > benefits of sharing an implementation seemed compelling. That's not what bothers me, as I explain above. I don't want us to call more Lisp from the loop that processes keyboard input, if that can be avoided. And in this case, it can be easily avoided. > I see your point about wanting to minimize lisp in the command loop. > Can we just port display-selections-p to C and use it from both > places, or will that break things? I see no need for doing that. display-selections-p is okay in Lisp, as it is called from Lisp programs. > > I think TRT here is to provide a defcustom, so that users could > > disable this feature if it causes more trouble than it's worth. With > > time, perhaps we will collect enough user experience to come up with > > the default value that makes the most sense on most supported systems; > > for now setting the X selection could just be disabled by default. > > My initial resistance to a defcustom was because this feature already > requires xterm support for setSelection, which is already somewhat > rare, and it's already controlled by `select-active-regions'. Without > a new defcustom, it can be turned off with: > (add-hook 'terminal-init-xterm-hook (lambda () (setq > select-active-regions nil))) > > But I accept the feedback that this is not discoverable, and people > want to avoid surprises, so having a defcustom that's off by default > makes sense. I'll upload a new version of the patch to the tracker > shortly. Thanks. > > > + ((and (memq frame-type '(t)) > > > + (eq (terminal-parameter nil 'xterm--set-selection) t)) > > > + t) > > > > This is unnecessarily strict: there should be no need to test > > frame-type, since any frame type could arrange for this parameter when > > it supports selections. > > In practice, are there other frame types? Is it reasonable to set > terminal-parameter for other frame types? Maybe not today, but I'd like this code to be more future-proof. There's no need to test for more things that are absolutely necessary, and testing for the xterm--set-selection parameter is enough in this case, isn't it?