all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
@ 2023-08-04  2:47 John t
  2023-08-04  6:20 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: John t @ 2023-08-04  2:47 UTC (permalink / raw)
  To: 65048


[-- Attachment #1.1: Type: text/plain, Size: 7745 bytes --]

In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
 cairo version 1.17.8) of 2023-08-02 built on localhost
System Description: Gentoo Linux

Configured using:
 'configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --datarootdir=/usr/share
 --disable-silent-rules --docdir=/usr/share/doc/emacs-29.1
 --htmldir=/usr/share/doc/emacs-29.1/html --libdir=/usr/lib64
 --program-suffix=-emacs-29 --includedir=/usr/include/emacs-29
 --infodir=/usr/share/info/emacs-29 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --without-compress-install --without-hesiod --without-pop
 --with-file-notification=inotify --with-pdumper --enable-acl
 --with-dbus --with-modules --without-gameuser --with-libgmp
 --without-gpm --with-native-compilation=aot --with-json
 --without-kerberos --without-kerberos5 --with-lcms2 --with-xml2
 --without-mailutils --without-selinux --with-sqlite3 --with-gnutls
 --without-libsystemd --with-threads --with-tree-sitter --with-wide-int
 --with-sound=alsa --with-zlib --with-pgtk --without-x --without-ns
 --with-toolkit-scroll-bars --without-gconf --without-gsettings
 --with-harfbuzz --without-libotf --without-m17n-flt --without-xwidgets
 --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-webp
 --with-imagemagick --with-dumping=pdumper 'CFLAGS=-march=native -O2
 -pipe' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG
JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Info

Minor modes in effect:
  electric-pair-mode: t
  recentf-mode: t
  save-place-mode: t
  delete-selection-mode: t
  cua-mode: t
  savehist-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  isearch-fold-quotes-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/cmake-mode hides
/usr/share/emacs/site-lisp/cmake/cmake-mode
/usr/share/emacs/site-lisp/desktop-entry-mode hides
/usr/share/emacs/site-lisp/desktop-file-utils/desktop-entry-mode
/usr/share/emacs/site-lisp/transient/transient hides
/usr/share/emacs/29.1/lisp/transient

Features:
(shadow sort mail-extr emacsbug tramp-cmds mule-util jka-compr info vc
bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs face-remap vc-hg vc-bzr rfc2104
tramp-cache time-stamp tramp-sh misearch multi-isearch ibuf-ext
dired-aux vc-git vc-dispatcher display-line-numbers elec-pair
badger-theme wombat-theme recentf tree-widget wid-edit saveplace delsel
cua-base rust-ts-mode c-ts-common tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time iso8601 savehist man
magit-bookmark bookmark magit-imenu git-rebase magit-extras
magit-gitignore magit-ediff magit-subtree magit-patch magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-handlers
magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff diff-mode git-commit log-edit message sendmail mailcap
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util time-date mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert autorevert magit-margin magit-transient magit-process
with-editor comp comp-cstr shell pcomplete magit-mode transient edmacro
kmacro compat format-spec magit-git magit-section magit-utils crm ielm
ibuffer ibuffer-loaddefs highlight-indentation flycheck lisp-mnt dash
eglot external-completion array filenotify jsonrpc ert pp ewoc xref
flymake-proc flymake thingatpt warnings icons compile
text-property-search comint ansi-osc ansi-color ring pcase url-util
url-parse auth-source eieio eieio-core password-cache json subr-x map
url-vars project imenu ediff ediff-merg ediff-mult ediff-wind ediff-diff
ediff-help ediff-init ediff-util ebuild-mode skeleton sh-script smie
treesit executable rx conf-mode cl-extra toggle-local-vars
reload-library loadhist byte-opt man-completion cl-macs gv cl-seq edebug
debug backtrace help-mode find-func server use-package
use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core cl-loaddefs
cl-lib bytecomp byte-compile site-gentoo rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting font-render-setting cairo gtk pgtk lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 488020 35871)
 (symbols 48 25863 0)
 (strings 32 99619 5192)
 (string-bytes 1 3259302)
 (vectors 16 57667)
 (vector-slots 8 941782 73507)
 (floats 8 125 489)
 (intervals 56 38946 0)
 (buffers 984 22))

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!

[-- Attachment #1.2: Type: text/html, Size: 8408 bytes --]

[-- Attachment #2: fix-x-option.patch --]
[-- Type: application/octet-stream, Size: 1737 bytes --]

From 7ab2f6a5d8b0650eb91c1f475972d7325e1f641d Mon Sep 17 00:00:00 2001
From: John Turner <jturner.usa@gmail.com>
Date: Wed, 2 Aug 2023 02:28:58 -0400
Subject: [PATCH] move arg parse case for -x out of HAVE_X_WINDOWS #ifdef

---
 src/emacs.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index 80a013b68df..3349477b4b9 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1639,10 +1639,19 @@ main (int argc, char **argv)
       /* FIXME broken for --script=FILE - is that supposed to work?  */
       argv[skip_args - 1] = (char *) "-scriptload";
       skip_args -= 2;
       sort_args (argc, argv);
     }
+  if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args))
+      {
+	noninteractive = 1;
+	no_site_lisp = 1;
+	/* This is picked up in startup.el.  */
+	argv[skip_args - 1] = (char *) "-scripteval";
+	skip_args -= 2;
+	sort_args (argc, argv);
+      }
 
   /* Handle the --help option, which gives a usage message.  */
   if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args)
       && !only_version)
     {
@@ -2051,20 +2060,10 @@ main (int argc, char **argv)
         if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args)
             || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args))
           no_site_lisp = 1;
       }
 
