GNU bug report logs -
#65048
29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
Previous Next
Reported by: John t <jturner.usa <at> gmail.com>
Date: Fri, 4 Aug 2023 03:57:04 UTC
Severity: normal
Found in version 29.1
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: John t <jturner.usa <at> gmail.com>
> Date: Thu, 3 Aug 2023 22:47:19 -0400
>
> Scripts starting with "#!/usr/bin/emacs -x" do not function with PGTK Emacs.
>
> Instead of evaluating the file contents, Emacs creates a new instance
> and opens a frame, echos a warning about "-x" being an unknown option in
> the minibuffer. This seems to suggest that the "-x" option is not being recognized at all.
>
> The statement that parses this specific parameter seems to be inside
> of a conditionally compiled block of code that toggles based on the
> macro HAVE_X_WINDOWS (#ifdef HAVE_X_WINDOWS).
>
> My current build of Emacs uses the PGTK, and non-PGTK builds appear to
> function correctly when used with the "-x" option.
>
> This option doesn't seem to be related to x11 in any way as far as I can
> tell, so I have moved it to the location where the "--script" option is
> parsed, and then decrement skip_args by 2 instead of 1 which is also what
> "--script" does.
>
> These changes cause the "-x" option to function correctly, but I am not
> experienced in C or with the C parts of Emacs, so this may not be the
> correct solution!
Thanks. You are right: the -x switch should not be X-specific.
Please try the patch below instead (which removes some duplicate code,
but is in general the same idea as in your suggested patch). Please
try this both in the PGTK and in non-PGTK builds, as I have only
limited access to such configurations.
diff --git a/src/emacs.c b/src/emacs.c
index e63b092..37c017d 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2007,15 +2007,16 @@ main (int argc, char **argv)
}
#endif /* HAVE_NS */
-#ifdef HAVE_X_WINDOWS
/* Stupid kludge to catch command-line display spec. We can't
handle this argument entirely in window system dependent code
because we don't even know which window system dependent code
to run until we've recognized this argument. */
{
- char *displayname = 0;
int count_before = skip_args;
+#ifdef HAVE_X_WINDOWS
+ char *displayname = 0;
+
/* Skip any number of -d options, but only use the last one. */
while (!only_version)
{
@@ -2045,12 +2046,15 @@ main (int argc, char **argv)
}
argv[count_before + 1] = (char *) "-d";
}
+#endif /* !HAVE_X_WINDOWS */
if (! no_site_lisp)
{
- if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args)
+
+ if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args)
|| argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args))
- no_site_lisp = 1;
+ no_site_lisp = 1;
+
}
if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args))
@@ -2066,18 +2070,6 @@ main (int argc, char **argv)
/* Don't actually discard this arg. */
skip_args = count_before;
}
-#else /* !HAVE_X_WINDOWS */
- if (! no_site_lisp)
- {
- int count_before = skip_args;
-
- if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args)
- || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args))
- no_site_lisp = 1;
-
- skip_args = count_before;
- }
-#endif
/* argmatch must not be used after here,
except when building temacs
This bug report was last modified 1 year and 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.