diff options
author | Richard M. Stallman <rms@gnu.org> | 1994-11-19 20:42:26 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1994-11-19 20:42:26 +0000 |
commit | 629a7bcc00befef37e5cafeeb2656458f0eb6dd9 (patch) | |
tree | 0520926201b7f01b29fbd40b9b8227524da6ed4c /lisp/startup.el | |
parent | 5016780a585c10fbf6a747f3dcf821497ef386c6 (diff) | |
download | emacs-629a7bcc00befef37e5cafeeb2656458f0eb6dd9.tar.gz |
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
(command-line): Don't leave argval set if option not really a long one.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r-- | lisp/startup.el | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/lisp/startup.el b/lisp/startup.el index b2b87c94754..0b34117a00f 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -322,7 +322,8 @@ specified by the LC_ALL, LC_CTYPE and LANG environment variables.") (let ((elt (assoc completion longopts))) (or elt (error "Option `%s' is ambiguous" argi)) - (setq argi (substring (car elt) 1)))))) + (setq argi (substring (car elt) 1))) + (setq argval nil)))) (cond ((or (string-equal argi "-q") (string-equal argi "-no-init-file")) @@ -547,31 +548,68 @@ Type \\[describe-distribution] for information on getting the latest version.")) first-file-buffer (line 0)) (while command-line-args-left - (let ((argi (car command-line-args-left)) - tem) + (let* ((argi (car command-line-args-left)) + (orig-argi argi) + ;; This includes our standard options' long versions + ;; and long versions of what's on command-switch-alist. + (longopts + (append '(("--funcall") ("--load") ("--insert") ("--kill")) + (mapcar '(lambda (elt) + (list (concat "-" (car elt)))) + command-switch-alist))) + tem argval completion) (setq command-line-args-left (cdr command-line-args-left)) + + ;; Convert long options to ordinary options + ;; and separate out an attached option argument into argval. + (if (string-match "^--[^=]*=" argi) + (setq argval (substring argi (match-end 0)) + argi (substring argi 0 (1- (match-end 0))))) + (setq completion (try-completion argi longopts)) + (if (eq completion t) + (setq argi (substring argi 1)) + (if (stringp completion) + (let ((elt (assoc completion longopts))) + (or elt + (error "Option `%s' is ambiguous" argi)) + (setq argi (substring (car elt) 1))) + (setq argval nil argi orig-argi))) + + ;; Execute the option. (cond ((setq tem (assoc argi command-switch-alist)) - (funcall (cdr tem) argi)) + (if argval + (let ((command-line-args-left + (cons argval command-line-args-left))) + (funcall (cdr tem) argi)) + (funcall (cdr tem) argi))) ((or (string-equal argi "-f") ;what the manual claims (string-equal argi "-funcall") (string-equal argi "-e")) ; what the source used to say - (setq tem (intern (car command-line-args-left))) - (setq command-line-args-left (cdr command-line-args-left)) + (if argval + (setq tem (intern argval)) + (setq tem (intern (car command-line-args-left))) + (setq command-line-args-left (cdr command-line-args-left))) (funcall tem)) ((or (string-equal argi "-l") (string-equal argi "-load")) - (let ((file (car command-line-args-left))) + (if argval + (setq tem argval) + (setq tem (car command-line-args-left) + command-line-args-left (cdr command-line-args-left))) + (let ((file tem)) ;; Take file from default dir if it exists there; ;; otherwise let `load' search for it. (if (file-exists-p (expand-file-name file)) (setq file (expand-file-name file))) - (load file nil t)) - (setq command-line-args-left (cdr command-line-args-left))) + (load file nil t))) ((string-equal argi "-insert") (or (stringp (car command-line-args-left)) - (error "filename omitted from `-insert' option")) - (insert-file-contents (car command-line-args-left)) - (setq command-line-args-left (cdr command-line-args-left))) + (error "File name omitted from `-insert' option")) + (if argval + (setq tem argval) + (setq tem (car command-line-args-left) + command-line-args-left (cdr command-line-args-left))) + (insert-file-contents tem)) ((string-equal argi "-kill") (kill-emacs t)) ((string-match "^\\+[0-9]+\\'" argi) |