From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Duncan Findlay Newsgroups: gmane.emacs.devel Subject: Re: Set X primary selection with Emacs in xterm Date: Tue, 14 Jun 2022 19:43:21 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11729"; mail-complaints-to="usenet@ciao.gmane.io" To: Duncan Findlay , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jun 15 14:11:34 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 1o1Rrx-0002tj-WF for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jun 2022 14:11:34 +0200 Original-Received: from localhost ([::1]:43654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1Rrv-0001El-6Z for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jun 2022 08:11:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1J0l-0000zO-73 for emacs-devel@gnu.org; Tue, 14 Jun 2022 22:44:03 -0400 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:41912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1J0j-0007xW-Kf for emacs-devel@gnu.org; Tue, 14 Jun 2022 22:44:02 -0400 Original-Received: by mail-wr1-x436.google.com with SMTP id k19so13469836wrd.8 for ; Tue, 14 Jun 2022 19:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=GPWAq/yWW7TEOibqUAP923VNfNEufGd4p6ZDNuiLlWw=; b=oyyVO2z28q43xTG8ShhKyEDcouOAdyxzVtyD5k2lfLeLiB+Z6omnE1JFAKUdMZ0ffn I+In7D8QyGs8orG4ed5A0xc04EJcMjFbSRIaVFCPIU5lBG80stCY02GlQNQTH+TePm20 mtyRDQQv7o3H/yQ1ybyHAMz0em7U1knG+zsykpR2bGSmu+fU6jMDsMhXg0WvHEB1MK03 wD88/GqssIczAs2eG7QYaG53dAfppUayMuhLlzhjpOcjy8eyafp4txJLEBZq034tbBtf zXSe/CO0z5uWLT6LFV1oiEXJfCr9UHoNWppfgiMHESKj8jWC13C34620zUye4WxnaXPN euRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=GPWAq/yWW7TEOibqUAP923VNfNEufGd4p6ZDNuiLlWw=; b=I2b5M8L0vDDktlbNSxo+YLq3GPnRtF0EK2tSjPZHAg7AWhUG7haH4SBg9enQrhJGXm nyooe42NardWN6POLCtHKXK4NqgMRk/PUs8mpzyGQMHvv5GIFW1/Wvl6w0rdfM13bqnV OILtSxXH9osjVu22gu1qa1G3BTrr7FDOr9IKfWJfFclRUPqm5ZIHKETQdftZYUd48LTc qDBsPupJkMi8w+WT2tc+DOaJrKmRdo0geqRt3zcX9WXkE/ZVe73kcprLie734dqtVfG2 XQ3TN6cl6N8/5YKyOuJ/VIOlDBu2E11bdYwUHV67AEKULLTWoupJJrHLGNDlcFAceq6a 51oQ== X-Gm-Message-State: AJIora/zeZLnmPrF8bJiFljGirVupAO/BVT9mDPdI/9ezWUI8ZpEn+TV p23mqJWJOcZA7IuMYlzVdV2Ufz6yga/eFy8XG1/fog== X-Google-Smtp-Source: AGRyM1tuIp324DuXECjuWa7vdFS73m6NJPgXbv60w6c1c3xIJMaq74VX5IO7HY5fokg+3gZsCpgLUIRhmiACis9QO54= X-Received: by 2002:a05:6000:1c1b:b0:215:840a:3fc4 with SMTP id ba27-20020a0560001c1b00b00215840a3fc4mr7559356wrb.30.1655261039284; Tue, 14 Jun 2022 19:43:59 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=duncf@google.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -175 X-Spam_score: -17.6 X-Spam_bar: ----------------- X-Spam_report: (-17.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 15 Jun 2022 08:06:23 -0400 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:291204 Archived-At: On Sat, Jun 11, 2022 at 9:16 AM Jean Louis wrote: > > > > Similarly, if I select text with mark and keyboard (or mouse with > > > > xterm-mouse-mode), I'd like it to update my local X's primary > > > > selection so I can middle-click to paste it elsewhere. I have two > > > > patches attached that got this working for me. > > > > > > For me your explained situation works without patches. I have the > > > above settings. But I may miss something as you mention > > > xterm-mouse-mode which I am not even using it ever. On my side it > > > works. > > > > Sorry, I should have been more precise. > > > > I would like the primary selection to be updated with the contents of > > the region, as described here: > > https://www.gnu.org/software/emacs/manual/html_node/emacs/Primary-Selection.html > > > > This requires `select-active-regions' to be non-nil. Do you have this > > set in your configuration? > > Yes, it is T in my configuration. > > When I select region, I can use second (among three) mouse button to > insert selection into XTerm. Oh, I think I see what you mean. With your configuration I can select text in emacs with mouse and paste with mouse into emacs or other programs, but this is handled entirely by xterm. AIUI emacs is not made aware of the selection and has no control over this. If I make an active region with the keyboard (e.g. C-SPC, C-p), the text shows as highlighted in emacs, but it does not update my primary selection buffer unless I kill it, and it cannot be pasted with the middle mouse button until it's killed. (Text highlighted by emacs is a different color than text highlighted by xterm with my current config; I'm not sure if this is default.) My patch fixes this, though it's a pretty minor issue IMO. The bigger benefit of my patch comes with xterm-mouse-mode enabled. In this mode, most mouse events are passed through to Emacs, and are not handled by Xterm itself. Without my patch, selecting text with the mouse highlights it, but it doesn't update the primary selection and can't be pasted with middle click. With my patch, the selected text can be pasted into other programs with middle click. Pasting from primary selection back into Emacs with middle-click requires xterm getSelection support (haven't tried this yet) or Shift-MiddleClick (handled by XTerm itself), though this is unaffected by my change. With `xterm-select-active-regions' set to nil (default), my patch will have no effect. Thanks Duncan