From: Steve Youngs Date: Sun, 10 May 2015 00:17:23 +0000 (+1000) Subject: Bring some consistency to command line switches X-Git-Tag: v22.1.16~47 X-Git-Url: https://cgit.sxemacs.org/?p=sxemacs;a=commitdiff_plain;h=01ee95f714416d9966727aad1f66a01ff2c3f540 Bring some consistency to command line switches We have UNIX style single dash cmdline long-opts, and GNU style double dash cmdline long-opts, but not every single dash long-opt has a corresponding double dash long-opt, and vice verse. This changeset rectifies that. * lisp/startup.el (command-line-early): Add missing GNU style `--long-option' for all `-long-option' that were lacking it. (startup-setup-paths): ditto. (command-switch-alist): Add `-h'. * info/sxemacs/cmdargs.texi: Add missing command switches. * src/emacs.c (main_1): Add `-show-dump-id', `-terminal', `-no-dump-file', `-color-terminal', `-no-windows', `-h' command switches. Signed-off-by: Steve Youngs --- diff --git a/info/sxemacs/cmdargs.texi b/info/sxemacs/cmdargs.texi index f17db76..6c21829 100644 --- a/info/sxemacs/cmdargs.texi +++ b/info/sxemacs/cmdargs.texi @@ -64,38 +64,46 @@ Visit @var{file} using @code{find-file}, then go to line number @var{linenum} in it. @item -load @var{file} +@itemx --load @var{file} @itemx -l @var{file} Load a file @var{file} of Lisp code with the function @code{load}. @xref{Lisp Libraries}. @item -funcall @var{function} +@itemx --funcall @var{function} @itemx -f @var{function} Call Lisp function @var{function} with no arguments. @item -eval @var{function} +@itemx --eval @var{function} +@itemx -e @var{function} Interpret the next argument as a Lisp expression, and evaluate it. You must be very careful of the shell quoting here. @item -insert @var{file} +@itemx --insert @var{file} @itemx -i @var{file} Insert the contents of @var{file} into the current buffer. This is like what @kbd{M-x insert-buffer} does; @xref{Misc File Ops}. @item -kill +@itemx --kill Exit from SXEmacs without asking for confirmation. Always the last argument processed, no matter where it appears in the command line. @item -version +@itemx --version @itemx -V Prints version information. This implies @samp{-batch}. @example % sxemacs -version -SXEmacs: steve@@sxemacs.org--2006/sxemacs--main--22.1.4--patch-79, -built Sun Apr 9 05:36:50 2006 on bastard +SXEmacs: v22.1.15-131-gccf396e, built Sun May 10 07:40:48 2015 on bastard.steveyoungs.com @end example @item -help +@itemx --help +@itemx -h Prints a summary of command-line options and then exits. @end table @@ -105,24 +113,28 @@ command line. If more than one of them appears, they must appear in the order in which they appear in this table. @table @samp -@item --show-dump-id +@item -show-dump-id +@itemx --show-dump-id @itemx -sd Print the ID for the new portable dumper's dump file on the terminal and exit. (Prints an error message and exits if SXEmacs was not configured @samp{--pdump}.) -@item --no-dump-file +@item -no-dump-file +@itemx --no-dump-file @itemx -nd Don't load the dump file. Roughly equivalent to old temacs. (Ignored if SXEmacs was not configured @samp{--pdump}.) -@item --terminal @var{file} +@item -terminal @var{file} +@itemx --terminal @var{file} @itemx -t @var{file} Use @var{file} instead of the terminal for input and output. This implies the @samp{-nw} option, documented below. @cindex batch mode @item -batch +@itemx --batch Run SXEmacs in @dfn{batch mode}, which means that the text being edited is not displayed and the standard Unix interrupt characters such as @kbd{C-z} and @kbd{C-c} continue to have their normal effect. SXEmacs in @@ -139,13 +151,15 @@ causes SXEmacs to kill itself after all command switches have been processed. In addition, auto-saving is not done except in buffers for which it has been explicitly requested. -@item --no-windows +@item -no-windows +@itemx --no-windows @itemx -nw Start up SXEmacs in TTY mode (using the TTY SXEmacs was started from), rather than trying to connect to an X display. Note that this happens automatically if the @samp{DISPLAY} environment variable is not set. -@item --color-terminal +@item -color-terminal +@itemx --color-terminal @itemx -ct Tells SXEmacs to assume that any TTY frame should be colorized even when the color support was not detected. The color support is of @@ -153,42 +167,53 @@ the 8 color ANSI terminals. If color capabilities of the terminal are detected those more accurate settings are used. @item -debug-init +@itemx --debug-init Enter the debugger if an error in the init file occurs. @item -debug-paths +@itemx --debug-paths Displays information on how SXEmacs constructs the various paths into its hierarchy on startup. (See also @pxref{Startup Paths}.) @item -unmapped +@itemx --unmapped Do not map the initial frame. This is useful if you want to start up SXEmacs as a server (e.g. for gnuserv screens or external client widgets). @item -no-init-file +@itemx --no-init-file @itemx -q Do not load your SXEmacs init file. @xref{Init File}. @item -no-site-file +@itemx --no-site-file Do not load the site-specific init file @file{lisp/site-start.el}. @item -no-autoloads +@itemx --no-autoloads Do not load global symbol files (@file{auto-autoloads}) at startup. This implies @samp{-vanilla}. @item -no-early-packages +@itemx --no-early-packages Do not process early packages. (For more information on startup issues concerning the package system, @xref{Startup Paths}.) @item -vanilla +@itemx --vanilla This is equivalent to @samp{-q -no-site-file -no-early-packages}. @item -user-init-file @var{file} +@itemx --user-init-file @var{file} Load @var{file} as your SXEmacs init file instead of the default @file{$XDG_CONFIG_HOME/sxemacs/init.el}. @item -user-init-directory @var{directory} +@itemx --user-init-directory @var{directory} Use @var{directory} as the location of your initialization files. @item -user @var{user} +@itemx --user @var{user} @itemx -u @var{user} Attempt to load @var{user} init instead of your own. There is no privilege escalation going on, the SXEmacs process is still owned by diff --git a/lisp/startup.el b/lisp/startup.el index ce95a33..f7b5aef 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -199,9 +199,10 @@ after, and will not be true at any time before.") (defvar command-switch-alist '(("-help" . command-line-do-help) - ("-version". command-line-do-version) + ("-h" . command-line-do-help) + ("-version" . command-line-do-version) ("-V" . command-line-do-version) - ("-funcall". command-line-do-funcall) + ("-funcall" . command-line-do-funcall) ("-f" . command-line-do-funcall) ("-e" . command-line-do-funcall-1) ("-eval" . command-line-do-eval) @@ -516,9 +517,11 @@ Internal variable, DO NOT USE.") (setq arg (pop args)) (cond ((or (string= arg "-q") - (string= arg "-no-init-file")) + (string= arg "-no-init-file") + (string= arg "--no-init-file")) (setq load-user-init-file-p nil)) - ((string= arg "-no-site-file") + ((or (string= arg "-no-site-file") + (string= arg "--no-site-file")) (setq site-start-file nil)) ((or (string= arg "-no-early-packages") (string= arg "--no-early-packages")) @@ -533,9 +536,11 @@ Internal variable, DO NOT USE.") (string= arg "--no-autoloads")) (setq load-user-init-file-p nil site-start-file nil)) - ((string= arg "-user-init-file") + ((or (string= arg "-user-init-file") + (string= arg "--user-init-file")) (setq user-init-file (pop args))) - ((string= arg "-user-init-directory") + ((or (string= arg "-user-init-directory") + (string= arg "--user-init-directory")) (setq forced-user-init-directory t) (setq user-init-directory (file-name-as-directory (pop args))) (setq user-init-file (find-user-init-file user-init-directory)) @@ -553,7 +558,8 @@ Internal variable, DO NOT USE.") (paths-construct-path (list user-init-directory lisp-initd-basename))))) ((or (string= arg "-u") - (string= arg "-user")) + (string= arg "-user") + (string= arg "--user")) (let* ((user (pop args)) (home-user (concat "~" user)) (xdgdir (paths-construct-path @@ -580,9 +586,11 @@ Internal variable, DO NOT USE.") (file-name-as-directory (paths-construct-path (list user-init-directory lisp-initd-basename)))))) - ((string= arg "-debug-init") + ((or (string= arg "-debug-init") + (string= arg "--debug-init")) (setq init-file-debug t)) - ((string= arg "-unmapped") + ((or (string= arg "-unmapped") + (string= arg "--unmapped")) (setq initial-frame-unmapped-p t)) ((or (string= arg "-debug-paths") (string= arg "--debug-paths")) @@ -1155,7 +1163,8 @@ idempotent, so call this as often as you like!" ;; SXEmacs was started without any command line arg that would set ;; or change it. (let ((allargs command-line-args) - (initdargs '("-u" "-user" "-user-init-directory"))) + (initdargs '("-u" "-user" "--user" "-user-init-directory" + "--user-init-directory"))) (unless (or (member t (mapfam #'string= initdargs allargs :mode 'comb)) forced-user-init-directory) diff --git a/src/emacs.c b/src/emacs.c index 58970a2..0517f8c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1018,9 +1018,9 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart) /* Handle the -sd/--show-dump-id switch, which means show the hex dump_id and quit */ - if (argmatch(argv, argc, - "-sd", "--show-dump-id", - 9, NULL, &skip_args)) { + if (argmatch(argv, argc, "-show-dump-id", "--show-dump-id", 9, + NULL, &skip_args) + || argmatch(argv, argc, "-sd", 0, 3, NULL, &skip_args)) { #ifdef PDUMP printf("%08x\n", dump_id); #else @@ -1034,7 +1034,8 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart) { char *term; if (argmatch - (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) { + (argv, argc, "-terminal", "--terminal", 4, &term, &skip_args) + || argmatch(argv, argc, "-t", 0, 2, &term, &skip_args)) { int tdesc = -1; #ifdef HAVE_TTYNAME stderr_out("Opening for terminal usage %s (current: %s)\n", term, ttyname(0)); @@ -1083,19 +1084,24 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart) /* Handle the --no-dump-file/-nd switch, which means don't * load the dump file (ignored when not using pdump) */ - if (argmatch(argv, argc, "-nd", "--no-dump-file", 7, - NULL, &skip_args)) { + if (argmatch(argv, argc, "-no-dump-file", "--no-dump-file", 7, + NULL, &skip_args) + || argmatch(argv, argc, "-nd", 0, 3, NULL, &skip_args)) { nodumpfile = 1; } - if (argmatch(argv, argc, "-ct", "--color-terminal", 5, - NULL, &skip_args)) { + if (argmatch(argv, argc, "-color-terminal", "--color-terminal", 5, + NULL, &skip_args) + || argmatch(argv, argc, "-ct", 0, 3, NULL, &skip_args)) { assume_colorterm = 1; } /* Handle -nw switch */ - if (argmatch(argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args)) + if (argmatch(argv, argc, "-no-windows", "--no-windows", 6, NULL, + &skip_args) + || argmatch(argv, argc, "-nw", 0, 3, NULL, &skip_args)) { inhibit_window_system = 1; + } /* Handle the -batch switch, which means don't do interactive display */ if (argmatch(argv, argc, "-batch", "--batch", 5, NULL, &skip_args)) { @@ -1147,7 +1153,8 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart) /* Partially handle the -version and -help switches: they imply -batch, but are not removed from the list. */ - if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args)) + if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args) + || argmatch(argv, argc, "-h", 0, 2, NULL, &skip_args)) noninteractive = 1, skip_args--; if (argmatch(argv, argc, "-version", "--version", 3, NULL, &skip_args)