Subject: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs
From: John t <[email-masked]>
To: [email-masked]
Date: Thu, 3 Aug 2023 22:47:19 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

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!