On 12/10/06, Francis Wright <[EMAIL PROTECTED]> wrote:
I execute all the following commands from a cmd command
prompt (outside of Emacs).
emacsclient -n -a runemacs "TO DO.txt"
works correctly if Emacs IS already running, but if it is not
already running then Emacs does not see the filename correctly;
the quotes do not appear to be passed on to runemacs.
The following patch addresses the issue by allocating quoted copies of
any argument containing spaces before calling execvp.
Any objections to install this fix? As it stands, it affects also
non-Windows builds. Is requoting args the right behavior in these
environments?
/L/e/k/t/u
Index: lib-src/emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.98
diff -u -2 -r1.98 emacsclient.c
--- lib-src/emacsclient.c 30 Nov 2006 22:49:38 -0000 1.98
+++ lib-src/emacsclient.c 15 Dec 2006 10:19:44 -0000
@@ -310,8 +310,20 @@
if (alternate_editor)
{
- int i = optind - 1;
+ int j, i = optind - 1;
+
#ifdef WINDOWSNT
- argv[i] = (char *)alternate_editor;
+ argv[i] = (char *) alternate_editor;
#endif
+
+ /* Arguments with spaces have been dequoted, so we
+ have to requote them before calling execvp. */
+ for (j = i; argv[j]; j++)
+ if (strchr (argv[j], ' '))
+ {
+ char *quoted = alloca (strlen (argv[j]) + 3);
+ sprintf (quoted, "\"%s\"", argv[j]);
+ argv[j] = quoted;
+ }
+
execvp (alternate_editor, argv + i);
message (TRUE, "%s: error executing alternate editor \"%s\"\n",
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug