658
|
1 ;;; startup.el --- process Emacs shell arguments
|
|
2
|
12413
|
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc.
|
840
|
4
|
787
|
5 ;; Maintainer: FSF
|
814
|
6 ;; Keywords: internal
|
787
|
7
|
322
|
8 ;; This file is part of GNU Emacs.
|
|
9
|
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
11 ;; it under the terms of the GNU General Public License as published by
|
621
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
322
|
13 ;; any later version.
|
|
14
|
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 ;; GNU General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
23
|
787
|
24 ;;; Commentary:
|
322
|
25
|
11633
|
26 ;; This file parses the command line and gets Emacs running. Options on
|
|
27 ;; the command line are handled in precedence order. The order is the
|
|
28 ;; one in the list below; first described means first handled. Options
|
|
29 ;; within each category (delimited by a bar) are handled in the order
|
|
30 ;; encountered on the command line.
|
11625
|
31
|
11633
|
32 ;; -------------------------
|
|
33 ;; -version Print Emacs version to stderr, then exit
|
|
34 ;; --version successfully right away.
|
|
35 ;; This option is handled by emacs.c
|
|
36 ;; -------------------------
|
|
37 ;; -help Print a short usage description and exit
|
|
38 ;; --help successfully right away.
|
|
39 ;; This option is handled by emacs.c
|
|
40 ;; -------------------------
|
|
41 ;; -nl Do not use shared memory (for systems that
|
|
42 ;; -no-shared-memory support this) for the dumped Emacs data.
|
|
43 ;; This option is handled by emacs.c
|
|
44 ;;
|
|
45 ;; -map For VMS.
|
|
46 ;; --map-data This option is handled by emacs.c
|
|
47 ;; -------------------------
|
|
48 ;; -t FILE Use FILE as the name of the terminal.
|
|
49 ;; --terminal FILE Using this implies "-nw" also.
|
|
50 ;; This option is handled by emacs.c
|
|
51 ;; -------------------------
|
|
52 ;; -d DISPNAME Use DISPNAME as the name of the X-windows
|
|
53 ;; -display DISPNAME display for the initial frame.
|
|
54 ;; --display DISPNAME This option is handled by emacs.c
|
|
55 ;; -------------------------
|
|
56 ;; -nw Do not use a windows system (but use the
|
|
57 ;; --no-windows terminal instead.)
|
|
58 ;; This option is handled by emacs.c
|
|
59 ;; -------------------------
|
|
60 ;; -batch Execute noninteractively (messages go to stdout,
|
|
61 ;; --batch variable noninteractive set to t)
|
|
62 ;; This option is handled by emacs.c
|
|
63 ;; -------------------------
|
|
64 ;; -q Do not load user's init file and do not load
|
|
65 ;; -no-init-file "default.el". Regardless of this switch,
|
12563
|
66 ;; --no-init-file "site-start" is still loaded.
|
11633
|
67 ;; -------------------------
|
12563
|
68 ;; -no-site-file Do not load "site-start.el". (This is the ONLY
|
11633
|
69 ;; --no-site-file way to prevent loading that file.)
|
|
70 ;; -------------------------
|
|
71 ;; -u USER Load USER's init file instead of the init
|
|
72 ;; -user USER file belonging to the user starting Emacs.
|
|
73 ;; --user USER
|
|
74 ;; -------------------------
|
|
75 ;; -debug-init Don't catch errors in init files; let the
|
|
76 ;; --debug-init debugger run.
|
|
77 ;; -------------------------
|
|
78 ;; -i ICONTYPE Set type of icon using when Emacs is
|
|
79 ;; -itype ICONTYPE iconified under X-windows.
|
|
80 ;; --icon-type ICONTYPE This option is passed on to term/x-win.el
|
|
81 ;;
|
|
82 ;; -iconic Start Emacs iconified under X-windows.
|
|
83 ;; --iconic This option is passed on to term/x-win.el
|
|
84 ;; -------------------------
|
|
85 ;; Various X-windows options for colors/fonts/geometry/title etc.
|
|
86 ;; These options are passed on to term/x-win.el which see. Certain
|
|
87 ;; of these are also found in term/pc-win.el
|
|
88 ;; -------------------------
|
|
89 ;; FILE Visit FILE.
|
|
90 ;;
|
|
91 ;; -L DIRNAME Add DIRNAME to load-path
|
|
92 ;; -directory DIRNAME
|
|
93 ;; --directory DIRNAME
|
|
94 ;;
|
|
95 ;; -l FILE Load and execute the Emacs lisp code
|
|
96 ;; -load FILE in FILE.
|
|
97 ;; --load FILE
|
|
98 ;;
|
|
99 ;; -f FUNC Execute Emacs lisp function FUNC with
|
|
100 ;; -funcall FUNC no arguments. The "-e" form is outdated
|
|
101 ;; --funcall FUNC and should not be used. (It's a typo
|
|
102 ;; -e FUNC promoted to a feature.)
|
|
103 ;;
|
13072
|
104 ;; -eval FORM Execute Emacs lisp form FORM.
|
|
105 ;; --eval FORM
|
12849
|
106 ;;
|
11633
|
107 ;; -insert FILE Insert the contents of FILE into buffer.
|
|
108 ;; --insert FILE
|
|
109 ;; -------------------------
|
|
110 ;; -kill Kill (exit) Emacs right away.
|
|
111 ;; --kill
|
|
112 ;; -------------------------
|
322
|
113
|
787
|
114 ;;; Code:
|
|
115
|
322
|
116 (setq top-level '(normal-top-level))
|
|
117
|
|
118 (defvar command-line-processed nil "t once command line has been processed")
|
|
119
|
|
120 (defconst inhibit-startup-message nil
|
5930
|
121 "*Non-nil inhibits the initial startup message.
|
322
|
122 This is for use in your personal init file, once you are familiar
|
|
123 with the contents of the startup message.")
|
|
124
|
5930
|
125 (defconst inhibit-startup-echo-area-message nil
|
|
126 "*Non-nil inhibits the initial startup echo area message.
|
|
127 Inhibition takes effect only if your `.emacs' file contains
|
7880
|
128 a line of this form:
|
6119
|
129 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
|
7880
|
130 If your `.emacs' file is byte-compiled, use the following form instead:
|
|
131 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
|
5930
|
132 Thus, someone else using a copy of your `.emacs' file will see
|
|
133 the startup message unless he personally acts to inhibit it.")
|
|
134
|
322
|
135 (defconst inhibit-default-init nil
|
|
136 "*Non-nil inhibits loading the `default' library.")
|
|
137
|
|
138 (defconst command-switch-alist nil
|
|
139 "Alist of command-line switches.
|
|
140 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
|
|
141 HANDLER-FUNCTION receives switch name as sole arg;
|
|
142 remaining command-line args are in the variable `command-line-args-left'.")
|
|
143
|
8335
|
144 (defvar command-line-args-left nil
|
|
145 "List of command-line args not yet processed.")
|
|
146
|
322
|
147 (defvar command-line-functions nil ;; lrs 7/31/89
|
|
148 "List of functions to process unrecognized command-line arguments.
|
|
149 Each function should access the dynamically bound variables
|
6593
|
150 `argi' (the current argument) and `command-line-args-left' (the remaining
|
322
|
151 arguments). The function should return non-nil only if it recognizes and
|
6593
|
152 processes `argi'. If it does so, it may consume successive arguments by
|
|
153 altering `command-line-args-left' to remove them.")
|
322
|
154
|
7022
|
155 (defvar command-line-default-directory nil
|
|
156 "Default directory to use for command line arguments.
|
|
157 This is normally copied from `default-directory' when Emacs starts.")
|
|
158
|
688
|
159 (defvar before-init-hook nil
|
6593
|
160 "Functions to call after handling urgent options but before init files.
|
779
|
161 The frame system uses this to open frames to display messages while
|
370
|
162 Emacs loads the user's initialization file.")
|
|
163
|
688
|
164 (defvar after-init-hook nil
|
1550
|
165 "Functions to call after loading the init file (`~/.emacs').
|
688
|
166 The call is not protected by a condition-case, so you can set `debug-on-error'
|
1550
|
167 in `.emacs', and put all the actual code on `after-init-hook'.")
|
688
|
168
|
322
|
169 (defvar term-setup-hook nil
|
6593
|
170 "Functions to be called after loading terminal-specific Lisp code.
|
688
|
171 See `run-hooks'. This variable exists for users to set,
|
322
|
172 so as to override the definitions made by the terminal-specific file.
|
|
173 Emacs never sets this variable itself.")
|
|
174
|
|
175 (defvar keyboard-type nil
|
6593
|
176 "The brand of keyboard you are using.
|
|
177 This variable is used to define
|
322
|
178 the proper function and keypad keys for use under X. It is used in a
|
|
179 fashion analogous to the environment value TERM.")
|
|
180
|
|
181 (defvar window-setup-hook nil
|
6593
|
182 "Normal hook run to initialize window system display.
|
|
183 Emacs runs this hook after processing the command line arguments and loading
|
|
184 the user's init file.")
|
322
|
185
|
|
186 (defconst initial-major-mode 'lisp-interaction-mode
|
|
187 "Major mode command symbol to use for the initial *scratch* buffer.")
|
|
188
|
|
189 (defvar init-file-user nil
|
|
190 "Identity of user whose `.emacs' file is or was read.
|
6980
|
191 The value is nil if no init file is being used; otherwise, it may be either
|
|
192 the null string, meaning that the init file was taken from the user that
|
|
193 originally logged in, or it may be a string containing a user's name.
|
322
|
194
|
6980
|
195 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
|
|
196 evaluates to the name of the directory where the `.emacs' file was
|
11083
|
197 looked for.
|
|
198
|
|
199 Setting `init-file-user' does not prevent Emacs from loading
|
|
200 `site-start.el'. The only way to do that is to use `--no-site-file'.")
|
322
|
201
|
4599
|
202 (defvar site-run-file "site-start"
|
|
203 "File containing site-wide run-time initializations.
|
|
204 This file is loaded at run-time before `~/.emacs'. It contains inits
|
|
205 that need to be in place for the entire site, but which, due to their
|
|
206 higher incidence of change, don't make sense to load into emacs'
|
|
207 dumped image. Thus, the run-time load order is: 1. file described in
|
11083
|
208 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
|
|
209
|
|
210 Don't use the `site-start.el' file for things some users may not like.
|
|
211 Put them in `default.el' instead, so that users can more easily
|
|
212 override them. Users can prevent loading `default.el' with the `-q'
|
|
213 option or by setting `inhibit-default-init' in their own init files,
|
|
214 but inhibiting `site-start.el' requires `--no-site-file', which
|
|
215 is less convenient.")
|
4599
|
216
|
8147
|
217 (defconst iso-8859-1-locale-regexp "8859[-_]?1"
|
|
218 "Regexp that specifies when to enable the ISO 8859-1 character set.
|
|
219 We do that if this regexp matches the locale name
|
|
220 specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
|
|
221
|
8989
|
222 (defvar mail-host-address nil
|
|
223 "*Name of this machine, for purposes of naming users.")
|
|
224
|
8048
|
225 (defvar user-mail-address nil
|
13479
|
226 "*Full mailing address of this user.
|
|
227 This is initialized based on `mail-host-address',
|
|
228 after your init file is read, in case it sets `mail-host-address'.")
|
8048
|
229
|
13117
|
230 (defvar auto-save-list-file-prefix "~/.saves-"
|
|
231 "Prefix for generating auto-save-list-file-name.
|
|
232 Emacs's pid and the system name will be appended to
|
|
233 this prefix to create a unique file name.")
|
|
234
|
322
|
235 (defvar init-file-debug nil)
|
|
236
|
5109
|
237 (defvar init-file-had-error nil)
|
|
238
|
9443
|
239 ;; This function is called from the subdirs.el file.
|
|
240 (defun normal-top-level-add-to-load-path (dirs)
|
|
241 (let ((tail (member default-directory load-path)))
|
|
242 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail)))))
|
|
243
|
322
|
244 (defun normal-top-level ()
|
|
245 (if command-line-processed
|
|
246 (message "Back to top level.")
|
|
247 (setq command-line-processed t)
|
11294
|
248 ;; Give *Messages* the same default-directory as *scratch*,
|
|
249 ;; just to keep things predictable.
|
|
250 (let ((dir default-directory))
|
|
251 (save-excursion
|
|
252 (set-buffer (get-buffer "*Messages*"))
|
|
253 (setq default-directory dir)))
|
9443
|
254 ;; Look in each dir in load-path for a subdirs.el file.
|
|
255 ;; If we find one, load it, which will add the appropriate subdirs
|
|
256 ;; of that dir into load-path,
|
|
257 (let ((tail load-path)
|
|
258 new)
|
|
259 (while tail
|
|
260 (setq new (cons (car tail) new))
|
|
261 (let ((default-directory (car tail)))
|
|
262 (load (expand-file-name "subdirs.el" (car tail)) t t t))
|
|
263 (setq tail (cdr tail))))
|
648
|
264 (if (not (eq system-type 'vax-vms))
|
1558
|
265 (progn
|
|
266 ;; If the PWD environment variable isn't accurate, delete it.
|
|
267 (let ((pwd (getenv "PWD")))
|
|
268 (and (stringp pwd)
|
|
269 ;; Use FOO/., so that if FOO is a symlink, file-attributes
|
|
270 ;; describes the directory linked to, not FOO itself.
|
|
271 (or (equal (file-attributes
|
|
272 (concat (file-name-as-directory pwd) "."))
|
|
273 (file-attributes
|
|
274 (concat (file-name-as-directory default-directory)
|
|
275 ".")))
|
|
276 (setq process-environment
|
|
277 (delete (concat "PWD=" pwd)
|
|
278 process-environment)))))))
|
707
|
279 (setq default-directory (abbreviate-file-name default-directory))
|
7371
|
280 (let ((menubar-bindings-done nil))
|
|
281 (unwind-protect
|
|
282 (command-line)
|
|
283 ;; Do this again, in case .emacs defined more abbreviations.
|
|
284 (setq default-directory (abbreviate-file-name default-directory))
|
13279
|
285 ;; Specify the file for recording all the auto save files of this session.
|
|
286 ;; This is used by recover-session.
|
|
287 (setq auto-save-list-file-name
|
|
288 (expand-file-name
|
|
289 (format "%s%d-%s"
|
|
290 auto-save-list-file-prefix
|
|
291 (emacs-pid)
|
|
292 (system-name))))
|
7371
|
293 (run-hooks 'emacs-startup-hook)
|
|
294 (and term-setup-hook
|
|
295 (run-hooks 'term-setup-hook))
|
|
296 ;; Modify the initial frame based on what .emacs puts into
|
|
297 ;; ...-frame-alist.
|
|
298 (if (fboundp 'frame-notice-user-settings)
|
|
299 (frame-notice-user-settings))
|
|
300 ;; Now we know the user's default font, so add it to the menu.
|
|
301 (if (fboundp 'font-menu-add-default)
|
|
302 (font-menu-add-default))
|
|
303 (and window-setup-hook
|
|
304 (run-hooks 'window-setup-hook))
|
|
305 (or menubar-bindings-done
|
13430
abcf51439209
[win32] (normal-top-level, command-line, command-line-1):
Geoff Voelker <voelker@cs.washington.edu>
diff
changeset
|
306 (if (or (eq window-system 'x) (eq window-system 'win32))
|
12300
|
307 (precompute-menubar-bindings)))))))
|
7371
|
308
|
|
309 ;; Precompute the keyboard equivalents in the menu bar items.
|
|
310 (defun precompute-menubar-bindings ()
|
12300
|
311 (let ((submap (lookup-key global-map [menu-bar])))
|
|
312 (while submap
|
|
313 (and (consp (car submap))
|
|
314 (symbolp (car (car submap)))
|
|
315 (stringp (car-safe (cdr (car submap))))
|
|
316 (keymapp (cdr (cdr (car submap))))
|
12346
|
317 (progn
|
|
318 (x-popup-menu nil (cdr (cdr (car submap))))
|
|
319 (if purify-flag
|
|
320 (garbage-collect))))
|
12300
|
321 (setq submap (cdr submap))))
|
|
322 (setq define-key-rebound-commands t))
|
322
|
323
|
|
324 (defun command-line ()
|
7022
|
325 (setq command-line-default-directory default-directory)
|
|
326
|
823
|
327 ;; See if we should import version-control from the environment variable.
|
322
|
328 (let ((vc (getenv "VERSION_CONTROL")))
|
|
329 (cond ((eq vc nil)) ;don't do anything if not set
|
|
330 ((or (string= vc "t")
|
|
331 (string= vc "numbered"))
|
|
332 (setq version-control t))
|
|
333 ((or (string= vc "nil")
|
|
334 (string= vc "existing"))
|
|
335 (setq version-control nil))
|
|
336 ((or (string= vc "never")
|
|
337 (string= vc "simple"))
|
|
338 (setq version-control 'never))))
|
|
339
|
8147
|
340 (if (let ((ctype
|
|
341 ;; Use the first of these three envvars that has a nonempty value.
|
|
342 (or (let ((string (getenv "LC_ALL")))
|
|
343 (and (not (equal string "")) string))
|
|
344 (let ((string (getenv "LC_CTYPE")))
|
|
345 (and (not (equal string "")) string))
|
|
346 (let ((string (getenv "LANG")))
|
|
347 (and (not (equal string "")) string)))))
|
|
348 (and ctype
|
|
349 (string-match iso-8859-1-locale-regexp ctype)))
|
8127
|
350 (progn
|
9348
|
351 (require 'disp-table)
|
8127
|
352 (standard-display-european t)
|
|
353 (require 'iso-syntax)))
|
|
354
|
755
|
355 ;;! This has been commented out; I currently find the behavior when
|
|
356 ;;! split-window-keep-point is nil disturbing, but if I can get used
|
|
357 ;;! to it, then it would be better to eliminate the option.
|
|
358 ;;! ;; Choose a good default value for split-window-keep-point.
|
|
359 ;;! (setq split-window-keep-point (> baud-rate 2400))
|
384
|
360
|
322
|
361 ;; Read window system's init file if using a window system.
|
8748
|
362 (condition-case error
|
|
363 (if (and window-system (not noninteractive))
|
|
364 (load (concat term-file-prefix
|
|
365 (symbol-name window-system)
|
|
366 "-win")
|
|
367 ;; Every window system should have a startup file;
|
|
368 ;; barf if we can't find it.
|
|
369 nil t))
|
|
370 ;; If we can't read it, print the error message and exit.
|
|
371 (error
|
8749
|
372 (princ
|
|
373 (if (eq (car error) 'error)
|
|
374 (apply 'concat (cdr error))
|
|
375 (if (memq 'file-error (get (car error) 'error-conditions))
|
|
376 (format "%s: %s"
|
|
377 (nth 1 error)
|
|
378 (mapconcat '(lambda (obj) (prin1-to-string obj t))
|
|
379 (cdr (cdr error)) ", "))
|
|
380 (format "%s: %s"
|
|
381 (get (car error) 'error-message)
|
|
382 (mapconcat '(lambda (obj) (prin1-to-string obj t))
|
|
383 (cdr error) ", "))))
|
|
384 'external-debugging-output)
|
|
385 (setq window-system nil)
|
8748
|
386 (kill-emacs)))
|
322
|
387
|
326
|
388 (let ((done nil)
|
|
389 (args (cdr command-line-args)))
|
|
390
|
322
|
391 ;; Figure out which user's init file to load,
|
|
392 ;; either from the environment or from the options.
|
|
393 (setq init-file-user (if noninteractive nil (user-login-name)))
|
|
394 ;; If user has not done su, use current $HOME to find .emacs.
|
|
395 (and init-file-user (string= init-file-user (user-real-login-name))
|
|
396 (setq init-file-user ""))
|
326
|
397
|
|
398 ;; Process the command-line args, and delete the arguments
|
|
399 ;; processed. This is consistent with the way main in emacs.c
|
|
400 ;; does things.
|
322
|
401 (while (and (not done) args)
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
402 (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
|
11620
|
403 ("--debug-init") ("--iconic") ("--icon-type")))
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
404 (argi (car args))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
405 (argval nil))
|
13479
|
406 ;; Handle --OPTION=VALUE format.
|
|
407 (if (and (string-match "\\`--" argi)
|
|
408 (string-match "=" argi))
|
9174
|
409 (setq argval (substring argi (match-end 0))
|
|
410 argi (substring argi 0 (match-beginning 0))))
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
411 (let ((completion (try-completion argi longopts)))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
412 (if (eq completion t)
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
413 (setq argi (substring argi 1))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
414 (if (stringp completion)
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
415 (let ((elt (assoc completion longopts)))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
416 (or elt
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
417 (error "Option `%s' is ambiguous" argi))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
418 (setq argi (substring (car elt) 1)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
419 (setq argval nil))))
|
322
|
420 (cond
|
|
421 ((or (string-equal argi "-q")
|
|
422 (string-equal argi "-no-init-file"))
|
|
423 (setq init-file-user nil
|
|
424 args (cdr args)))
|
|
425 ((or (string-equal argi "-u")
|
|
426 (string-equal argi "-user"))
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
427 (or argval
|
12397
|
428 (setq args (cdr args)
|
|
429 argval (car args)))
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
430 (setq init-file-user argval
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
431 argval nil
|
322
|
432 args (cdr args)))
|
4599
|
433 ((string-equal argi "-no-site-file")
|
|
434 (setq site-run-file nil
|
|
435 args (cdr args)))
|
322
|
436 ((string-equal argi "-debug-init")
|
|
437 (setq init-file-debug t
|
|
438 args (cdr args)))
|
11620
|
439 ((string-equal argi "-iconic")
|
|
440 (setq initial-frame-alist
|
|
441 (cons '(visibility . icon) initial-frame-alist))
|
|
442 (setq args (cdr args)))
|
|
443 ((or (string-equal argi "-icon-type")
|
|
444 (string-equal argi "-i")
|
|
445 (string-equal argi "-itype"))
|
|
446 (setq default-frame-alist
|
|
447 (cons '(icon-type . t) default-frame-alist))
|
|
448 (setq args (cdr args)))
|
9173
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
449 (t (setq done t)))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
450 ;; Was argval set but not used?
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
451 (and argval
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
452 (error "Option `%s' doesn't allow an argument" argi))))
|
6ee3eeec722b
(command-line): Recognize --longopt synonyms for all options handled here.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
453
|
326
|
454 ;; Re-attach the program name to the front of the arg list.
|
11947
|
455 (and command-line-args (setcdr command-line-args args)))
|
322
|
456
|
2761
|
457 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
|
6874
|
458 (if (fboundp 'face-initialize)
|
|
459 (face-initialize))
|
2869
|
460 (if (fboundp 'frame-initialize)
|
|
461 (frame-initialize))
|
8759
19d9177069c4
(command-line): If initial X frame has a menu bar, mark menu-bar-mode as on.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
462 ;; If frame was created with a menu bar, set menu-bar-mode on.
|
13430
abcf51439209
[win32] (normal-top-level, command-line, command-line-1):
Geoff Voelker <voelker@cs.washington.edu>
diff
changeset
|
463 (if (or (not (or (eq window-system 'x) (eq window-system 'win32)))
|
13371
|
464 (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
|
8759
19d9177069c4
(command-line): If initial X frame has a menu bar, mark menu-bar-mode as on.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
465 (menu-bar-mode t))
|
2761
|
466
|
688
|
467 (run-hooks 'before-init-hook)
|
370
|
468
|
883
|
469 ;; Run the site-start library if it exists. The point of this file is
|
|
470 ;; that it is run before .emacs. There is no point in doing this after
|
|
471 ;; .emacs; that is useless.
|
4599
|
472 (if site-run-file
|
|
473 (load site-run-file t t))
|
883
|
474
|
4672
|
475 ;; Sites should not disable this. Only individuals should disable
|
|
476 ;; the startup message.
|
|
477 (setq inhibit-startup-message nil)
|
|
478
|
322
|
479 ;; Load that user's init file, or the default one, or none.
|
5379
|
480 (let (debug-on-error-from-init-file
|
|
481 debug-on-error-should-be-set
|
|
482 (debug-on-error-initial
|
|
483 (if (eq init-file-debug t) 'startup init-file-debug)))
|
|
484 (let ((debug-on-error debug-on-error-initial)
|
|
485 ;; This function actually reads the init files.
|
|
486 (inner
|
|
487 (function
|
|
488 (lambda ()
|
|
489 (if init-file-user
|
5450
|
490 (progn
|
|
491 (setq user-init-file
|
|
492 (cond
|
|
493 ((eq system-type 'ms-dos)
|
|
494 (concat "~" init-file-user "/_emacs"))
|
9778
|
495 ((eq system-type 'windows-nt)
|
|
496 "~/_emacs")
|
5450
|
497 ((eq system-type 'vax-vms)
|
|
498 "sys$login:.emacs")
|
|
499 (t
|
|
500 (concat "~" init-file-user "/.emacs"))))
|
|
501 (load user-init-file t t t)
|
|
502 (or inhibit-default-init
|
|
503 (let ((inhibit-startup-message nil))
|
|
504 ;; Users are supposed to be told their rights.
|
|
505 ;; (Plus how to get help and how to undo.)
|
|
506 ;; Don't you dare turn this off for anyone
|
|
507 ;; except yourself.
|
|
508 (load "default" t t)))))))))
|
5379
|
509 (if init-file-debug
|
|
510 ;; Do this without a condition-case if the user wants to debug.
|
|
511 (funcall inner)
|
|
512 (condition-case error
|
|
513 (progn
|
|
514 (funcall inner)
|
|
515 (setq init-file-had-error nil))
|
|
516 (error (message "Error in init file: %s%s%s"
|
|
517 (get (car error) 'error-message)
|
6911
|
518 (if (cdr error) ": " "")
|
5379
|
519 (mapconcat 'prin1-to-string (cdr error) ", "))
|
|
520 (setq init-file-had-error t))))
|
6911
|
521 ;; If we can tell that the init file altered debug-on-error,
|
5379
|
522 ;; arrange to preserve the value that it set up.
|
|
523 (or (eq debug-on-error debug-on-error-initial)
|
|
524 (setq debug-on-error-should-be-set t
|
|
525 debug-on-error-from-init-file debug-on-error)))
|
|
526 (if debug-on-error-should-be-set
|
|
527 (setq debug-on-error debug-on-error-from-init-file)))
|
370
|
528
|
13153
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
529 ;; Do this here in case the init file sets mail-host-address.
|
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
530 (or user-mail-address
|
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
531 (setq user-mail-address (concat (user-login-name) "@"
|
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
532 (or mail-host-address
|
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
533 (system-name)))))
|
c9694633f7ca
(command-line): Init user-mail-address here, after reading init file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
534
|
688
|
535 (run-hooks 'after-init-hook)
|
|
536
|
322
|
537 ;; If *scratch* exists and init file didn't change its mode, initialize it.
|
|
538 (if (get-buffer "*scratch*")
|
|
539 (save-excursion
|
|
540 (set-buffer "*scratch*")
|
|
541 (if (eq major-mode 'fundamental-mode)
|
|
542 (funcall initial-major-mode))))
|
|
543 ;; Load library for our terminal type.
|
|
544 ;; User init file can set term-file-prefix to nil to prevent this.
|
|
545 (and term-file-prefix (not noninteractive) (not window-system)
|
|
546 (let ((term (getenv "TERM"))
|
|
547 hyphend)
|
|
548 (while (and term
|
|
549 (not (load (concat term-file-prefix term) t t)))
|
|
550 ;; Strip off last hyphen and what follows, then try again
|
|
551 (if (setq hyphend (string-match "[-_][^-_]+$" term))
|
|
552 (setq term (substring term 0 hyphend))
|
|
553 (setq term nil)))))
|
|
554
|
326
|
555 ;; Process the remaining args.
|
322
|
556 (command-line-1 (cdr command-line-args))
|
|
557
|
|
558 ;; If -batch, terminate after processing the command options.
|
|
559 (if noninteractive (kill-emacs t)))
|
|
560
|
|
561 (defun command-line-1 (command-line-args-left)
|
5109
|
562 (or noninteractive (input-pending-p) init-file-had-error
|
5930
|
563 (and inhibit-startup-echo-area-message
|
|
564 (let ((buffer (get-buffer-create " *temp*")))
|
|
565 (prog1
|
|
566 (condition-case nil
|
|
567 (save-excursion
|
|
568 (set-buffer buffer)
|
|
569 (insert-file-contents user-init-file)
|
|
570 (re-search-forward
|
|
571 (concat
|
5932
|
572 "([ \t\n]*setq[ \t\n]+"
|
|
573 "inhibit-startup-echo-area-message[ \t\n]+"
|
5931
|
574 (regexp-quote
|
|
575 (prin1-to-string
|
|
576 (if (string= init-file-user "")
|
|
577 (user-login-name)
|
|
578 init-file-user)))
|
|
579 "[ \t\n]*)")
|
5930
|
580 nil t))
|
|
581 (error nil))
|
|
582 (kill-buffer buffer))))
|
|
583 (message (if (eq (key-binding "\C-h\C-p") 'describe-project)
|
|
584 "For information about the GNU Project and its goals, type C-h C-p."
|
|
585 (substitute-command-keys
|
|
586 "For information about the GNU Project and its goals, type \\[describe-project]."))))
|
322
|
587 (if (null command-line-args-left)
|
|
588 (cond ((and (not inhibit-startup-message) (not noninteractive)
|
|
589 ;; Don't clobber a non-scratch buffer if init file
|
|
590 ;; has selected it.
|
|
591 (string= (buffer-name) "*scratch*")
|
|
592 (not (input-pending-p)))
|
|
593 ;; If there are no switches to process, we might as well
|
|
594 ;; run this hook now, and there may be some need to do it
|
|
595 ;; before doing any output.
|
|
596 (and term-setup-hook
|
|
597 (run-hooks 'term-setup-hook))
|
|
598 ;; Don't let the hook be run twice.
|
|
599 (setq term-setup-hook nil)
|
2869
|
600
|
|
601 ;; It's important to notice the user settings before we
|
|
602 ;; display the startup message; otherwise, the settings
|
|
603 ;; won't take effect until the user gives the first
|
|
604 ;; keystroke, and that's distracting.
|
|
605 (if (fboundp 'frame-notice-user-settings)
|
|
606 (frame-notice-user-settings))
|
|
607
|
322
|
608 (and window-setup-hook
|
|
609 (run-hooks 'window-setup-hook))
|
|
610 (setq window-setup-hook nil)
|
7658
|
611 ;; Do this now to avoid an annoying delay if the user
|
|
612 ;; clicks the menu bar during the sit-for.
|
13430
abcf51439209
[win32] (normal-top-level, command-line, command-line-1):
Geoff Voelker <voelker@cs.washington.edu>
diff
changeset
|
613 (if (or (eq window-system 'x) (eq window-system 'win32))
|
12300
|
614 (precompute-menubar-bindings))
|
7658
|
615 (setq menubar-bindings-done t)
|
322
|
616 (unwind-protect
|
|
617 (progn
|
13542
|
618 ;; The convention for this piece of code is that
|
|
619 ;; each piece of output starts with one or two newlines
|
|
620 ;; and does not end with any newlines.
|
322
|
621 (insert (emacs-version)
|
|
622 "
|
13542
|
623 Copyright (C) 1995 Free Software Foundation, Inc.")
|
322
|
624 ;; If keys have their default meanings,
|
|
625 ;; use precomputed string to save lots of time.
|
|
626 (if (and (eq (key-binding "\C-h") 'help-command)
|
|
627 (eq (key-binding "\C-xu") 'advertised-undo)
|
|
628 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
|
10272
|
629 (eq (key-binding "\C-ht") 'help-with-tutorial)
|
|
630 (eq (key-binding "\C-hi") 'info))
|
13542
|
631 (insert "\n
|
|
632 Type C-h for help; C-x u to undo changes. (`C-' means use CTRL key.)
|
322
|
633 To kill the Emacs job, type C-x C-c.
|
|
634 Type C-h t for a tutorial on using Emacs.
|
10272
|
635 Type C-h i to enter Info, which you can use to read GNU documentation.")
|
|
636 (insert (substitute-command-keys
|
13542
|
637 (format "\n
|
|
638 Type %s for help; \\[advertised-undo] to undo changes. (`C-' means use CTRL key.)
|
10272
|
639 To kill the Emacs job, type \\[save-buffers-kill-emacs].
|
|
640 Type \\[help-with-tutorial] for a tutorial on using Emacs.
|
|
641 Type \\[info] to enter Info, which you can use to read GNU documentation."
|
|
642 (let ((where (where-is-internal
|
|
643 'help-command nil t)))
|
|
644 (if where
|
|
645 (key-description where)
|
|
646 "M-x help"))))))
|
13371
|
647 ;; Say how to use the menu bar
|
|
648 ;; if that is not with the mouse.
|
|
649 (if (not (assq 'display (frame-parameters)))
|
|
650 (if (eq (key-binding "\M-`") 'tmm-menubar)
|
13552
|
651 (insert "\n\nType F10, ESC ` or Meta-` to use the menu bar.")
|
13371
|
652 (insert (substitute-command-keys
|
|
653 "\n\nType \\[tmm-menubar] to use the menu bar."))))
|
322
|
654
|
10272
|
655 ;; Windows and MSDOS (currently) do not count as
|
|
656 ;; window systems, but do have mouse support.
|
10285
|
657 (if (or (memq system-type '(msdos windowsnt))
|
10272
|
658 window-system)
|
13542
|
659 (insert "\n
|
10272
|
660 C-mouse-3 (third mouse button, with Control) gets a mode-specific menu."))
|
13542
|
661 (if (directory-files "~/" nil "\\`\\.saves-" t)
|
|
662 (insert "\n\nIf an Emacs session crashed recently,\n"
|
|
663 "type M-x recover-session RET to recover"
|
|
664 " the files you were editing."))
|
|
665
|
10272
|
666 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
|
|
667 (eq (key-binding "\C-h\C-d") 'describe-distribution)
|
|
668 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
|
|
669 (insert
|
13542
|
670 "\n
|
322
|
671 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
|
|
672 You may give out copies of Emacs; type C-h C-c to see the conditions.
|
|
673 Type C-h C-d for information on getting the latest version.")
|
|
674 (insert (substitute-command-keys
|
13542
|
675 "\n
|
322
|
676 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
|
|
677 You may give out copies of Emacs; type \\[describe-copying] to see the conditions.
|
|
678 Type \\[describe-distribution] for information on getting the latest version.")))
|
12764
69dcdd99fd8d
(command-line-1): Mention recover-session if there's a .saves file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
679
|
322
|
680 (set-buffer-modified-p nil)
|
|
681 (sit-for 120))
|
|
682 (save-excursion
|
|
683 ;; In case the Emacs server has already selected
|
|
684 ;; another buffer, erase the one our message is in.
|
|
685 (set-buffer (get-buffer "*scratch*"))
|
|
686 (erase-buffer)
|
|
687 (set-buffer-modified-p nil)))))
|
10324
|
688 ;; Delay 2 seconds after the init file error message
|
|
689 ;; was displayed, so user can read it.
|
|
690 (if init-file-had-error
|
|
691 (sit-for 2))
|
7022
|
692 (let ((dir command-line-default-directory)
|
322
|
693 (file-count 0)
|
|
694 first-file-buffer
|
|
695 (line 0))
|
|
696 (while command-line-args-left
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
697 (let* ((argi (car command-line-args-left))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
698 (orig-argi argi)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
699 ;; This includes our standard options' long versions
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
700 ;; and long versions of what's on command-switch-alist.
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
701 (longopts
|
11625
|
702 (append '(("--funcall") ("--load") ("--insert") ("--kill")
|
12849
|
703 ("--directory") ("--eval"))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
704 (mapcar '(lambda (elt)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
705 (list (concat "-" (car elt))))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
706 command-switch-alist)))
|
11625
|
707 tem argval completion
|
|
708 ;; List of directories specified in -L/--directory,
|
|
709 ;; in reverse of the order specified.
|
|
710 extra-load-path
|
|
711 (initial-load-path load-path))
|
322
|
712 (setq command-line-args-left (cdr command-line-args-left))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
713
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
714 ;; Convert long options to ordinary options
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
715 ;; and separate out an attached option argument into argval.
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
716 (if (string-match "^--[^=]*=" argi)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
717 (setq argval (substring argi (match-end 0))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
718 argi (substring argi 0 (1- (match-end 0)))))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
719 (setq completion (try-completion argi longopts))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
720 (if (eq completion t)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
721 (setq argi (substring argi 1))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
722 (if (stringp completion)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
723 (let ((elt (assoc completion longopts)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
724 (or elt
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
725 (error "Option `%s' is ambiguous" argi))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
726 (setq argi (substring (car elt) 1)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
727 (setq argval nil argi orig-argi)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
728
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
729 ;; Execute the option.
|
322
|
730 (cond ((setq tem (assoc argi command-switch-alist))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
731 (if argval
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
732 (let ((command-line-args-left
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
733 (cons argval command-line-args-left)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
734 (funcall (cdr tem) argi))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
735 (funcall (cdr tem) argi)))
|
322
|
736 ((or (string-equal argi "-f") ;what the manual claims
|
|
737 (string-equal argi "-funcall")
|
|
738 (string-equal argi "-e")) ; what the source used to say
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
739 (if argval
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
740 (setq tem (intern argval))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
741 (setq tem (intern (car command-line-args-left)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
742 (setq command-line-args-left (cdr command-line-args-left)))
|
10444
|
743 (if (arrayp (symbol-function tem))
|
|
744 (command-execute tem)
|
|
745 (funcall tem)))
|
12849
|
746 ((string-equal argi "-eval")
|
|
747 (if argval
|
|
748 (setq tem argval)
|
|
749 (setq tem (car command-line-args-left))
|
|
750 (setq command-line-args-left (cdr command-line-args-left)))
|
13072
|
751 (eval (read tem)))
|
11625
|
752 ;; Set the default directory as specified in -L.
|
|
753 ((or (string-equal argi "-L")
|
|
754 (string-equal argi "-directory"))
|
|
755 (if argval
|
|
756 (setq tem argval)
|
|
757 (setq tem (car command-line-args-left)
|
|
758 command-line-args-left (cdr command-line-args-left)))
|
|
759 (setq extra-load-path
|
|
760 (cons (expand-file-name tem) extra-load-path))
|
|
761 (setq load-path (append (nreverse extra-load-path)
|
|
762 initial-load-path)))
|
322
|
763 ((or (string-equal argi "-l")
|
|
764 (string-equal argi "-load"))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
765 (if argval
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
766 (setq tem argval)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
767 (setq tem (car command-line-args-left)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
768 command-line-args-left (cdr command-line-args-left)))
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
769 (let ((file tem))
|
322
|
770 ;; Take file from default dir if it exists there;
|
|
771 ;; otherwise let `load' search for it.
|
|
772 (if (file-exists-p (expand-file-name file))
|
|
773 (setq file (expand-file-name file)))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
774 (load file nil t)))
|
3072
|
775 ((string-equal argi "-insert")
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
776 (if argval
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
777 (setq tem argval)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
778 (setq tem (car command-line-args-left)
|
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
779 command-line-args-left (cdr command-line-args-left)))
|
13073
|
780 (or (stringp tem)
|
|
781 (error "File name omitted from `-insert' option"))
|
10028
55f7d03ce918
(command-line-1): Handle long options --funcall, --load, --insert, --kill.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
782 (insert-file-contents tem))
|
322
|
783 ((string-equal argi "-kill")
|
|
784 (kill-emacs t))
|
|
785 ((string-match "^\\+[0-9]+\\'" argi)
|
|
786 (setq line (string-to-int argi)))
|
|
787 (t
|
|
788 ;; We have almost exhausted our options. See if the
|
|
789 ;; user has made any other command-line options available
|
|
790 (let ((hooks command-line-functions);; lrs 7/31/89
|
|
791 (did-hook nil))
|
|
792 (while (and hooks
|
|
793 (not (setq did-hook (funcall (car hooks)))))
|
|
794 (setq hooks (cdr hooks)))
|
|
795 (if (not did-hook)
|
|
796 ;; Ok, presume that the argument is a file name
|
|
797 (progn
|
13524
|
798 (if (string-match "\\`-" argi)
|
|
799 (error "Unknown option `%s'" argi))
|
322
|
800 (setq file-count (1+ file-count))
|
|
801 (cond ((= file-count 1)
|
|
802 (setq first-file-buffer
|
|
803 (find-file (expand-file-name argi dir))))
|
|
804 (t
|
|
805 (find-file-other-window (expand-file-name argi dir))))
|
|
806 (or (zerop line)
|
|
807 (goto-line line))
|
|
808 (setq line 0))))))))
|
|
809 ;; If 3 or more files visited, and not all visible,
|
|
810 ;; show user what they all are.
|
|
811 (if (> file-count 2)
|
|
812 (or (get-buffer-window first-file-buffer)
|
3281
|
813 (progn (other-window 1)
|
5024
|
814 (buffer-menu)))))))
|
658
|
815
|
|
816 ;;; startup.el ends here
|