diff options
| author | Gerd Moellmann | 1999-10-26 14:35:16 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-10-26 14:35:16 +0000 |
| commit | dc2cd811d198c452058050007d88b8683b9d46a4 (patch) | |
| tree | ecc41787284ae094ff416973a27dbfd1c60e5c64 | |
| parent | 67a5596fa3e72172a0deeca74e2087f174a456e8 (diff) | |
| download | emacs-dc2cd811d198c452058050007d88b8683b9d46a4.tar.gz emacs-dc2cd811d198c452058050007d88b8683b9d46a4.zip | |
(command-line-1): Add support for `file' and
`execute'. Fix handling of `visit'.
| -rw-r--r-- | lisp/startup.el | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lisp/startup.el b/lisp/startup.el index bc9207d446c..53913211d1e 100644 --- a/lisp/startup.el +++ b/lisp/startup.el | |||
| @@ -88,6 +88,10 @@ | |||
| 88 | ;; of these are also found in term/pc-win.el | 88 | ;; of these are also found in term/pc-win.el |
| 89 | ;; ------------------------- | 89 | ;; ------------------------- |
| 90 | ;; FILE Visit FILE. | 90 | ;; FILE Visit FILE. |
| 91 | ;; -visit FILE | ||
| 92 | ;; --visit FILE | ||
| 93 | ;; -file FILE | ||
| 94 | ;; --file FILE | ||
| 91 | ;; | 95 | ;; |
| 92 | ;; -L DIRNAME Add DIRNAME to load-path | 96 | ;; -L DIRNAME Add DIRNAME to load-path |
| 93 | ;; -directory DIRNAME | 97 | ;; -directory DIRNAME |
| @@ -104,6 +108,8 @@ | |||
| 104 | ;; | 108 | ;; |
| 105 | ;; -eval FORM Execute Emacs lisp form FORM. | 109 | ;; -eval FORM Execute Emacs lisp form FORM. |
| 106 | ;; --eval FORM | 110 | ;; --eval FORM |
| 111 | ;; -execute EXPR | ||
| 112 | ;; --execute EXPR | ||
| 107 | ;; | 113 | ;; |
| 108 | ;; -insert FILE Insert the contents of FILE into buffer. | 114 | ;; -insert FILE Insert the contents of FILE into buffer. |
| 109 | ;; --insert FILE | 115 | ;; --insert FILE |
| @@ -956,7 +962,8 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 956 | ;; and long versions of what's on command-switch-alist. | 962 | ;; and long versions of what's on command-switch-alist. |
| 957 | (longopts | 963 | (longopts |
| 958 | (append '(("--funcall") ("--load") ("--insert") ("--kill") | 964 | (append '(("--funcall") ("--load") ("--insert") ("--kill") |
| 959 | ("--directory") ("--eval") ("--find-file") ("--visit")) | 965 | ("--directory") ("--eval") ("--execute") |
| 966 | ("--find-file") ("--visit") ("--file")) | ||
| 960 | (mapcar '(lambda (elt) | 967 | (mapcar '(lambda (elt) |
| 961 | (list (concat "-" (car elt)))) | 968 | (list (concat "-" (car elt)))) |
| 962 | command-switch-alist))) | 969 | command-switch-alist))) |
| @@ -1008,6 +1015,7 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 1008 | (cons argval command-line-args-left))) | 1015 | (cons argval command-line-args-left))) |
| 1009 | (funcall (cdr tem) argi)) | 1016 | (funcall (cdr tem) argi)) |
| 1010 | (funcall (cdr tem) argi))) | 1017 | (funcall (cdr tem) argi))) |
| 1018 | |||
| 1011 | ((or (string-equal argi "-f") ;what the manual claims | 1019 | ((or (string-equal argi "-f") ;what the manual claims |
| 1012 | (string-equal argi "-funcall") | 1020 | (string-equal argi "-funcall") |
| 1013 | (string-equal argi "-e")) ; what the source used to say | 1021 | (string-equal argi "-e")) ; what the source used to say |
| @@ -1018,13 +1026,16 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 1018 | (if (arrayp (symbol-function tem)) | 1026 | (if (arrayp (symbol-function tem)) |
| 1019 | (command-execute tem) | 1027 | (command-execute tem) |
| 1020 | (funcall tem))) | 1028 | (funcall tem))) |
| 1021 | ((string-equal argi "-eval") | 1029 | |
| 1030 | ((or (string-equal argi "-eval") | ||
| 1031 | (string-equal argi "-execute")) | ||
| 1022 | (if argval | 1032 | (if argval |
| 1023 | (setq tem argval) | 1033 | (setq tem argval) |
| 1024 | (setq tem (car command-line-args-left)) | 1034 | (setq tem (car command-line-args-left)) |
| 1025 | (setq command-line-args-left (cdr command-line-args-left))) | 1035 | (setq command-line-args-left (cdr command-line-args-left))) |
| 1026 | (eval (read tem))) | 1036 | (eval (read tem))) |
| 1027 | ;; Set the default directory as specified in -L. | 1037 | ;; Set the default directory as specified in -L. |
| 1038 | |||
| 1028 | ((or (string-equal argi "-L") | 1039 | ((or (string-equal argi "-L") |
| 1029 | (string-equal argi "-directory")) | 1040 | (string-equal argi "-directory")) |
| 1030 | (if argval | 1041 | (if argval |
| @@ -1036,6 +1047,7 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 1036 | (cons (expand-file-name tem) extra-load-path)) | 1047 | (cons (expand-file-name tem) extra-load-path)) |
| 1037 | (setq load-path (append (nreverse extra-load-path) | 1048 | (setq load-path (append (nreverse extra-load-path) |
| 1038 | initial-load-path))) | 1049 | initial-load-path))) |
| 1050 | |||
| 1039 | ((or (string-equal argi "-l") | 1051 | ((or (string-equal argi "-l") |
| 1040 | (string-equal argi "-load")) | 1052 | (string-equal argi "-load")) |
| 1041 | (if argval | 1053 | (if argval |
| @@ -1048,6 +1060,7 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 1048 | (if (file-exists-p (expand-file-name file)) | 1060 | (if (file-exists-p (expand-file-name file)) |
| 1049 | (setq file (expand-file-name file))) | 1061 | (setq file (expand-file-name file))) |
| 1050 | (load file nil t))) | 1062 | (load file nil t))) |
| 1063 | |||
| 1051 | ((string-equal argi "-insert") | 1064 | ((string-equal argi "-insert") |
| 1052 | (if argval | 1065 | (if argval |
| 1053 | (setq tem argval) | 1066 | (setq tem argval) |
| @@ -1056,28 +1069,38 @@ Type \\[describe-distribution] for information on getting the latest version.")) | |||
| 1056 | (or (stringp tem) | 1069 | (or (stringp tem) |
| 1057 | (error "File name omitted from `-insert' option")) | 1070 | (error "File name omitted from `-insert' option")) |
| 1058 | (insert-file-contents (command-line-normalize-file-name tem))) | 1071 | (insert-file-contents (command-line-normalize-file-name tem))) |
| 1072 | |||
| 1059 | ((string-equal argi "-kill") | 1073 | ((string-equal argi "-kill") |
| 1060 | (kill-emacs t)) | 1074 | (kill-emacs t)) |
| 1075 | |||
| 1061 | ((string-match "^\\+[0-9]+\\'" argi) | 1076 | ((string-match "^\\+[0-9]+\\'" argi) |
| 1062 | (setq line (string-to-int argi))) | 1077 | (setq line (string-to-int argi))) |
| 1078 | |||
| 1063 | ((setq tem (assoc argi command-line-x-option-alist)) | 1079 | ((setq tem (assoc argi command-line-x-option-alist)) |
| 1064 | ;; Ignore X-windows options and their args if not using X. | 1080 | ;; Ignore X-windows options and their args if not using X. |
| 1065 | (setq command-line-args-left | 1081 | (setq command-line-args-left |
| 1066 | (nthcdr (nth 1 tem) command-line-args-left))) | 1082 | (nthcdr (nth 1 tem) command-line-args-left))) |
| 1083 | |||
| 1067 | ((or (string-equal argi "-find-file") | 1084 | ((or (string-equal argi "-find-file") |
| 1085 | (string-equal argi "-file") | ||
| 1068 | (string-equal argi "-visit")) | 1086 | (string-equal argi "-visit")) |
| 1069 | ;; An explicit option to specify visiting a file. | 1087 | ;; An explicit option to specify visiting a file. |
| 1088 | (if argval | ||
| 1089 | (setq tem argval) | ||
| 1090 | (setq tem (car command-line-args-left) | ||
| 1091 | command-line-args-left (cdr command-line-args-left))) | ||
| 1092 | (unless (stringp tem) | ||
| 1093 | (error "File name omitted from `%s' option" argi)) | ||
| 1070 | (setq file-count (1+ file-count)) | 1094 | (setq file-count (1+ file-count)) |
| 1071 | (let ((file | 1095 | (let ((file (expand-file-name |
| 1072 | (expand-file-name | 1096 | (command-line-normalize-file-name tem) dir))) |
| 1073 | (command-line-normalize-file-name orig-argi) | ||
| 1074 | dir))) | ||
| 1075 | (if (= file-count 1) | 1097 | (if (= file-count 1) |
| 1076 | (setq first-file-buffer (find-file file)) | 1098 | (setq first-file-buffer (find-file file)) |
| 1077 | (find-file-other-window file))) | 1099 | (find-file-other-window file))) |
| 1078 | (or (zerop line) | 1100 | (or (zerop line) |
| 1079 | (goto-line line)) | 1101 | (goto-line line)) |
| 1080 | (setq line 0)) | 1102 | (setq line 0)) |
| 1103 | |||
| 1081 | ((equal argi "--") | 1104 | ((equal argi "--") |
| 1082 | (setq just-files t)) | 1105 | (setq just-files t)) |
| 1083 | (t | 1106 | (t |