all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 11474@debbugs.gnu.org, Scott Turner <srt19170@gmail.com>
Subject: bug#11474: Patch for Emacsclient --eval bug
Date: Thu, 27 Jun 2019 20:40:37 +0200	[thread overview]
Message-ID: <m3ftnux462.fsf@gnus.org> (raw)
In-Reply-To: <jwv1rzeao7l.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Thu, 27 Jun 2019 14:17:20 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> $ emacsclient -a nano --eval '(my-emacs-setup-thing)'
>>
>> The eval bit is meaningful in Emacs, and may be something that the user
>> feels is something that Emacs should do when called from emacsclient.
>> But if there's no server, then we should use nano.
>>
>> The current behaviour is to use nano with the file name
>> '(my-emacs-setup-thing)', while you propose to call nano with
>> --eval '(my-emacs-setup-thing)', which would be even worse, I think,
>> while just dropping the parameters completely in the -a case would make
>> this usable.
>
> I think that nowadays with the `-a ""` option the need to keep
> the --eval is indeed not very high, so I retract my objection.

Hm...  the emacsclient source code has changed substantially over the
years, I see...

  if (alternate_editor)
    {
      size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *);
      size_t new_argv_size = extra_args_size;
      char **new_argv = xmalloc (new_argv_size);

[...]

      /* Append main_argv arguments to new_argv.  */
      memcpy (&new_argv[toks], main_argv + optind, extra_args_size);

      execvp (*new_argv, new_argv);
      message (true, "%s: error executing alternate editor \"%s\"\n",
	       progname, alternate_editor);
    }

So it now picks out arguments from the -a="nano --foo" string, and then
appends the rest of the arguments from emacsclient.

The equivalent here would be to set extra_args_size to 0 if eval, I
guess.  But...  hm....  then we'd lose the file argument too, wouldn't
we?

I mean, if you say

$ ./lib-src/emacsclient -a "nano -v" --eval '(message "foo")' /tmp/a

the you want nano to open /tmp/a...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  reply	other threads:[~2019-06-27 18:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15  5:27 bug#11474: 24.1.50; eval a command does the wrong thing with emacsclientw.exe Jason Lewis
2013-12-13 15:30 ` bug#11474: Patch for Emacsclient --eval bug Scott Turner
2013-12-24 14:56   ` Scott Turner
2013-12-24 16:03     ` Stefan Monnier
2013-12-24 16:11       ` Scott Turner
2014-04-02 14:57   ` Stefan Monnier
2014-04-02 15:34     ` Scott Turner
2014-04-02 16:34       ` Stefan Monnier
2019-06-27 15:29     ` Lars Ingebrigtsen
2019-06-27 18:17       ` Stefan Monnier
2019-06-27 18:40         ` Lars Ingebrigtsen [this message]
2019-06-27 18:56           ` Lars Ingebrigtsen
2019-06-27 19:00             ` Lars Ingebrigtsen
2019-06-27 19:14               ` Stefan Monnier
2019-06-27 19:19                 ` 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

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

  git send-email \
    --in-reply-to=m3ftnux462.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=11474@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=srt19170@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.