all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: John t <jturner.usa@gmail.com>
Cc: 65048@debbugs.gnu.org
Subject: bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
Date: Fri, 04 Aug 2023 09:20:54 +0300	[thread overview]
Message-ID: <83fs4zwcop.fsf@gnu.org> (raw)
In-Reply-To: <CAJ2jvPKRqQ2FqsKgB0V=_CFjou3z+km=dH3-8RH7Qu5b8_nKng@mail.gmail.com> (message from John t on Thu, 3 Aug 2023 22:47:19 -0400)

> From: John t <jturner.usa@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





  reply	other threads:[~2023-08-04  6:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  2:47 bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs John t
2023-08-04  6:20 ` Eli Zaretskii [this message]
     [not found]   ` <CAJ2jvP+Opyt7XEtoZsTGKw0M-D-Ws1D5eFRi+81gz5z3S7FR6Q@mail.gmail.com>
2023-08-09 11:44     ` Eli Zaretskii
2023-08-09 17:34       ` Robert Pluim
2023-08-09 18:05         ` Eli Zaretskii
2023-08-10  7:37           ` Robert Pluim
2023-08-10  7:51             ` Eli Zaretskii

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=83fs4zwcop.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=65048@debbugs.gnu.org \
    --cc=jturner.usa@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.