(DEFVAR_DISPLAY): New macro.
[emacs.git] / lisp / startup.el
bloba884e61a1830e56ba0ee0c7d67296f3f3024eae3
1 ;;; startup.el --- process Emacs shell arguments
3 ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: internal
8 ;; This file is part of GNU Emacs.
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
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
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.
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.
24 ;;; Commentary:
26 ; These are processed only at the beginning of the argument list.
27 ; -batch execute noninteractively (messages go to stdout,
28 ; variable noninteractive set to t)
29 ; This option must be the first in the arglist.
30 ; Processed by `main' in emacs.c -- never seen by lisp
31 ; -t file Specify to use file rather than stdin/stdout
32 ; as the terminal.
33 ; This option must be the first in the arglist.
34 ; Processed by `main' in emacs.c -- never seen by lisp
35 ; -nw Inhibit the use of any window-system-specific display
36 ; code; use the current virtual terminal.
37 ; This option must be the first in the arglist.
38 ; Processed by `main' in emacs.c -- never seen by lisp
39 ; -q load no init file
40 ; -no-init-file same
41 ; -u user load user's init file
42 ; -user user same
43 ; -debug-init Don't catch errors in init file; let debugger run.
44 ; -no-site-file Don't load site-run-file.
46 ; These are processed in the order encountered.
47 ; -f function execute function
48 ; -funcall function same
49 ; -l file load file
50 ; -load file same
51 ; -insert file insert file into buffer
52 ; file visit file
53 ; -kill kill (exit) emacs
55 ;;; Code:
57 (setq top-level '(normal-top-level))
59 (defvar command-line-processed nil "t once command line has been processed")
61 (defconst inhibit-startup-message nil
62 "*Non-nil inhibits the initial startup message.
63 This is for use in your personal init file, once you are familiar
64 with the contents of the startup message.")
66 (defconst inhibit-startup-echo-area-message nil
67 "*Non-nil inhibits the initial startup echo area message.
68 Inhibition takes effect only if your `.emacs' file contains
69 a line of this form:
70 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
71 If your `.emacs' file is byte-compiled, use the following form instead:
72 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
73 Thus, someone else using a copy of your `.emacs' file will see
74 the startup message unless he personally acts to inhibit it.")
76 (defconst inhibit-default-init nil
77 "*Non-nil inhibits loading the `default' library.")
79 (defconst command-switch-alist nil
80 "Alist of command-line switches.
81 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
82 HANDLER-FUNCTION receives switch name as sole arg;
83 remaining command-line args are in the variable `command-line-args-left'.")
85 (defvar command-line-args-left nil
86 "List of command-line args not yet processed.")
88 (defvar command-line-functions nil ;; lrs 7/31/89
89 "List of functions to process unrecognized command-line arguments.
90 Each function should access the dynamically bound variables
91 `argi' (the current argument) and `command-line-args-left' (the remaining
92 arguments). The function should return non-nil only if it recognizes and
93 processes `argi'. If it does so, it may consume successive arguments by
94 altering `command-line-args-left' to remove them.")
96 (defvar command-line-default-directory nil
97 "Default directory to use for command line arguments.
98 This is normally copied from `default-directory' when Emacs starts.")
100 (defvar before-init-hook nil
101 "Functions to call after handling urgent options but before init files.
102 The frame system uses this to open frames to display messages while
103 Emacs loads the user's initialization file.")
105 (defvar after-init-hook nil
106 "Functions to call after loading the init file (`~/.emacs').
107 The call is not protected by a condition-case, so you can set `debug-on-error'
108 in `.emacs', and put all the actual code on `after-init-hook'.")
110 (defvar term-setup-hook nil
111 "Functions to be called after loading terminal-specific Lisp code.
112 See `run-hooks'. This variable exists for users to set,
113 so as to override the definitions made by the terminal-specific file.
114 Emacs never sets this variable itself.")
116 (defvar keyboard-type nil
117 "The brand of keyboard you are using.
118 This variable is used to define
119 the proper function and keypad keys for use under X. It is used in a
120 fashion analogous to the environment value TERM.")
122 (defvar window-setup-hook nil
123 "Normal hook run to initialize window system display.
124 Emacs runs this hook after processing the command line arguments and loading
125 the user's init file.")
127 (defconst initial-major-mode 'lisp-interaction-mode
128 "Major mode command symbol to use for the initial *scratch* buffer.")
130 (defvar init-file-user nil
131 "Identity of user whose `.emacs' file is or was read.
132 The value is nil if no init file is being used; otherwise, it may be either
133 the null string, meaning that the init file was taken from the user that
134 originally logged in, or it may be a string containing a user's name.
136 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
137 evaluates to the name of the directory where the `.emacs' file was
138 looked for.")
140 (defvar site-run-file "site-start"
141 "File containing site-wide run-time initializations.
142 This file is loaded at run-time before `~/.emacs'. It contains inits
143 that need to be in place for the entire site, but which, due to their
144 higher incidence of change, don't make sense to load into emacs'
145 dumped image. Thus, the run-time load order is: 1. file described in
146 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.")
148 (defconst iso-8859-1-locale-regexp "8859[-_]?1"
149 "Regexp that specifies when to enable the ISO 8859-1 character set.
150 We do that if this regexp matches the locale name
151 specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
153 (defvar mail-host-address nil
154 "*Name of this machine, for purposes of naming users.")
156 (defvar user-mail-address nil
157 "*Full mailing address of this user.")
159 (defvar init-file-debug nil)
161 (defvar init-file-had-error nil)
163 ;; This function is called from the subdirs.el file.
164 (defun normal-top-level-add-to-load-path (dirs)
165 (let ((tail (member default-directory load-path)))
166 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail)))))
168 (defun normal-top-level ()
169 (if command-line-processed
170 (message "Back to top level.")
171 (setq command-line-processed t)
172 ;; Look in each dir in load-path for a subdirs.el file.
173 ;; If we find one, load it, which will add the appropriate subdirs
174 ;; of that dir into load-path,
175 (let ((tail load-path)
176 new)
177 (while tail
178 (setq new (cons (car tail) new))
179 (let ((default-directory (car tail)))
180 (load (expand-file-name "subdirs.el" (car tail)) t t t))
181 (setq tail (cdr tail))))
182 (if (not (eq system-type 'vax-vms))
183 (progn
184 ;; If the PWD environment variable isn't accurate, delete it.
185 (let ((pwd (getenv "PWD")))
186 (and (stringp pwd)
187 ;; Use FOO/., so that if FOO is a symlink, file-attributes
188 ;; describes the directory linked to, not FOO itself.
189 (or (equal (file-attributes
190 (concat (file-name-as-directory pwd) "."))
191 (file-attributes
192 (concat (file-name-as-directory default-directory)
193 ".")))
194 (setq process-environment
195 (delete (concat "PWD=" pwd)
196 process-environment)))))))
197 (setq default-directory (abbreviate-file-name default-directory))
198 (setq user-mail-address (concat (user-login-name) "@"
199 (or mail-host-address
200 (system-name))))
201 (let ((menubar-bindings-done nil))
202 (unwind-protect
203 (command-line)
204 ;; Do this again, in case .emacs defined more abbreviations.
205 (setq default-directory (abbreviate-file-name default-directory))
206 (run-hooks 'emacs-startup-hook)
207 (and term-setup-hook
208 (run-hooks 'term-setup-hook))
209 ;; Modify the initial frame based on what .emacs puts into
210 ;; ...-frame-alist.
211 (if (fboundp 'frame-notice-user-settings)
212 (frame-notice-user-settings))
213 ;; Now we know the user's default font, so add it to the menu.
214 (if (fboundp 'font-menu-add-default)
215 (font-menu-add-default))
216 (and window-setup-hook
217 (run-hooks 'window-setup-hook))
218 (or menubar-bindings-done
219 (precompute-menubar-bindings))))))
221 ;; Precompute the keyboard equivalents in the menu bar items.
222 (defun precompute-menubar-bindings ()
223 (if (eq window-system 'x)
224 (let ((submap (lookup-key global-map [menu-bar])))
225 (while submap
226 (and (consp (car submap))
227 (symbolp (car (car submap)))
228 (stringp (car-safe (cdr (car submap))))
229 (keymapp (cdr (cdr (car submap))))
230 (x-popup-menu nil (cdr (cdr (car submap)))))
231 (setq submap (cdr submap))))))
233 (defun command-line ()
234 (setq command-line-default-directory default-directory)
236 ;; See if we should import version-control from the environment variable.
237 (let ((vc (getenv "VERSION_CONTROL")))
238 (cond ((eq vc nil)) ;don't do anything if not set
239 ((or (string= vc "t")
240 (string= vc "numbered"))
241 (setq version-control t))
242 ((or (string= vc "nil")
243 (string= vc "existing"))
244 (setq version-control nil))
245 ((or (string= vc "never")
246 (string= vc "simple"))
247 (setq version-control 'never))))
249 (if (let ((ctype
250 ;; Use the first of these three envvars that has a nonempty value.
251 (or (let ((string (getenv "LC_ALL")))
252 (and (not (equal string "")) string))
253 (let ((string (getenv "LC_CTYPE")))
254 (and (not (equal string "")) string))
255 (let ((string (getenv "LANG")))
256 (and (not (equal string "")) string)))))
257 (and ctype
258 (string-match iso-8859-1-locale-regexp ctype)))
259 (progn
260 (require 'disp-table)
261 (standard-display-european t)
262 (require 'iso-syntax)))
264 ;;! This has been commented out; I currently find the behavior when
265 ;;! split-window-keep-point is nil disturbing, but if I can get used
266 ;;! to it, then it would be better to eliminate the option.
267 ;;! ;; Choose a good default value for split-window-keep-point.
268 ;;! (setq split-window-keep-point (> baud-rate 2400))
270 ;; Read window system's init file if using a window system.
271 (condition-case error
272 (if (and window-system (not noninteractive))
273 (load (concat term-file-prefix
274 (symbol-name window-system)
275 "-win")
276 ;; Every window system should have a startup file;
277 ;; barf if we can't find it.
278 nil t))
279 ;; If we can't read it, print the error message and exit.
280 (error
281 (princ
282 (if (eq (car error) 'error)
283 (apply 'concat (cdr error))
284 (if (memq 'file-error (get (car error) 'error-conditions))
285 (format "%s: %s"
286 (nth 1 error)
287 (mapconcat '(lambda (obj) (prin1-to-string obj t))
288 (cdr (cdr error)) ", "))
289 (format "%s: %s"
290 (get (car error) 'error-message)
291 (mapconcat '(lambda (obj) (prin1-to-string obj t))
292 (cdr error) ", "))))
293 'external-debugging-output)
294 (setq window-system nil)
295 (kill-emacs)))
297 (let ((done nil)
298 (args (cdr command-line-args)))
300 ;; Figure out which user's init file to load,
301 ;; either from the environment or from the options.
302 (setq init-file-user (if noninteractive nil (user-login-name)))
303 ;; If user has not done su, use current $HOME to find .emacs.
304 (and init-file-user (string= init-file-user (user-real-login-name))
305 (setq init-file-user ""))
307 ;; Process the command-line args, and delete the arguments
308 ;; processed. This is consistent with the way main in emacs.c
309 ;; does things.
310 (while (and (not done) args)
311 (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
312 ("--debug-init")))
313 (argi (car args))
314 (argval nil))
315 (if (string-match "=" argi)
316 (setq argval (substring argi (match-end 0))
317 argi (substring argi 0 (match-beginning 0))))
318 (let ((completion (try-completion argi longopts)))
319 (if (eq completion t)
320 (setq argi (substring argi 1))
321 (if (stringp completion)
322 (let ((elt (assoc completion longopts)))
323 (or elt
324 (error "Option `%s' is ambiguous" argi))
325 (setq argi (substring (car elt) 1)))
326 (setq argval nil))))
327 (cond
328 ((or (string-equal argi "-q")
329 (string-equal argi "-no-init-file"))
330 (setq init-file-user nil
331 args (cdr args)))
332 ((or (string-equal argi "-u")
333 (string-equal argi "-user"))
334 (or argval
335 (setq argval (car args)
336 args (cdr args)))
337 (setq init-file-user argval
338 argval nil
339 args (cdr args)))
340 ((string-equal argi "-no-site-file")
341 (setq site-run-file nil
342 args (cdr args)))
343 ((string-equal argi "-debug-init")
344 (setq init-file-debug t
345 args (cdr args)))
346 (t (setq done t)))
347 ;; Was argval set but not used?
348 (and argval
349 (error "Option `%s' doesn't allow an argument" argi))))
351 ;; Re-attach the program name to the front of the arg list.
352 (setcdr command-line-args args))
354 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
355 (if (fboundp 'face-initialize)
356 (face-initialize))
357 (if (fboundp 'frame-initialize)
358 (frame-initialize))
359 ;; If frame was created with a menu bar, set menu-bar-mode on.
360 (if (and (eq window-system 'x)
361 (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
362 (menu-bar-mode t))
364 (run-hooks 'before-init-hook)
366 ;; Run the site-start library if it exists. The point of this file is
367 ;; that it is run before .emacs. There is no point in doing this after
368 ;; .emacs; that is useless.
369 (if site-run-file
370 (load site-run-file t t))
372 ;; Sites should not disable this. Only individuals should disable
373 ;; the startup message.
374 (setq inhibit-startup-message nil)
376 ;; Load that user's init file, or the default one, or none.
377 (let (debug-on-error-from-init-file
378 debug-on-error-should-be-set
379 (debug-on-error-initial
380 (if (eq init-file-debug t) 'startup init-file-debug)))
381 (let ((debug-on-error debug-on-error-initial)
382 ;; This function actually reads the init files.
383 (inner
384 (function
385 (lambda ()
386 (if init-file-user
387 (progn
388 (setq user-init-file
389 (cond
390 ((eq system-type 'ms-dos)
391 (concat "~" init-file-user "/_emacs"))
392 ((eq system-type 'windows-nt)
393 "~/_emacs")
394 ((eq system-type 'vax-vms)
395 "sys$login:.emacs")
397 (concat "~" init-file-user "/.emacs"))))
398 (load user-init-file t t t)
399 (or inhibit-default-init
400 (let ((inhibit-startup-message nil))
401 ;; Users are supposed to be told their rights.
402 ;; (Plus how to get help and how to undo.)
403 ;; Don't you dare turn this off for anyone
404 ;; except yourself.
405 (load "default" t t)))))))))
406 (if init-file-debug
407 ;; Do this without a condition-case if the user wants to debug.
408 (funcall inner)
409 (condition-case error
410 (progn
411 (funcall inner)
412 (setq init-file-had-error nil))
413 (error (message "Error in init file: %s%s%s"
414 (get (car error) 'error-message)
415 (if (cdr error) ": " "")
416 (mapconcat 'prin1-to-string (cdr error) ", "))
417 (setq init-file-had-error t))))
418 ;; If we can tell that the init file altered debug-on-error,
419 ;; arrange to preserve the value that it set up.
420 (or (eq debug-on-error debug-on-error-initial)
421 (setq debug-on-error-should-be-set t
422 debug-on-error-from-init-file debug-on-error)))
423 (if debug-on-error-should-be-set
424 (setq debug-on-error debug-on-error-from-init-file)))
426 (run-hooks 'after-init-hook)
428 ;; If *scratch* exists and init file didn't change its mode, initialize it.
429 (if (get-buffer "*scratch*")
430 (save-excursion
431 (set-buffer "*scratch*")
432 (if (eq major-mode 'fundamental-mode)
433 (funcall initial-major-mode))))
434 ;; Load library for our terminal type.
435 ;; User init file can set term-file-prefix to nil to prevent this.
436 (and term-file-prefix (not noninteractive) (not window-system)
437 (let ((term (getenv "TERM"))
438 hyphend)
439 (while (and term
440 (not (load (concat term-file-prefix term) t t)))
441 ;; Strip off last hyphen and what follows, then try again
442 (if (setq hyphend (string-match "[-_][^-_]+$" term))
443 (setq term (substring term 0 hyphend))
444 (setq term nil)))))
446 ;; Process the remaining args.
447 (command-line-1 (cdr command-line-args))
449 ;; If -batch, terminate after processing the command options.
450 (if noninteractive (kill-emacs t)))
452 (defun command-line-1 (command-line-args-left)
453 (or noninteractive (input-pending-p) init-file-had-error
454 (and inhibit-startup-echo-area-message
455 (let ((buffer (get-buffer-create " *temp*")))
456 (prog1
457 (condition-case nil
458 (save-excursion
459 (set-buffer buffer)
460 (insert-file-contents user-init-file)
461 (re-search-forward
462 (concat
463 "([ \t\n]*setq[ \t\n]+"
464 "inhibit-startup-echo-area-message[ \t\n]+"
465 (regexp-quote
466 (prin1-to-string
467 (if (string= init-file-user "")
468 (user-login-name)
469 init-file-user)))
470 "[ \t\n]*)")
471 nil t))
472 (error nil))
473 (kill-buffer buffer))))
474 (message (if (eq (key-binding "\C-h\C-p") 'describe-project)
475 "For information about the GNU Project and its goals, type C-h C-p."
476 (substitute-command-keys
477 "For information about the GNU Project and its goals, type \\[describe-project]."))))
478 (if (null command-line-args-left)
479 (cond ((and (not inhibit-startup-message) (not noninteractive)
480 ;; Don't clobber a non-scratch buffer if init file
481 ;; has selected it.
482 (string= (buffer-name) "*scratch*")
483 (not (input-pending-p)))
484 ;; If there are no switches to process, we might as well
485 ;; run this hook now, and there may be some need to do it
486 ;; before doing any output.
487 (and term-setup-hook
488 (run-hooks 'term-setup-hook))
489 ;; Don't let the hook be run twice.
490 (setq term-setup-hook nil)
492 ;; It's important to notice the user settings before we
493 ;; display the startup message; otherwise, the settings
494 ;; won't take effect until the user gives the first
495 ;; keystroke, and that's distracting.
496 (if (fboundp 'frame-notice-user-settings)
497 (frame-notice-user-settings))
499 (and window-setup-hook
500 (run-hooks 'window-setup-hook))
501 (setq window-setup-hook nil)
502 ;; Do this now to avoid an annoying delay if the user
503 ;; clicks the menu bar during the sit-for.
504 (precompute-menubar-bindings)
505 (setq menubar-bindings-done t)
506 (unwind-protect
507 (progn
508 (insert (emacs-version)
510 Copyright (C) 1994 Free Software Foundation, Inc.\n\n")
511 ;; If keys have their default meanings,
512 ;; use precomputed string to save lots of time.
513 (if (and (eq (key-binding "\C-h") 'help-command)
514 (eq (key-binding "\C-xu") 'advertised-undo)
515 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
516 (eq (key-binding "\C-ht") 'help-with-tutorial)
517 (eq (key-binding "\C-hi") 'info))
518 (insert
519 "Type C-h for help; C-x u to undo changes. (`C-' means use CTRL key.)
520 To kill the Emacs job, type C-x C-c.
521 Type C-h t for a tutorial on using Emacs.
522 Type C-h i to enter Info, which you can use to read GNU documentation.")
523 (insert (substitute-command-keys
524 (format "Type %s for help; \\[advertised-undo] to undo changes. (`C-' means use CTRL key.)
525 To kill the Emacs job, type \\[save-buffers-kill-emacs].
526 Type \\[help-with-tutorial] for a tutorial on using Emacs.
527 Type \\[info] to enter Info, which you can use to read GNU documentation."
528 (let ((where (where-is-internal
529 'help-command nil t)))
530 (if where
531 (key-description where)
532 "M-x help"))))))
534 ;; Windows and MSDOS (currently) do not count as
535 ;; window systems, but do have mouse support.
536 (if (or (memq system-type '(msdos windowsnt))
537 window-system)
538 (insert "
539 C-mouse-3 (third mouse button, with Control) gets a mode-specific menu."))
540 (insert "\n")
541 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
542 (eq (key-binding "\C-h\C-d") 'describe-distribution)
543 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
544 (insert
546 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
547 You may give out copies of Emacs; type C-h C-c to see the conditions.
548 Type C-h C-d for information on getting the latest version.")
549 (insert (substitute-command-keys
551 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
552 You may give out copies of Emacs; type \\[describe-copying] to see the conditions.
553 Type \\[describe-distribution] for information on getting the latest version.")))
554 (set-buffer-modified-p nil)
555 (sit-for 120))
556 (save-excursion
557 ;; In case the Emacs server has already selected
558 ;; another buffer, erase the one our message is in.
559 (set-buffer (get-buffer "*scratch*"))
560 (erase-buffer)
561 (set-buffer-modified-p nil)))))
562 ;; Delay 2 seconds after the init file error message
563 ;; was displayed, so user can read it.
564 (if init-file-had-error
565 (sit-for 2))
566 (let ((dir command-line-default-directory)
567 (file-count 0)
568 first-file-buffer
569 (line 0))
570 (while command-line-args-left
571 (let* ((argi (car command-line-args-left))
572 (orig-argi argi)
573 ;; This includes our standard options' long versions
574 ;; and long versions of what's on command-switch-alist.
575 (longopts
576 (append '(("--funcall") ("--load") ("--insert") ("--kill"))
577 (mapcar '(lambda (elt)
578 (list (concat "-" (car elt))))
579 command-switch-alist)))
580 tem argval completion)
581 (setq command-line-args-left (cdr command-line-args-left))
583 ;; Convert long options to ordinary options
584 ;; and separate out an attached option argument into argval.
585 (if (string-match "^--[^=]*=" argi)
586 (setq argval (substring argi (match-end 0))
587 argi (substring argi 0 (1- (match-end 0)))))
588 (setq completion (try-completion argi longopts))
589 (if (eq completion t)
590 (setq argi (substring argi 1))
591 (if (stringp completion)
592 (let ((elt (assoc completion longopts)))
593 (or elt
594 (error "Option `%s' is ambiguous" argi))
595 (setq argi (substring (car elt) 1)))
596 (setq argval nil argi orig-argi)))
598 ;; Execute the option.
599 (cond ((setq tem (assoc argi command-switch-alist))
600 (if argval
601 (let ((command-line-args-left
602 (cons argval command-line-args-left)))
603 (funcall (cdr tem) argi))
604 (funcall (cdr tem) argi)))
605 ((or (string-equal argi "-f") ;what the manual claims
606 (string-equal argi "-funcall")
607 (string-equal argi "-e")) ; what the source used to say
608 (if argval
609 (setq tem (intern argval))
610 (setq tem (intern (car command-line-args-left)))
611 (setq command-line-args-left (cdr command-line-args-left)))
612 (if (arrayp (symbol-function tem))
613 (command-execute tem)
614 (funcall tem)))
615 ((or (string-equal argi "-l")
616 (string-equal argi "-load"))
617 (if argval
618 (setq tem argval)
619 (setq tem (car command-line-args-left)
620 command-line-args-left (cdr command-line-args-left)))
621 (let ((file tem))
622 ;; Take file from default dir if it exists there;
623 ;; otherwise let `load' search for it.
624 (if (file-exists-p (expand-file-name file))
625 (setq file (expand-file-name file)))
626 (load file nil t)))
627 ((string-equal argi "-insert")
628 (or (stringp (car command-line-args-left))
629 (error "File name omitted from `-insert' option"))
630 (if argval
631 (setq tem argval)
632 (setq tem (car command-line-args-left)
633 command-line-args-left (cdr command-line-args-left)))
634 (insert-file-contents tem))
635 ((string-equal argi "-kill")
636 (kill-emacs t))
637 ((string-match "^\\+[0-9]+\\'" argi)
638 (setq line (string-to-int argi)))
640 ;; We have almost exhausted our options. See if the
641 ;; user has made any other command-line options available
642 (let ((hooks command-line-functions);; lrs 7/31/89
643 (did-hook nil))
644 (while (and hooks
645 (not (setq did-hook (funcall (car hooks)))))
646 (setq hooks (cdr hooks)))
647 (if (not did-hook)
648 ;; Ok, presume that the argument is a file name
649 (progn
650 (setq file-count (1+ file-count))
651 (cond ((= file-count 1)
652 (setq first-file-buffer
653 (find-file (expand-file-name argi dir))))
655 (find-file-other-window (expand-file-name argi dir))))
656 (or (zerop line)
657 (goto-line line))
658 (setq line 0))))))))
659 ;; If 3 or more files visited, and not all visible,
660 ;; show user what they all are.
661 (if (> file-count 2)
662 (or (get-buffer-window first-file-buffer)
663 (progn (other-window 1)
664 (buffer-menu)))))))
666 ;;; startup.el ends here