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, 03 Jun 2022 09:57:06 +0300 Message-ID: <83y1yecjzx.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6831"; 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 03 09:03:16 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 1nx1L2-0001fG-EK for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jun 2022 09:03:16 +0200 Original-Received: from localhost ([::1]:34728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nx1L1-0007O3-D9 for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jun 2022 03:03:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nx1Eu-0004fv-J6 for emacs-devel@gnu.org; Fri, 03 Jun 2022 02:56:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nx1Eu-00030N-5U; Fri, 03 Jun 2022 02:56:56 -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=5rwoONVp4y9MfvG8lEuzg8409gKJwqf2Dko0yJa7fbA=; b=bnCi7QmcHFlb LUfAJPwDNn0Z5GGf8sF6svbEKt14Sp7uaBprrmNNdmKgqueFriL0e7dWUUS/3UPlzYgqn5q+XOubj TRiLW0/39SAz7nhTuU7cQHiQ4ToHbZqYrLd1ewrp/jUtFxgyA6e7rlPdnqO4Xfk1H4LK7ILv4pbNA OGpYxIVKUgnw0By1UZ+3FO31MQkzVMbyjcAFzjopSzGw56LSeWbMKLUCwwXwEaBNiNZEYb1+XEou1 0GL4kqdxjSBoA2NTcaW/unO6PJd8sTBXFPHq6J5GPYCjv4r/wjvBssPahZhe0g/KVNnkQjiYECU6e Zd1Z3ArKRcAkJKRIByrYtQ==; Original-Received: from [87.69.77.57] (port=1830 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 1nx1Es-0005BD-LZ; Fri, 03 Jun 2022 02:56:55 -0400 In-Reply-To: (message from Duncan Findlay on Thu, 2 Jun 2022 21:03:49 -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:290600 Archived-At: > From: Duncan Findlay > Date: Thu, 2 Jun 2022 21:03:49 -0700 > > I've attached a patch below to replace the `window-system' check with > `display-selections-p', as that's documented as the preferred way to > do this type of check. It also moves the check to lisp where we can > advise it. 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). > The second patch changes `(display-selections-p)' to return true > under xterm with the setSelection feature enabled. This part is mostly fine, but it should be augmented to resolve the issues below. > I don't know if this second patch can be submitted as is. It may break > existing users. tmux, for example, removes the selection indicator > from OSC 52 codes, so if emacs writes to both CLIPBOARD and PRIMARY > selections, both updates will go to the same buffer on the user's > side. I've filed https://github.com/tmux/tmux/issues/3192 with tmux. I > haven't tested GNU screen. > > This patch will also lead to extra data being sent to the user's > terminal which they may not need or want. It might be wise to only > send OSC 52 codes for primary selection if the user actually has a > primary selection buffer, but I'm not sure the best way to do that. > I'd appreciate some guidance here, or if somebody more experienced > wants to take this on, that'd be most appreciated. 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. > --- a/lisp/frame.el > +++ b/lisp/frame.el > @@ -2164,6 +2164,9 @@ display-selections-p > (not (null dos-windows-version)))) > ((memq frame-type '(x w32 ns pgtk)) > t) > + ((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. Thanks.