From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KuITOHfTcGPKiAAAbAwnHQ (envelope-from ) for ; Sun, 13 Nov 2022 12:22:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aIdmNnfTcGODZAAAG6o9tA (envelope-from ) for ; Sun, 13 Nov 2022 12:22:31 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9E282D99 for ; Sun, 13 Nov 2022 12:22:31 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouAlz-0001q6-Cq; Sun, 13 Nov 2022 06:03:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouAly-0001py-0w for emacs-orgmode@gnu.org; Sun, 13 Nov 2022 06:03:34 -0500 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouAlw-0004qD-HO for emacs-orgmode@gnu.org; Sun, 13 Nov 2022 06:03:33 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ouAls-0005MA-Nq for emacs-orgmode@gnu.org; Sun, 13 Nov 2022 12:03:28 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: Getting X selection reliably (Re: idea for capture anywhere in x) Date: Sun, 13 Nov 2022 18:03:22 +0700 Message-ID: References: <87tuw31iub.fsf@mm.st> <87r0zelo7e.fsf@posteo.net> <875yg7qiyb.fsf@localhost> <875yfj8nf7.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US In-Reply-To: <875yfj8nf7.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668338551; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3ysWn9ICtAnvpLFmE3J2nhiubBoBHMCYR6K+D6BvMoA=; b=g5+1sf+TSCIZ18aewyuvJOMo3NxpFPAkLEAF4Dr69m0f2BhMwtjx68HWRObvfFXD187qJx gLRY+EcFfh4PKysPt3GL2b3Y4qgq8GXt6NzuIsmlyqzeTQ1Ssh4X5v6ovFOFHk52yUXQvN fwNzcd8UFCzGHqM0upEXnhjRPvqB8lL4Jkdrsvlf1EEnyTql4KFbp5B7eZ7OVF3Yx/d6P+ M6QlUeRBqkXlxrMom/c1kDSPLGzzMP06d8KWk8OQeCdatPMmMtjx6EiNFvQiyZPMCXczQg AKmtxiE1XvQ43dCLvz6N4vWkAMYPL0IKYN06vHK1QbTi3Dl2Hri7wT8wRm4bgg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668338551; a=rsa-sha256; cv=none; b=WNyFR4QQzF44GuhjjwgHU7nlEMNXI31oI8S2hz0g+xcJWOLEta5kUIfcXH9undBLz6Ido8 c4ezcBJwRNcM8bCgf7IEH9m5YAy9N3efrdYXt6q26d9FeJzXrhu9AiC3kOYWe99ts2i6Er cB8DuNVbgTo5sRDN8CjVh8QxKF8RGjW3JmCmpcuKPDllAu8f7IPTNADLIsW4lWsEAa80pZ A7DWj9Kv9TOhl/DYWpGAO3m6oLqTxV6FhZo8RU1+chEsvKPPTmKzVqlNjxgpnTDDlyH8FQ GKXUDV2wsOCQ1oLzwygy4TFSMV7TEl4bCu5YsyHAd1GLk0TI1XvF+KyLWDct9g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 4.15 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9E282D99 X-Spam-Score: 4.15 X-Migadu-Scanner: scn1.migadu.com X-TUID: RX2on9fZTql1 On 13/11/2022 11:54, Ihor Radchenko wrote: > Max Nikulin writes: >> On 26/10/2022 11:58, Ihor Radchenko wrote: >>> >>> Yes. From org-capture-templates docstring: >>> >>> %x Content of the X clipboard. >> >> Ihor, I am afraid there are a couple of pitfalls with "%x" for Samuel >> since he prefers to keep Emacs hidden so can not check result. >> >> 1. If something goes wrong, e.g. some application does not put >> highlighted text to PRIMARY selection then wrong source (CLIPBOARD) or >> empty string may be silently captured. I would prefer explicit source >> however it will not protect against stale selection from the same source. >> >> Simulate empty selection: >> echo | xsel -bi ; echo | xsel -i ; killall xsel > > I am unsure what can be done here. AFAIU, Org just follows the %x > description. Nothing wrong on Org side. > > The best we can do is alternative %?? that will do something more > reliable. But I am unsure what it can be. Depending of particular capture template (even with :immediate-finish t) empty selection may or may not be an error. In Samuel's case it is an error. Unfortunately, while the template is processed, signaled errors are caught and their text is inserted into the text. That is why in my example I put checks outside of `org-capture'. We may: - Add a capture template option that allows errors to pass through to the caller. Then a user may add %(...) expression with all necessary checks. - Add a warning note to "%x" or :immediate-finish docs to make users aware of possible pitfall. >> 2. Jean pointed out that Emacs ignores X selection if it does not have >> an X frame. It was almost buried in the haystack of "SQL instead of Org" >> noise. It happens if Emacs is running as a daemon. I am unsure which way >> Samuel starts Emacs (xinit, systemd user session, systemd socket >> activation, manually, etc.) > > May we modify org-get-x-clipboard adding > (server-select-display (getenv \"DISPLAY\")) ? > Will it be enough? It will work for most of users, however sometimes it is incorrect. There are a number of options that should have higher priority than emacs server DISPLAY environment - emacsclient -display command line option, - emacsclient process DISPLAY environment, - emacs -display server argument. I have no idea how to get "emacs -display" argument and I need to look into emacsclient source and server.el to figure out which way client's display argument is passed to the server process.