bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jim Porter
Subject: bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me
Date: Sun, 18 Sep 2022 11:31:58 -0700

On 9/18/2022 3:23 AM, Lars Ingebrigtsen wrote:
Jim Porter <jporterbugs@gmail.com> writes:

1) Instead of specifying the function args with a flag, I think I'd go
the other way and specify the function as being special, e.g.:

   emacs --apply func arg1 arg2

Yes, that sounds good.  (But we'd still need "--" to say that the
arguments have ended.)

This is actually the trickiest part about this to me. If I were designing this, I'd say that '--apply' consumes every positional argument up to the next flag. If it encounters a '--' while consuming arguments, *every* remaining argument gets passed to the function. That allows the following:

  emacs --apply func1 arg1 arg2 --apply func2 arg3 arg4 -Q
    => emacs -Q
       (func1 "arg1" "arg2")
       (func2 "arg3" "arg4")

  emacs --apply func -- --arg1 --arg2
    => emacs
       (func "--arg1" "--arg2")

This way, users can pass arguments beginning with a "-" to the function being applied while still retaining a fair amount of flexibility in other cases. It would also be good for shell scripts/aliases where you don't know ahead of time what the arguments will look like. If you had this in your shell environment:

  EDITOR="emacs --apply fancy-find-file"

then you might try to visit a file named "-Q". However, it would treat "-Q" as an argument to emacs instead. With what I suggested above, you'd just say:

  EDITOR="emacs --apply fancy-find-file --"

That's a common way of doing this for other command-line tools, so I think most people should understand the behavior fairly easily.

2) Even better, why not just use --function and pass some higher-order
function:

   emacs --function apply-from-command-line func arg1 arg2

I think that sounds more obscure, really (even if it's simpler to
implement in the "emacs" case).

Either is fine with me. Originally, I thought that "--funcall apply-from-command-line ..."[1] might be nicer since you could replace 'apply-from-command-line' with a fancier function, e.g. one that parses numeric values, but I think you'd be able to do that with --apply anyway. It's probably better to keep the simple path simple and go with --apply.

[1] I had meant to type --funcall instead of --function in my previous message, but got mixed up.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]