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.bugs Subject: bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping Date: Sun, 24 Sep 2023 08:18:45 +0300 Message-ID: <83a5tc4096.fsf@gnu.org> References: <80d8aeb0-c9f1-410f-b83d-60f83ca5b3af@email.android.com> <83led8ls3z.fsf@gnu.org> <835y4ckkzu.fsf@gnu.org> <874jjnvvip.fsf@catern.com> <835y4290kf.fsf@gnu.org> <87zg1cprix.fsf@catern.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24933"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jporterbugs@gmail.com, 65902@debbugs.gnu.org, sbaugh@janestreet.com To: sbaugh@catern.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 24 07:20:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qkHXb-0006K1-Gc for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Sep 2023 07:20:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qkHX8-0008Jy-Eq; Sun, 24 Sep 2023 01:19:55 -0400 Original-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 1qkHX6-0008I1-Py for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2023 01:19:53 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qkHX5-00043m-OZ for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2023 01:19:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qkHXG-00024f-S2 for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2023 01:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Sep 2023 05:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65902-submit@debbugs.gnu.org id=B65902.16955327727925 (code B ref 65902); Sun, 24 Sep 2023 05:20:02 +0000 Original-Received: (at 65902) by debbugs.gnu.org; 24 Sep 2023 05:19:32 +0000 Original-Received: from localhost ([127.0.0.1]:40870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkHWm-00023l-7i for submit@debbugs.gnu.org; Sun, 24 Sep 2023 01:19:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkHWj-00023U-5N for 65902@debbugs.gnu.org; Sun, 24 Sep 2023 01:19:31 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qkHWR-0003pe-LQ; Sun, 24 Sep 2023 01:19:11 -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=cKxMP3y/CYrdI5uMcg38K2hrEJj8Fb7gSPMe6i6F6M4=; b=H/siEePBYe4u wVHkVwYvWf6dYWdO/JTr9qzhwmSdIQq6OZxL0MHGuCe235nGG0cFzpZ28ZT+t9p5++OMiCuJQTZDH CRoLzkMT/bHClx3jBxZAeKYY9X0HcXd+Y9cBYIQtZ4H2MQbbgNkoMSiVWl3m6neW8rb6UEZrCEZdv dSVeL6+KpMPTh1sCICpnc6ATeNR1BXe6WXfgUieJ9dXCDaIg9sBWSEWvLle/LuXE/jvszUTUpFKFX 5tKMLwRNDS7YhYqLXYEVSOxlmLBmNwm49cjTPPL0hR1WJkSo0aSBWkhq0W8KC5CZcwhTI5osb9jw9 +G5oZyyoVwHOgAMy0LCp0g==; In-Reply-To: <87zg1cprix.fsf@catern.com> (sbaugh@catern.com) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271210 Archived-At: > From: sbaugh@catern.com > Date: Sat, 23 Sep 2023 20:24:07 +0000 (UTC) > Cc: 65902@debbugs.gnu.org, sbaugh@janestreet.com, jporterbugs@gmail.com > > > IIUC, this kind of solution is fine by me, but the protocol of > > accessing and using server-eval-args-left in the Lisp expressions > > specified on the emacsclient command line should be well-documented to > > avoid any confusion and UB. > > Added a docstring and included it in NEWS. I would have put it in the > manual, but it seems rather niche to put in the Emacs manual and I > didn't see a natural place to put it in the Emacs Lisp manual. The natural place is in the Emacs user manual, in "emacsclient Options", where --eval is described. Where else? > Passing arbitrary arguments to functions through emacsclient --eval > requires complicated escaping to avoid them being parsed as Lisp (as > seen in emacsclient-mail.desktop before this change). > > This new variable server-eval-args-left allows access to the arguments > before they are parsed as Lisp. By removing arguments from the > variable before they're parsed, a snippet of Lisp can consume > arguments, as in emacsclient-mail.desktop. > > org-protocol might be able to use this as well, which might allow it > to drop its current advice on server-visit-files. The right place to keep this information is in the manual and the doc strings, not just in the Git commit log message. > +(defvar server-eval-args-left nil > + "List of eval args not yet processed. > + > +When the server receives a request to eval one or more strings, > +it stores them in this variable. Then, until this variable is > +nil, it `pop's a string from this variable and evaluates it with > +`server-eval-and-print'. Adding or removing strings from this > +variable during this process will affect what is evaluated. This describes the implementation rather than the intended usage. > +This allows an expression passed to \"emacsclient --eval\" to > +consume one or more subsequent arguments before they're parsed or > +evaluated, with (pop server-eval-args-left). This is useful if > +those arguments are arbitrary strings which should not be > +evaluated. This describes a way of using this, but without the important part: that any processed argument _must_ be popped, or it will be evaluated again. See the doc string of command-line-functions for what I have in mind. All in all, I think this should be rewritten in terms of how to use this, and the result moved to the Emacs manual, leaving just the minimum here. > +See also `command-line-args-left' for a similar variable which > +works for command line invocations of \"emacs\".") This "see also" is not useful, because the doc string of command-line-args-left is minimal and doesn't add any information (which is okay, since that variable is basically meant for internal Emacs handling of command-line arguments, unlike this one). > --- a/lisp/startup.el > +++ b/lisp/startup.el > @@ -120,7 +120,10 @@ command-switch-alist > "List of command-line args not yet processed. > This is a convenience alias, so that one can write (pop argv) > inside of --eval command line arguments in order to access > -following arguments.")) > +following arguments. > + > +See also `server-eval-args-left' for a similar variable which > +works for invocations of \"emacsclient --eval\".")) And neither is this, because the use cases of the two variables are almost completely unrelated.