unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Damien Cassou <damien@cassou.me>, Eli Zaretskii <eliz@gnu.org>,
	git@mavit.org.uk, 57752@debbugs.gnu.org
Subject: bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me
Date: Sun, 18 Sep 2022 11:31:58 -0700	[thread overview]
Message-ID: <78d5c54b-5b33-8571-7de5-b5bd2ddd95b7@gmail.com> (raw)
In-Reply-To: <87zgex56bw.fsf@gnus.org>

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.





  parent reply	other threads:[~2022-09-18 18:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 18:31 bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me Damien Cassou
2022-09-13 12:19 ` Lars Ingebrigtsen
2022-09-13 13:29   ` Damien Cassou
2022-09-13 13:41     ` Eli Zaretskii
2022-09-13 13:58       ` Damien Cassou
2022-09-13 14:57         ` Robert Pluim
2022-09-13 15:32           ` Damien Cassou
2022-09-15 18:30         ` Jim Porter
2022-09-16  9:54           ` Lars Ingebrigtsen
2022-09-16 10:09             ` Robert Pluim
2022-09-16 10:14               ` Lars Ingebrigtsen
2022-09-16 14:18                 ` Robert Pluim
2022-09-16 15:21                   ` Jim Porter
2022-09-16 12:38               ` Damien Cassou
2022-09-16 12:50                 ` Gregory Heytings
2022-09-16 14:46                   ` Damien Cassou
2022-09-16 15:07                     ` Gregory Heytings
2022-09-16 16:18                       ` Peter Oliver
2022-09-16 16:42                         ` Gregory Heytings
2022-09-16 17:21                           ` Jim Porter
2022-09-16 18:26                             ` Gregory Heytings
2022-09-16 19:33                               ` Jim Porter
2022-09-16 20:04                                 ` Gregory Heytings
2022-09-18 13:58                                   ` Robert Pluim
2022-09-16 14:19                 ` Robert Pluim
2022-09-16 14:47                   ` Damien Cassou
2022-09-16 15:17             ` Jim Porter
2022-09-18 10:23               ` Lars Ingebrigtsen
2022-09-18 14:46                 ` Robert Pluim
2022-09-19  8:09                   ` Lars Ingebrigtsen
2022-09-18 18:31                 ` Jim Porter [this message]
2022-09-19  8:12                   ` Lars Ingebrigtsen
2022-09-19 15:48                     ` Jim Porter
2022-09-19 18:45                       ` Lars Ingebrigtsen
2022-09-19  8:56                 ` Gregory Heytings
2022-09-19 12:00                   ` Lars Ingebrigtsen
2022-09-19 16:05                   ` Jim Porter
2022-09-19 17:01                     ` Gregory Heytings
2022-12-02 14:52     ` Max Nikulin
2023-07-26  5:14       ` Max Nikulin
2022-09-16 19:42   ` Jim Porter
2022-09-18 10:26     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=78d5c54b-5b33-8571-7de5-b5bd2ddd95b7@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=57752@debbugs.gnu.org \
    --cc=damien@cassou.me \
    --cc=eliz@gnu.org \
    --cc=git@mavit.org.uk \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).