Subject: bug#1298: allow 'emacsclient -a "emacs --daemon && emacsclient -c"'

From: Dan Nicolaescu <[email-masked]>
Date: Tue, 18 Nov 2008 00:22:33 -0800 (PST)

Dan Nicolaescu <[email-masked]> writes:

  > It would be nice if some equivalent of: 
  > 
  > 'emacsclient -a "emacs --daemon && emacsclient -c"
  > 
  > would work.
  > 
  > That would allow one to ALWAYS use emacsclient. 

Here's a quick hack that allows:

emacsclient -a "emacs --daemon && emacsclient -c" FILENAME

to work.  It is not complete yet, FILENAME does not get passed to the
"&& emacsclient"

--- emacsclient.c.~1.140.~	2008-11-03 06:30:13.000000000 -0800
+++ emacsclient.c	2008-11-18 00:13:29.000000000 -0800
@@ -630,8 +630,13 @@ fail (void)
   if (alternate_editor)
     {
       int i = optind - 1;
+      char * new_argv[] = { "sh", "-c", 0, 0 };
 
-      execvp (alternate_editor, main_argv + i);
+      new_argv[0] = "sh";
+      new_argv[1] = "-c";
+      new_argv[2] = alternate_editor;
+
+      execve ("/bin/sh", new_argv, environ);
       message (TRUE, "%s: error executing alternate editor \"%s\"\n",
 	       progname, alternate_editor);
     }

Thoughts?