Subject: Re: bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me

From: Gregory Heytings <[email-masked]>
Date: Mon, 19 Sep 2022 08:56:13 +0000

>> emacs --apply func arg1 arg2
>
> Yes, that sounds good.
>

Hmm...  I did not see the --apply proposal earlier, it's nice and lispy 
indeed.

I think I would prefer to separate the two concerns (stuffing argument 
strings into the Lisp environment on the one hand, and forms on the other 
hand), but it seems good enough, and perhaps it's the best compromise.

One disadvantage I see is that it becomes a bit more complex to write 
function calls with arguments that are not strings.  E.g. to call

(some-func 1 "arg" t)

one would have to do something like

--eval '(defun tmp-func (arg) (some-func 1 arg t))' --apply tmp-func arg

instead of something like

--set args arg -- --eval '(some-func 1 (car args) t)'

Likewise, if we want to use the arguments in multiple --eval forms, 
something like

--eval '(defun setarg1 (arg) (setq arg1 arg))' --apply setarg1 arg -- --eval '(... arg1 ...)' --eval '(... arg1 ...)'

will be necessary.  Yet another example is that to loop over all 
arguments, one would have to do something like

--eval '(defun loop-fun (args) (dolist (arg args) ...))' --apply loop-fun args

instead of something like

--set args arg -- --eval '(dolist (arg args) ...)'

One case in which --apply is better is when the function is already 
defined by Emacs, e.g. (with the .desktop example mentioned upthread, and 
assuming that find-many-files is defined by Emacs)

--apply find-many-files %F

is probably clearer than

--set files %F -- --eval '(find-many-files files)'

>
> (But we'd still need "--" to say that the arguments have ended.)
>

Except for the last argument(s), of course.  IOW, except if there are no 
arguments that must not be passed to the function after the function 
arguments.