Eli Zaretskii writes: >> From: sbaugh@catern.com >> Date: Fri, 22 Sep 2023 01:36:47 +0000 (UTC) >> Cc: Spencer Baugh , jporterbugs@gmail.com, >> 65902@debbugs.gnu.org >> >> > Currently, when emacsclient is invoked like this: >> > >> > $ emacsclient --eval '(func args)' foo bar >> > >> > we send to the server the following commands: >> > >> > -eval (func args) >> > -eval foo >> > -eval bar >> > >> > IOW, every command-line argument after --eval is treated as being >> > implicitly preceded with --eval. >> > >> > With your proposal, how will the server know that some of "-eval foo" >> > commands should cause foo to be added to server-eval-args-left instead >> > of being evaluated as it does now? >> >> As in the attached patch. > > I wish you'd accompanied the patch with some plain-text description of > the idea, to make it easier to understand and to avoid unnecessary > misunderstandings. Ah, well, the basic idea is that for each -eval request we receive in the protocol, we accumulate the argument as a string into a single list (instead of immediately turning it into a closure which calls server-eval-and-print). Then we let-bind server-eval-args-left to that list around the calls to to server-eval-and-print, and consume each argument from the list one by one. > 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.