From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sEPLBJwujGPEdwAAbAwnHQ (envelope-from ) for ; Sun, 04 Dec 2022 06:22:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id UADEBJwujGOScgEA9RJhRA (envelope-from ) for ; Sun, 04 Dec 2022 06:22:36 +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 A6A083A2BC for ; Sun, 4 Dec 2022 06:22:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1hRi-00041Q-AX; Sun, 04 Dec 2022 00:21:46 -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 1p1hRg-00041F-9M for emacs-orgmode@gnu.org; Sun, 04 Dec 2022 00:21:44 -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 1p1hRe-0006H6-G7 for emacs-orgmode@gnu.org; Sun, 04 Dec 2022 00:21:43 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1p1hRY-0003BQ-4U for emacs-orgmode@gnu.org; Sun, 04 Dec 2022 06:21:36 +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, 4 Dec 2022 12:21:27 +0700 Message-ID: References: <87tuw31iub.fsf@mm.st> <87r0zelo7e.fsf@posteo.net> <875yg7qiyb.fsf@localhost> <875yfj8nf7.fsf@localhost> <877czyguhp.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: <877czyguhp.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: 23 X-Spam_score: 2.3 X-Spam_bar: ++ X-Spam_report: (2.3 / 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.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.265, 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=1670131355; 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=37udQCsr5161Tz75/NNFZMWMzzbkgZaLxjXVlJ0yOsA=; b=JVHrfzsy3akeQusRlFImJzPt4MNeqnEuLgbLc3vrkA5x+Pn3f++I9/YuXtoFqgZZJf0pAm HjyApT/dw09Fysaox79/91YtxOJCU0AtVrbhRLL0UfljpF15/GmGVS6DJssuZo9eF8xFop BLJHgGEyxl0dcZGQMxtR6I3jnRFCRrxzvhK74VgJP1L3eUHbyiOxxwYlOg6IoOZhN3SMU2 s3WQkFoZeiHBb8dMJF5YMDjHO4REyZwv4bkgOapvyYvdgekdsNVT4rJZkRNS5FN7cgm3BP QN8ocnhuhFkCGAi5SR+synL5GMIK71xQMGkTi4a7Aha2ZMkhEobf6bk2+MfDvw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670131355; a=rsa-sha256; cv=none; b=nuVltiZJBIbGbp/c9tpboVss+iRKk8elOnbrOwtRY/uiMiFDm4n6vZUYIXT71RirozlZDT +pswY8C2ORZdoM0+mU5XpjuRx2n/Nk9FebnJiLgBfT39r3Eb0vPmdv3F9EuL5oFk4jCtPK l6IL8xirJEeudsRdmu7EjXv4twjCDKqUT7bq47OKFJLHDDawAsUxmCdpxWCZhzB2MqQ51J cC7RD70OSDBtKOy1nS5X9pHpJCgtLiU/rCB2ZLlV26is8j5LDJkJO+pCxkz/DkRk2oRMXT gsA/SDfM7HyWDQiRS8vxN1oHC9Yurl70AHO0xnj6N3qvZqDA0wwfre4suc//DA== 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: 2.24 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: A6A083A2BC X-Spam-Score: 2.24 X-Migadu-Scanner: scn0.migadu.com X-TUID: GklYeTgZ8zYe On 14/11/2022 09:06, Ihor Radchenko wrote: > Max Nikulin writes: > >> 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'. > > Are you sure? `org-get-x-clipboard' returns nil in case of error and > `org-capture-fill-template' assigns empty string to v-x when no > clipboard value can be obtained. I did not mean elisp error. It is a trouble from the point of view of a user. Their expect to get selection text, but actually useless empty string is inserted. However capturing stale selection (from previous action) is an equally annoying trouble. That is why I believe, the only reliable way is to present result of capture to the user, so if something goes wrong then they may redo selection and capture. Samuel may weight distracting popup vs. a chance of useless capture differently. >> 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. > > I am not very sure what kind of errors you are talking about. AFAIU, we > are talking about scenarios when user explicitly wants one of > PRIMARY/CLIPBOARD/SECONDARY, don't we? I mean a way to propagate an error signaled during capture expansion to the caller of emacsclient, so user may be notified about the issue instead of silently getting "[ERROR ...]" in the captured heading. >> 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. > > Maybe it can be considered an Emacs bug or something to improve on Emacs > side? See Max Nikulin to emacs-devel. How to get DISPLAY of emacsclient? Fri, 25 Nov 2022 22:17:54 +0700. mid:tlqmb3$ic$1@ciao.gmane.io A workaround is emacsclient --display "$DISPLAY" --eval ... Unlike for most of X applications, --display option of emacsclient not only overrides the value of the DISPLAY environment, in addition it causes creation of a hidden frame, so `org-get-x-clipboard' is able to get selection text. I am unsure concerning behavior in other OSes. At least special values display are used internally, users are unlikely familiar with the concept of display. Unfortunately I can not check precise behavior for macOS or Windows. I would not mind to have an option like --force-display that does not require fetching the value from environment (to avoid explicit shell wrapper in .desktop files) or special values on non-X systems. Likely the "--display" hack should be mentioned in the manual and in the templates docscring.