unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Reuben Thomas <rrt@sc3d.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 25082@debbugs.gnu.org
Subject: bug#25082: [PATCH] Add support to emacsclient for command-lline options in ALTERNATE_EDITOR/--alternate-editor
Date: Tue, 29 Aug 2017 16:49:23 +0100	[thread overview]
Message-ID: <CAOnWdoie5tz8zhUjTSar3KHogVjGZW7mEwD6myhhCUA_2JZGyA@mail.gmail.com> (raw)
In-Reply-To: <83val62xcb.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3528 bytes --]

On 29 August 2017 at 16:43, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Reuben Thomas <rrt@sc3d.org>
> > Date: Mon, 28 Aug 2017 11:15:55 +0100
> > Cc: Glenn Morris <rgm@gnu.org>, 25082@debbugs.gnu.org
> >
> > >> Is this sufficient?
> > >
> > > It could be, but I'm not sure I understand clearly what is supported
> > > and what isn't.  Could you please add this information to the NEWS
> > > entry and in more detail to the user manual?  I think having these
> > > details in the manual is important regardless.
> >
> > I've added detail to NEWS. I am wary of adding more detail to the
> > manual, because it could prevent future improvements (for example,
> > implementation of quote escaping): we don't want users to rely on the
> > lack of quote escaping.
>
> We don't want them to rely on the lack of the escaping, but we also
> want to tell them what is supported and how.
>

So just to check, you would view the current lack of documentation of how
the current variable works as something that should ideally be improved?​


> > @table @samp
> > @item -a @var{command}
> > @itemx --alternate-editor=@var{command}
> > Specify a command to run if @code{emacsclient} fails to contact Emacs.
> > This is useful when running @code{emacsclient} in a script.
> >
> > Note that this does not document the current situation precisely (a
> > user could be forgiven for thinking that "emacs -Q -nw" would already
> > work.
>
> Only if we say "shell command", not just "command".
>

I don't think many readers will be so precise. I wasn't.​


> > +Arguments may be quoted, so that for example an absolute path
> > +containing a space may be specified; quote escaping is not supported.
>
> I would say `quoted "like this"', since otherwise it isn't clear what
> kind of quoting is supported.  And I think something similar needs to
> be said in the manual.
>

​OK, I'll do that.​

> +      /* Unpack alternate_editor's space-separated tokens into
> new_argv.  */
> > +      for (char *tok = s; tok != NULL && *tok != '\0';)
> > +        {
> > +          /* Allocate new token.  */
> > +          ++toks;
> > +          new_argv = xrealloc (new_argv, new_argv_size + toks * sizeof
> (char *));
> > +
> > +          /* Skip leading delimiters, and set separator, skipping any
> > +             opening quote.  */
> > +          size_t skip = strspn (tok, " \"");
> > +          tok += skip;
> > +          char sep = (skip > 0 && tok[-1] == '"') ? '"' : ' ';
> > +
> > +          /* Record start of token.  */
> > +          new_argv[toks - 1] = tok;
> > +
> > +          /* Find end of token and overwrite it with NUL.  */
> > +          tok = strchr (tok, sep);
> > +          if (tok != NULL)
> > +            *tok++ = '\0';
> > +        }
> > +
> > +      /* Append main_argv arguments to new_argv.  */
> > +      memcpy (&new_argv[toks], main_argv + optind, extra_args_size);
> >
> > -      execvp (alternate_editor, main_argv + i);
> > +      execvp (*new_argv, new_argv);
>
> This won't work on Windows, btw, if the arguments include whitespace.
> But that can be fixed by followup changes.
>

How not? That is precisely the case it aims to support.​ That's the whole
point of dealing with quotes! (Previous versions of the patch didn't
support quoting, and so didn't support spaces in arguments; this version
has a passing test to show that spaces in quoted arguments work.)

-- 
https://rrt.sc3d.org <http://rrt.sc3d.org>

[-- Attachment #2: Type: text/html, Size: 5399 bytes --]

  reply	other threads:[~2017-08-29 15:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-01 15:31 bug#25082: [PATCH] Add support to emacsclient for command-lline options in ALTERNATE_EDITOR/--alternate-editor Reuben Thomas
2016-12-02 10:20 ` Eli Zaretskii
2016-12-02 15:31   ` Reuben Thomas
2016-12-08 23:10 ` Glenn Morris
2016-12-09 13:44   ` Reuben Thomas
2017-08-20 21:08     ` Reuben Thomas
2017-08-22  0:16       ` Glenn Morris
2017-08-22  0:23         ` Reuben Thomas
2017-08-22  0:52           ` Reuben Thomas
2017-08-23 22:59   ` Reuben Thomas
2017-08-27 14:55     ` Eli Zaretskii
2017-08-28 10:15       ` Reuben Thomas
2017-08-29 15:43         ` Eli Zaretskii
2017-08-29 15:49           ` Reuben Thomas [this message]
2017-08-29 16:49             ` Eli Zaretskii
2017-08-29 22:29               ` Reuben Thomas
2017-08-30 16:48                 ` Eli Zaretskii
2017-08-30 21:01                   ` Reuben Thomas
2017-08-30 21:02 ` bug#25082: Patch installed Reuben Thomas

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=CAOnWdoie5tz8zhUjTSar3KHogVjGZW7mEwD6myhhCUA_2JZGyA@mail.gmail.com \
    --to=rrt@sc3d.org \
    --cc=25082@debbugs.gnu.org \
    --cc=eliz@gnu.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).