-    if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args))
-      {
-	noninteractive = 1;
-	no_site_lisp = 1;
-	/* This is picked up in startup.el.  */
-	argv[skip_args - 1] = (char *) "-scripteval";
-	skip_args -= 1;
-	sort_args (argc, argv);
-      }
-
     /* Don't actually discard this arg.  */
     skip_args = count_before;
   }
 #else  /* !HAVE_X_WINDOWS */
   if (! no_site_lisp)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
  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
       [not found]   ` <CAJ2jvP+Opyt7XEtoZsTGKw0M-D-Ws1D5eFRi+81gz5z3S7FR6Q@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-04  6:20 UTC (permalink / raw)
  To: John t; +Cc: 65048

> 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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
       [not found]   ` <CAJ2jvP+Opyt7XEtoZsTGKw0M-D-Ws1D5eFRi+81gz5z3S7FR6Q@mail.gmail.com>
@ 2023-08-09 11:44     ` Eli Zaretskii
  2023-08-09 17:34       ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-09 11:44 UTC (permalink / raw)
  To: John t, Po Lu; +Cc: 65048

> From: John t <jturner.usa@gmail.com>
> Date: Tue, 8 Aug 2023 23:51:32 -0400
> 

(You've replied only to me, so no one else saw your message.  Please
in the future use Reply All, to keep the bug address on the CC list.)

> I have tested the patch with PGTK, and headless configurations and the option seems to work
> correctly.
> 
> A friend with an x11 emacs tested the patch and reported that it returned the "unknown option" error.

That's strange.  Can someone please test the patch on X and see if it
works, and if not, tell me where I goofed?

TIA





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
  2023-08-09 11:44     ` Eli Zaretskii
@ 2023-08-09 17:34       ` Robert Pluim
  2023-08-09 18:05         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2023-08-09 17:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Po Lu, John t, 65048

>>>>> On Wed, 09 Aug 2023 14:44:24 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: John t <jturner.usa@gmail.com>
    >> Date: Tue, 8 Aug 2023 23:51:32 -0400
    >> 

    Eli> (You've replied only to me, so no one else saw your message.  Please
    Eli> in the future use Reply All, to keep the bug address on the CC list.)

    >> I have tested the patch with PGTK, and headless configurations and the option seems to work
    >> correctly.
    >> 
    >> A friend with an x11 emacs tested the patch and reported that it returned the "unknown option" error.

    Eli> That's strange.  Can someone please test the patch on X and see if it
    Eli> works, and if not, tell me where I goofed?

Looks ok to me:

$ src/emacs -x

Wrong type argument: stringp, nil

Error: wrong-type-argument (stringp nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode -0x1d4598e800517817>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument stringp nil))
  string-match("^///+" nil)
  command-line-normalize-file-name(nil)
  command-line-1(("-scripteval"))
  command-line()
  normal-top-level()

Robert
-- 





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
  2023-08-09 17:34       ` Robert Pluim
@ 2023-08-09 18:05         ` Eli Zaretskii
  2023-08-10  7:37           ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-09 18:05 UTC (permalink / raw)
  To: Robert Pluim; +Cc: luangruo, jturner.usa, 65048

> From: Robert Pluim <rpluim@gmail.com>
> Cc: John t <jturner.usa@gmail.com>,  Po Lu <luangruo@yahoo.com>,
>   65048@debbugs.gnu.org
> Date: Wed, 09 Aug 2023 19:34:34 +0200
> 
> >>>>> On Wed, 09 Aug 2023 14:44:24 +0300, Eli Zaretskii <eliz@gnu.org> said:
> 
>     Eli> That's strange.  Can someone please test the patch on X and see if it
>     Eli> works, and if not, tell me where I goofed?
> 
> Looks ok to me:
> 
> $ src/emacs -x
> 
> Wrong type argument: stringp, nil

Thanks.  And if you invoke the following shell script, does it produce
the message as expected?

#!/path/to/src/emacs -x

(message "Hello, emacs scripting!")





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
  2023-08-09 18:05         ` Eli Zaretskii
@ 2023-08-10  7:37           ` Robert Pluim
  2023-08-10  7:51             ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2023-08-10  7:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, jturner.usa, 65048

>>>>> On Wed, 09 Aug 2023 21:05:36 +0300, Eli Zaretskii <eliz@gnu.org> said:
    Eli> Thanks.  And if you invoke the following shell script, does it produce
    Eli> the message as expected?

    Eli> #!/path/to/src/emacs -x

    Eli> (message "Hello, emacs scripting!")

(emacs-29 *)> ./foo.sh
Hello, emacs scripting!
(emacs-29 *)>

Robert
-- 





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
  2023-08-10  7:37           ` Robert Pluim
@ 2023-08-10  7:51             ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-10  7:51 UTC (permalink / raw)
  To: Robert Pluim; +Cc: luangruo, jturner.usa, 65048-done

> From: Robert Pluim <rpluim@gmail.com>
> Cc: jturner.usa@gmail.com,  luangruo@yahoo.com,  65048@debbugs.gnu.org
> Date: Thu, 10 Aug 2023 09:37:29 +0200
> 
> >>>>> On Wed, 09 Aug 2023 21:05:36 +0300, Eli Zaretskii <eliz@gnu.org> said:
>     Eli> Thanks.  And if you invoke the following shell script, does it produce
>     Eli> the message as expected?
> 
>     Eli> #!/path/to/src/emacs -x
> 
>     Eli> (message "Hello, emacs scripting!")
> 
> (emacs-29 *)> ./foo.sh
> Hello, emacs scripting!
> (emacs-29 *)>

Thanks.  So I've now installed the fix on the emacs-29 branch, and I'm
closing this bug.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-10  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [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

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.