From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iARdJWgkAGInLwAAgWs5BA (envelope-from ) for ; Sun, 06 Feb 2022 20:41:28 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iF0QHmgkAGL/IgEAG6o9tA (envelope-from ) for ; Sun, 06 Feb 2022 20:41:28 +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 231542862E for ; Sun, 6 Feb 2022 20:41:28 +0100 (CET) Received: from localhost ([::1]:46278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnPb-0001jL-79 for larch@yhetil.org; Sun, 06 Feb 2022 14:41:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnP5-0001jB-14 for emacs-orgmode@gnu.org; Sun, 06 Feb 2022 14:40:55 -0500 Received: from [2607:f8b0:4864:20::530] (port=41768 helo=mail-pg1-x530.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnP2-0006Sk-85 for emacs-orgmode@gnu.org; Sun, 06 Feb 2022 14:40:54 -0500 Received: by mail-pg1-x530.google.com with SMTP id f8so9788543pgf.8 for ; Sun, 06 Feb 2022 11:40:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=iChoNBP8FFE1sEUl2UEjAJQV825XQuZsgVOVy1GqLgY=; b=pGYirO/zYsM7ihPpHGZ9Nh7S6UBGxH6/3PfUAv0+tFnmX0GDpxQuuAe5M1i37vtJvX 0zcBi4esvL6deeBoCvkVkXiah4GtRLendYe2zpJikq6XhSvXnhNtfkx9HGD1S5ae1MZe OidMrin+VHxvh7e6jnc9XeJf+y+V75VQM+bdVqL6C5Ju1jmBSffNo2G8/CIcTkxwkqKL QGWVve2ElkvzJ4SiKU/1MhxCCpinrlxpAzqr2YQgloSxbM6uTXll8tgi3tM2IdEASUhf MgKcCWnIt/cY4CdYQwbgBpB3pfQ4KRma2ZkrEXkoZkAiaDirf7O85jGz1geGp9pSrbJj v2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=iChoNBP8FFE1sEUl2UEjAJQV825XQuZsgVOVy1GqLgY=; b=UK4Wg7EEVAnUKDVTfBz58MfEfs5Nwne+e3J9NUcWUPPFQGdfLPOG6nlA0RWq49Ka9y Kcy42cnN9L2SktlHJhHC6Om0RYFZCvZZL4mXWKFLaNT37pmGMHjuuUVdOxSO88ZIfTUt XQp1JERttAmxap3xJa253vX0t0FFiRvZMrJcLKgjQTVe6q2aCMr7LSU9cSDRNDJ1YHD4 pGJjoLB6+MmFClhYajuexK+b1VTmpF+7WPTDZBjMf6Twev7gqHN6keS2GrlFgNijTn29 j8bJi/ctAdDkuvqPvC4b08/mEqQM/HEoGqCJF7zZF96G8IF3UaS/PmEdYAaAjIS0KpcY JiUA== X-Gm-Message-State: AOAM531ql1ywI15qlQ7wW6holpG8JIqAwbOx4Qg0gPNOuBXBY+CPZKCH QFwl2l+mOCsilXQLGBbNIMWOu+1VDJijvg== X-Google-Smtp-Source: ABdhPJxuJRHNiuNYcKn5j6gBqV0/CFekzesXi0ZZuNycY5zQrlnxJukoL2mZQTkhmpL/WZMLvvNyjA== X-Received: by 2002:a05:6a00:1989:: with SMTP id d9mr12580563pfl.14.1644176449166; Sun, 06 Feb 2022 11:40:49 -0800 (PST) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id bv22sm4021039pjb.0.2022.02.06.11.40.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Feb 2022 11:40:48 -0800 (PST) Subject: Re: Lazy load of org-protocol To: emacs-orgmode@gnu.org References: <9b140f0a-c75e-cf00-0f83-67e5a660935c@gmail.com> From: Jim Porter Message-ID: <62519b3f-d1fa-4497-e32f-2a0960c4d1fe@gmail.com> Date: Sun, 6 Feb 2022 11:40:49 -0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::530 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=jporterbugs@gmail.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" 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=1644176488; 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:dkim-signature; bh=iChoNBP8FFE1sEUl2UEjAJQV825XQuZsgVOVy1GqLgY=; b=hQZQGerM9aayA40KeNX0+jx5tbqdCiHvWUb9c37U7LKpQtjiSo/V2kbWORALoJ2arfLmM5 LeGrrXXsdSiIYRYvsuEQNYi7BFlDvUpUvEKn+Zs2vOwLkOeW3jmEZicOEr5680+QrchaqY Xty5HtAwTEaoCll3KQ+17pE1sNoNaP3uWlEsQ1AH3J5NVOSqCvPhA5twcqbpJH+R2lhBU/ +tCswTXyUZQ+MfvgOQbhPQFf+CqF+aJmf2VZlNNfta01h2vGNXV0NyMv9yi5TJIrdMPWGG NaM6gTFVcY7HR0xP2PfZd9xKm1P59GXt4w8gfvoybPt3RlWICeIDh2LlhFkLoQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644176488; a=rsa-sha256; cv=none; b=VSSi+da9fAawpW6YfE/UqFFxWYbu1KrQRDExttx5Vd6ZV6roEN2QQjMsbjOkMMklooTYnM ZMASwqe5VjTlNhgjUYEAvEiB5uNNevwRWpP5+EDiUSzwBMfyFTSo2gQ6F0lekdfYAKm+3+ HGL+q2ewFvez1s1oA/xtksXDSRiuCpAOhMYEX7bqVlfvDUPrz39jxrvXUii275zT2d6k3S egV24u4gfgGfU6hYIVQmMMORVMRM37Kv+aZ/qTuCbsItB0oIpgU1EDy4OuR+MpF0f7BtTx 7QyQJ7xjRZ5IoZm87bqXNB1ATkP4ZKymDSkBBpr9Zq5cJfVxvYXpA58eDZaB+g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="pGYirO/z"; dmarc=pass (policy=none) header.from=gmail.com; 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: -5.83 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="pGYirO/z"; dmarc=pass (policy=none) header.from=gmail.com; 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: 231542862E X-Spam-Score: -5.83 X-Migadu-Scanner: scn0.migadu.com X-TUID: Xk2O6G8wPKK2 On 2/6/2022 8:42 AM, Max Nikulin wrote: > On 06/02/2022 01:27, Jim Porter wrote: >> As a result, I think a good first step might be to add support for >> "--funcall" to emacsclient, just like the regular emacs binary. (The >> "-f" shorthand won't work though, since emacsclient already uses that >> for "--server-file"). This would simplify the `message-mailto' case >> above and would also allow org-protocol to do something similar: >> >>    emacsclient --funcall org-protocol-capture %u > > No, --funcall is just a sugar for --eval '(func)' that does not contain > arbitrary input, but func has no access to other arguments and it is the > real problem. Oh right, of course. The emacsclient case with `(message-mailto \"%u\")' threw me off, but `message-mailto' works differently depending on whether you pass it an arg or not. > I think, the solution is to add -arg command to emacs server protocol > that pushes its argument to a list and extend -exec command that would > make such list available as argv or as `command-line-args-left' for > evaluated expression. Of course, emacsclient option parser should be > modified as well to support --arg option >      emacsclient --eval '(func)' --arg 1 2 3 >      emacsclient --eval '(func)' --arg -- 1 2 3 > and maybe even for multiple eval+arg pairs >      emacsclient --eval '(f1)' --arg 'a1' --eval '(f2)' --arg 'a2' 'a3' I think something like this could work, so long as the arguments can be forwarded correctly in the alternate editor case. If I understand how emacsclient handles --eval, I think that might work, but it would still require writing Lisp functions that know how to handle argv or `command-line-args-left'. I'm also not totally sure how safe/sensible that is when the arguments aren't from the invocation of emacs itself, but from emacsclient (and thus, the args could be updated multiple times throughout a session). It probably wouldn't actually break anything, but it does seem a bit surprising to me... Maybe another option would be to add an --apply argument that really *does* consume the other command-line args and turns them into a properly-quoted function call. Roughly speaking, it would turn this: emacs --apply func foo bar baz into this: (apply #'func '(foo bar baz)) This would work effectively like how I momentarily thought --funcall works. Then you could say: emacsclient --apply org-protocol-capture %u # or ... emacs --apply org-protocol-capture %u This would also mean that the `message-mailto' function from Gnus doesn't need to care about `command-line-args-left' anymore, which would simplify it somewhat. And this could be useful in general for programmatically interacting with Emacs, since users would be able to pass arbitrary strings to Emacs Lisp functions without having to worry (as much) about sanitizing the strings first. > The proper place to discuss idea is emacs-devel list, but I am afraid > that without a patch it will be just buried. I don't know if an actual patch would be a strict prerequisite for posting to emacs-devel, but it's probably wise to have a clear, detailed proposal first. I think it's easier to get everyone on board with an idea if it's easy for them to see how all the details work up-front. - Jim