]> code.delx.au - gnu-emacs/blob - lisp/startup.el
Add arch taglines
[gnu-emacs] / lisp / startup.el
1 ;;; startup.el --- process Emacs shell arguments
2
3 ;; Copyright (C) 1985, 86, 92, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
4 ;; Free Software Foundation, Inc.
5
6 ;; Maintainer: FSF
7 ;; Keywords: internal
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; This file parses the command line and gets Emacs running. Options on
29 ;; the command line are handled in precedence order. The order is the
30 ;; one in the list below; first described means first handled. Options
31 ;; within each category (delimited by a bar) are handled in the order
32 ;; encountered on the command line.
33
34 ;; -------------------------
35 ;; -version Print Emacs version to stderr, then exit
36 ;; --version successfully right away.
37 ;; This option is handled by emacs.c
38 ;; -------------------------
39 ;; -help Print a short usage description and exit
40 ;; --help successfully right away.
41 ;; This option is handled by emacs.c
42 ;; -------------------------
43 ;; -nl Do not use shared memory (for systems that
44 ;; -no-shared-memory support this) for the dumped Emacs data.
45 ;; This option is handled by emacs.c
46 ;;
47 ;; -map For VMS.
48 ;; --map-data This option is handled by emacs.c
49 ;; -------------------------
50 ;; -t FILE Use FILE as the name of the terminal.
51 ;; --terminal FILE Using this implies "-nw" also.
52 ;; This option is handled by emacs.c
53 ;; -------------------------
54 ;; -d DISPNAME Use DISPNAME as the name of the X
55 ;; -display DISPNAME display for the initial frame.
56 ;; --display DISPNAME This option is handled by emacs.c
57 ;; -------------------------
58 ;; -nw Do not use a windows system (but use the
59 ;; --no-window-system terminal instead.)
60 ;; This option is handled by emacs.c
61 ;; -------------------------
62 ;; -batch Execute noninteractively (messages go to stdout,
63 ;; --batch variable noninteractive set to t)
64 ;; This option is handled by emacs.c
65 ;; -------------------------
66 ;; -q Do not load user's init file and do not load
67 ;; -no-init-file "default.el". Regardless of this switch,
68 ;; --no-init-file "site-start" is still loaded.
69 ;; -------------------------
70 ;; -no-site-file Do not load "site-start.el". (This is the ONLY
71 ;; --no-site-file way to prevent loading that file.)
72 ;; -------------------------
73 ;; -no-splash Don't display a splash screen on startup.
74 ;; --no-splash
75 ;; -------------------------
76 ;; -u USER Load USER's init file instead of the init
77 ;; -user USER file belonging to the user starting Emacs.
78 ;; --user USER
79 ;; -------------------------
80 ;; -debug-init Don't catch errors in init files; let the
81 ;; --debug-init debugger run.
82 ;; -------------------------
83 ;; -i ICONTYPE Set type of icon using when Emacs is
84 ;; -itype ICONTYPE iconified under X.
85 ;; --icon-type ICONTYPE This option is passed on to term/x-win.el
86 ;;
87 ;; -iconic Start Emacs iconified.
88 ;; --iconic This option is passed on to term/x-win.el
89 ;; -------------------------
90 ;; Various X options for colors/fonts/geometry/title etc.
91 ;; These options are passed on to term/x-win.el which see.
92 ;; -------------------------
93 ;; FILE Visit FILE.
94 ;; -visit FILE
95 ;; --visit FILE
96 ;; -file FILE
97 ;; --file FILE
98 ;;
99 ;; -L DIRNAME Add DIRNAME to load-path
100 ;; -directory DIRNAME
101 ;; --directory DIRNAME
102 ;;
103 ;; -l FILE Load and execute the Emacs lisp code
104 ;; -load FILE in FILE.
105 ;; --load FILE
106 ;;
107 ;; -f FUNC Execute Emacs lisp function FUNC with
108 ;; -funcall FUNC no arguments. The "-e" form is outdated
109 ;; --funcall FUNC and should not be used. (It's a typo
110 ;; -e FUNC promoted to a feature.)
111 ;;
112 ;; -eval FORM Execute Emacs lisp form FORM.
113 ;; --eval FORM
114 ;; -execute EXPR
115 ;; --execute EXPR
116 ;;
117 ;; -insert FILE Insert the contents of FILE into buffer.
118 ;; --insert FILE
119 ;; -------------------------
120 ;; -kill Kill (exit) Emacs right away.
121 ;; --kill
122 ;; -------------------------
123
124 ;;; Code:
125
126 (setq top-level '(normal-top-level))
127
128 (defvar command-line-processed nil
129 "Non-nil once command line has been processed.")
130
131 (defgroup initialization nil
132 "Emacs start-up procedure"
133 :group 'internal)
134
135 (defcustom inhibit-startup-message nil
136 "*Non-nil inhibits the initial startup message.
137 This is for use in your personal init file, once you are familiar
138 with the contents of the startup message."
139 :type 'boolean
140 :group 'initialization)
141
142 (defvaralias 'inhibit-splash-screen 'inhibit-startup-message)
143
144 (defcustom inhibit-startup-echo-area-message nil
145 "*Non-nil inhibits the initial startup echo area message.
146 Setting this variable takes effect
147 only if you do it with the customization buffer
148 or if your `.emacs' file contains a line of this form:
149 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
150 If your `.emacs' file is byte-compiled, use the following form instead:
151 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
152 Thus, someone else using a copy of your `.emacs' file will see
153 the startup message unless he personally acts to inhibit it."
154 :type '(choice (const :tag "Don't inhibit")
155 (string :tag "Enter your user name, to inhibit"))
156 :group 'initialization)
157
158 (defcustom inhibit-default-init nil
159 "*Non-nil inhibits loading the `default' library."
160 :type 'boolean
161 :group 'initialization)
162
163 (defcustom inhibit-startup-buffer-menu nil
164 "*Non-nil inhibits display of buffer list when more than 2 files are loaded."
165 :type 'boolean
166 :group 'initialization)
167
168 (defvar command-switch-alist nil
169 "Alist of command-line switches.
170 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
171 HANDLER-FUNCTION receives switch name as sole arg;
172 remaining command-line args are in the variable `command-line-args-left'.")
173
174 (defvar command-line-args-left nil
175 "List of command-line args not yet processed.")
176
177 (defvar command-line-functions nil ;; lrs 7/31/89
178 "List of functions to process unrecognized command-line arguments.
179 Each function should access the dynamically bound variables
180 `argi' (the current argument) and `command-line-args-left' (the remaining
181 arguments). The function should return non-nil only if it recognizes and
182 processes `argi'. If it does so, it may consume successive arguments by
183 altering `command-line-args-left' to remove them.")
184
185 (defvar command-line-default-directory nil
186 "Default directory to use for command line arguments.
187 This is normally copied from `default-directory' when Emacs starts.")
188
189 ;;; This is here, rather than in x-win.el, so that we can ignore these
190 ;;; options when we are not using X.
191 (defconst command-line-x-option-alist
192 '(("-bw" 1 x-handle-numeric-switch border-width)
193 ("-d" 1 x-handle-display)
194 ("-display" 1 x-handle-display)
195 ("-name" 1 x-handle-name-switch)
196 ("-title" 1 x-handle-switch title)
197 ("-T" 1 x-handle-switch title)
198 ("-r" 0 x-handle-switch reverse t)
199 ("-rv" 0 x-handle-switch reverse t)
200 ("-reverse" 0 x-handle-switch reverse t)
201 ("-reverse-video" 0 x-handle-switch reverse t)
202 ("-fn" 1 x-handle-switch font)
203 ("-font" 1 x-handle-switch font)
204 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
205 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
206 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
207 ("-ib" 1 x-handle-numeric-switch internal-border-width)
208 ("-g" 1 x-handle-geometry)
209 ("-lsp" 1 x-handle-numeric-switch line-spacing)
210 ("-geometry" 1 x-handle-geometry)
211 ("-fg" 1 x-handle-switch foreground-color)
212 ("-foreground" 1 x-handle-switch foreground-color)
213 ("-bg" 1 x-handle-switch background-color)
214 ("-background" 1 x-handle-switch background-color)
215 ("-ms" 1 x-handle-switch mouse-color)
216 ("-itype" 0 x-handle-switch icon-type t)
217 ("-i" 0 x-handle-switch icon-type t)
218 ("-iconic" 0 x-handle-iconic)
219 ("-xrm" 1 x-handle-xrm-switch)
220 ("-cr" 1 x-handle-switch cursor-color)
221 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
222 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
223 ("-bd" 1 x-handle-switch)
224 ("--border-width" 1 x-handle-numeric-switch border-width)
225 ("--display" 1 x-handle-display)
226 ("--name" 1 x-handle-name-switch)
227 ("--title" 1 x-handle-switch title)
228 ("--reverse-video" 0 x-handle-switch reverse t)
229 ("--font" 1 x-handle-switch font)
230 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
231 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
232 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
233 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
234 ("--geometry" 1 x-handle-geometry)
235 ("--foreground-color" 1 x-handle-switch foreground-color)
236 ("--background-color" 1 x-handle-switch background-color)
237 ("--mouse-color" 1 x-handle-switch mouse-color)
238 ("--icon-type" 0 x-handle-switch icon-type t)
239 ("--iconic" 0 x-handle-iconic)
240 ("--xrm" 1 x-handle-xrm-switch)
241 ("--cursor-color" 1 x-handle-switch cursor-color)
242 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
243 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
244 ("--border-color" 1 x-handle-switch border-color)
245 ("--smid" 1 x-handle-smid))
246 "Alist of X Windows options.
247 Each element has the form
248 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
249 where NAME is the option name string, NUMARGS is the number of arguments
250 that the option accepts, HANDLER is a function to call to handle the option.
251 FRAME-PARAM (optional) is the frame parameter this option specifies,
252 and VALUE is the value which is given to that frame parameter
253 \(most options use the argument for this, so VALUE is not present).")
254
255 (defvar before-init-hook nil
256 "Normal hook run after handling urgent options but before loading init files.")
257
258 (defvar after-init-hook nil
259 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
260 There is no `condition-case' around the running of these functions;
261 therefore, if you set `debug-on-error' non-nil in `.emacs',
262 an error in one of these functions will invoke the debugger.")
263
264 (defvar emacs-startup-hook nil
265 "Normal hook run after loading init files and handling the command line.")
266
267 (defvar term-setup-hook nil
268 "Normal hook run after loading terminal-specific Lisp code.
269 It also follows `emacs-startup-hook'. This hook exists for users to set,
270 so as to override the definitions made by the terminal-specific file.
271 Emacs never sets this variable itself.")
272
273 (defvar inhibit-startup-hooks nil
274 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
275 This is because we already did so.")
276
277 (defvar keyboard-type nil
278 "The brand of keyboard you are using.
279 This variable is used to define
280 the proper function and keypad keys for use under X. It is used in a
281 fashion analogous to the environment variable TERM.")
282
283 (defvar window-setup-hook nil
284 "Normal hook run to initialize window system display.
285 Emacs runs this hook after processing the command line arguments and loading
286 the user's init file.")
287
288 (defcustom initial-major-mode 'lisp-interaction-mode
289 "Major mode command symbol to use for the initial *scratch* buffer."
290 :type 'function
291 :group 'initialization)
292
293 (defcustom init-file-user nil
294 "Identity of user whose `.emacs' file is or was read.
295 The value is nil if `-q' or `--no-init-file' was specified,
296 meaning do not load any init file.
297
298 Otherwise, the value may be the null string, meaning use the init file
299 for the user that originally logged in, or it may be a
300 string containing a user's name meaning use that person's init file.
301
302 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
303 evaluates to the name of the directory where the `.emacs' file was
304 looked for.
305
306 Setting `init-file-user' does not prevent Emacs from loading
307 `site-start.el'. The only way to do that is to use `--no-site-file'."
308 :type '(choice (const :tag "none" nil) string)
309 :group 'initialization)
310
311 (defcustom site-run-file "site-start"
312 "File containing site-wide run-time initializations.
313 This file is loaded at run-time before `~/.emacs'. It contains inits
314 that need to be in place for the entire site, but which, due to their
315 higher incidence of change, don't make sense to load into emacs'
316 dumped image. Thus, the run-time load order is: 1. file described in
317 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
318
319 Don't use the `site-start.el' file for things some users may not like.
320 Put them in `default.el' instead, so that users can more easily
321 override them. Users can prevent loading `default.el' with the `-q'
322 option or by setting `inhibit-default-init' in their own init files,
323 but inhibiting `site-start.el' requires `--no-site-file', which
324 is less convenient."
325 :type '(choice (const :tag "none" nil) string)
326 :group 'initialization)
327
328 (defcustom mail-host-address nil
329 "*Name of this machine, for purposes of naming users."
330 :type '(choice (const nil) string)
331 :group 'mail)
332
333 (defcustom user-mail-address (if command-line-processed
334 (concat (user-login-name) "@"
335 (or mail-host-address
336 (system-name)))
337 ;; Empty string means "not set yet".
338 "")
339 "*Full mailing address of this user.
340 This is initialized based on `mail-host-address',
341 after your init file is read, in case it sets `mail-host-address'."
342 :type 'string
343 :group 'mail)
344
345 (defcustom auto-save-list-file-prefix
346 (cond ((eq system-type 'ms-dos)
347 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
348 "~/_emacs.d/auto-save.list/_s")
349 (t
350 "~/.emacs.d/auto-save-list/.saves-"))
351 "Prefix for generating `auto-save-list-file-name'.
352 This is used after reading your `.emacs' file to initialize
353 `auto-save-list-file-name', by appending Emacs's pid and the system name,
354 if you have not already set `auto-save-list-file-name' yourself.
355 Directories in the prefix will be created if necessary.
356 Set this to nil if you want to prevent `auto-save-list-file-name'
357 from being initialized."
358 :type '(choice (const :tag "Don't record a session's auto save list" nil)
359 string)
360 :group 'auto-save)
361
362 (defvar init-file-debug nil)
363
364 (defvar init-file-had-error nil)
365
366 (defvar normal-top-level-add-subdirs-inode-list nil)
367
368 (defvar pure-space-overflow nil
369 "Non-nil if building Emacs overflowed pure space.")
370
371 (defun normal-top-level-add-subdirs-to-load-path ()
372 "Add all subdirectories of current directory to `load-path'.
373 More precisely, this uses only the subdirectories whose names
374 start with letters or digits; it excludes any subdirectory named `RCS'
375 or `CVS', and any subdirectory that contains a file named `.nosearch'."
376 (let (dirs
377 attrs
378 (pending (list default-directory)))
379 ;; This loop does a breadth-first tree walk on DIR's subtree,
380 ;; putting each subdir into DIRS as its contents are examined.
381 (while pending
382 (push (pop pending) dirs)
383 (let* ((this-dir (car dirs))
384 (contents (directory-files this-dir))
385 (default-directory this-dir)
386 (canonicalized (and (eq system-type 'windows-nt)
387 (untranslated-canonical-name this-dir))))
388 ;; The Windows version doesn't report meaningful inode
389 ;; numbers, so use the canonicalized absolute file name of the
390 ;; directory instead.
391 (setq attrs (or canonicalized
392 (nthcdr 10 (file-attributes this-dir))))
393 (unless (member attrs normal-top-level-add-subdirs-inode-list)
394 (push attrs normal-top-level-add-subdirs-inode-list)
395 (dolist (file contents)
396 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
397 (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs"))
398 (when (and (string-match "\\`[[:alnum:]]" file)
399 ;; Avoid doing a `stat' when it isn't necessary
400 ;; because that can cause trouble when an NFS server
401 ;; is down.
402 (not (string-match "\\.elc?\\'" file))
403 (file-directory-p file))
404 (let ((expanded (expand-file-name file)))
405 (unless (file-exists-p (expand-file-name ".nosearch"
406 expanded))
407 (setq pending (nconc pending (list expanded)))))))))))
408 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
409
410 ;; This function is called from a subdirs.el file.
411 ;; It assumes that default-directory is the directory
412 ;; in which the subdirs.el file exists,
413 ;; and it adds to load-path the subdirs of that directory
414 ;; as specified in DIRS. Normally the elements of DIRS are relative.
415 (defun normal-top-level-add-to-load-path (dirs)
416 (let ((tail load-path)
417 (thisdir (directory-file-name default-directory)))
418 (while (and tail
419 ;;Don't go all the way to the nil terminator.
420 (cdr tail)
421 (not (equal thisdir (car tail)))
422 (not (and (memq system-type '(ms-dos windows-nt))
423 (equal (downcase thisdir) (downcase (car tail))))))
424 (setq tail (cdr tail)))
425 ;;Splice the new section in.
426 (when tail
427 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
428
429 (defun normal-top-level ()
430 (if command-line-processed
431 (message "Back to top level.")
432 (setq command-line-processed t)
433 ;; Give *Messages* the same default-directory as *scratch*,
434 ;; just to keep things predictable.
435 (let ((dir default-directory))
436 (save-excursion
437 (set-buffer (get-buffer "*Messages*"))
438 (setq default-directory dir)))
439 ;; `user-full-name' is now known; reset its standard-value here.
440 (put 'user-full-name 'standard-value
441 (list (default-value 'user-full-name)))
442 ;; For root, preserve owner and group when editing files.
443 (if (equal (user-uid) 0)
444 (setq backup-by-copying-when-mismatch t))
445 ;; Look in each dir in load-path for a subdirs.el file.
446 ;; If we find one, load it, which will add the appropriate subdirs
447 ;; of that dir into load-path,
448 ;; Look for a leim-list.el file too. Loading it will register
449 ;; available input methods.
450 (let ((tail load-path)
451 new)
452 (while tail
453 (push (car tail) new)
454 (condition-case nil
455 (let ((default-directory (car tail)))
456 (load (expand-file-name "subdirs.el" (car tail)) t t t)))
457 (condition-case nil
458 (let ((default-directory (car tail)))
459 (load (expand-file-name "leim-list.el" (car tail)) t t t)))
460 (setq tail (cdr tail))))
461 (if (not (eq system-type 'vax-vms))
462 (progn
463 ;; If the PWD environment variable isn't accurate, delete it.
464 (let ((pwd (getenv "PWD")))
465 (and (stringp pwd)
466 ;; Use FOO/., so that if FOO is a symlink, file-attributes
467 ;; describes the directory linked to, not FOO itself.
468 (or (equal (file-attributes
469 (concat (file-name-as-directory pwd) "."))
470 (file-attributes
471 (concat (file-name-as-directory default-directory)
472 ".")))
473 (setq process-environment
474 (delete (concat "PWD=" pwd)
475 process-environment)))))))
476 (setq default-directory (abbreviate-file-name default-directory))
477 (let ((menubar-bindings-done nil))
478 (unwind-protect
479 (command-line)
480 ;; Do this again, in case .emacs defined more abbreviations.
481 (setq default-directory (abbreviate-file-name default-directory))
482 ;; Specify the file for recording all the auto save files of this session.
483 ;; This is used by recover-session.
484 (or auto-save-list-file-name
485 (and auto-save-list-file-prefix
486 (setq auto-save-list-file-name
487 ;; Under MS-DOS our PID is almost always reused between
488 ;; Emacs invocations. We need something more unique.
489 (cond ((eq system-type 'ms-dos)
490 ;; We are going to access the auto-save
491 ;; directory, so make sure it exists.
492 (make-directory
493 (file-name-directory auto-save-list-file-prefix)
494 t)
495 (concat
496 (make-temp-name
497 (expand-file-name
498 auto-save-list-file-prefix))
499 "~"))
500 (t
501 (expand-file-name
502 (format "%s%d-%s~"
503 auto-save-list-file-prefix
504 (emacs-pid)
505 (system-name))))))))
506 (unless inhibit-startup-hooks
507 (run-hooks 'emacs-startup-hook)
508 (and term-setup-hook
509 (run-hooks 'term-setup-hook)))
510
511 ;; Don't do this if we failed to create the initial frame,
512 ;; for instance due to a dense colormap.
513 (when (or frame-initial-frame
514 ;; If frame-initial-frame has no meaning, do this anyway.
515 (not (and window-system
516 (not noninteractive)
517 (not (eq window-system 'pc)))))
518 ;; Modify the initial frame based on what .emacs puts into
519 ;; ...-frame-alist.
520 (if (fboundp 'frame-notice-user-settings)
521 (frame-notice-user-settings))
522 (if (fboundp 'frame-set-background-mode)
523 ;; Set the faces for the initial background mode even if
524 ;; frame-notice-user-settings didn't (such as on a tty).
525 ;; frame-set-background-mode is idempotent, so it won't
526 ;; cause any harm if it's already been done.
527 (let ((frame-background-mode frame-background-mode)
528 (frame (selected-frame))
529 term)
530 (when (and (null window-system)
531 ;; Don't override a possibly customized value.
532 (null frame-background-mode)
533 ;; Don't override user specifications.
534 (null (frame-parameter frame 'reverse))
535 (let ((bg (frame-parameter frame 'background-color)))
536 (or (null bg)
537 (member bg '(unspecified "unspecified-bg")))))
538 (setq term (getenv "TERM"))
539 ;; Some files in lisp/term do a better job with the
540 ;; background mode, but we leave this here anyway, in
541 ;; case they remove those files.
542 (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
543 term)
544 (setq frame-background-mode 'light)))
545 (frame-set-background-mode (selected-frame)))))
546
547 ;; Now we know the user's default font, so add it to the menu.
548 (if (fboundp 'font-menu-add-default)
549 (font-menu-add-default))
550 (and window-setup-hook
551 (run-hooks 'window-setup-hook))
552 (or menubar-bindings-done
553 (if (display-popup-menus-p)
554 (precompute-menubar-bindings)))))))
555
556 ;; Precompute the keyboard equivalents in the menu bar items.
557 (defun precompute-menubar-bindings ()
558 (let ((submap (lookup-key global-map [menu-bar])))
559 (while submap
560 (and (consp (car submap))
561 (symbolp (car (car submap)))
562 (stringp (car-safe (cdr (car submap))))
563 (keymapp (cdr (cdr (car submap))))
564 (progn
565 (x-popup-menu nil (cdr (cdr (car submap))))
566 (if purify-flag
567 (garbage-collect))))
568 (setq submap (cdr submap))))
569 (setq define-key-rebound-commands t))
570
571 ;; Command-line options supported by tty's:
572 (defconst tty-long-option-alist
573 '(("--name" . "-name")
574 ("--title" . "-T")
575 ("--reverse-video" . "-reverse")
576 ("--foreground-color" . "-fg")
577 ("--background-color" . "-bg")
578 ("--color" . "-color")))
579
580 (defconst tool-bar-images-pixel-height 24
581 "Height in pixels of images in the tool bar.")
582
583 (defvar tool-bar-originally-present nil
584 "Non-nil if tool-bars are present before user and site init files are read.")
585
586 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
587 (defun tty-handle-args (args)
588 (let (rest)
589 (message "%s" args)
590 (while (and args
591 (not (equal (car args) "--")))
592 (let* ((argi (pop args))
593 (orig-argi argi)
594 argval completion)
595 ;; Check for long options with attached arguments
596 ;; and separate out the attached option argument into argval.
597 (when (string-match "^\\(--[^=]*\\)=" argi)
598 (setq argval (substring argi (match-end 0))
599 argi (match-string 1 argi)))
600 (when (string-match "^--" argi)
601 (setq completion (try-completion argi tty-long-option-alist))
602 (if (eq completion t)
603 ;; Exact match for long option.
604 (setq argi (cdr (assoc argi tty-long-option-alist)))
605 (if (stringp completion)
606 (let ((elt (assoc completion tty-long-option-alist)))
607 ;; Check for abbreviated long option.
608 (or elt
609 (error "Option `%s' is ambiguous" argi))
610 (setq argi (cdr elt)))
611 ;; Check for a short option.
612 (setq argval nil
613 argi orig-argi))))
614 (cond ((member argi '("-fg" "-foreground"))
615 (push (cons 'foreground-color (or argval (pop args)))
616 default-frame-alist))
617 ((member argi '("-bg" "-background"))
618 (push (cons 'background-color (or argval (pop args)))
619 default-frame-alist))
620 ((member argi '("-T" "-name"))
621 (unless argval (setq argval (pop args)))
622 (push (cons 'title
623 (if (stringp argval)
624 argval
625 (let ((case-fold-search t)
626 i)
627 (setq argval (invocation-name))
628
629 ;; Change any . or * characters in name to
630 ;; hyphens, so as to emulate behavior on X.
631 (while
632 (setq i (string-match "[.*]" argval))
633 (aset argval i ?-))
634 argval)))
635 default-frame-alist))
636 ((member argi '("-r" "-rv" "-reverse"))
637 (push '(reverse . t)
638 default-frame-alist))
639 ((equal argi "-color")
640 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
641 (push (cons 'tty-color-mode
642 (cond
643 ((numberp argval) argval)
644 ((string-match "-?[0-9]+" argval)
645 (string-to-number argval))
646 (t (intern argval))))
647 default-frame-alist))
648 (t
649 (push argi rest)))))
650 (nreverse rest)))
651
652 (defun command-line ()
653 (setq command-line-default-directory default-directory)
654
655 ;; Choose a reasonable location for temporary files.
656 (setq temporary-file-directory
657 (file-name-as-directory
658 (cond ((memq system-type '(ms-dos windows-nt))
659 (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
660 ((memq system-type '(vax-vms axp-vms))
661 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
662 (t
663 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp")))))
664 (setq small-temporary-file-directory
665 (if (eq system-type 'ms-dos)
666 (getenv "TMPDIR")))
667 (setq auto-save-file-name-transforms
668 (list (list "\\`/[^/]*:\\(.+/\\)*\\(.*\\)"
669 ;; Don't put "\\2" inside expand-file-name, since
670 ;; it will be transformed to "/2" on DOS/Windows.
671 (concat temporary-file-directory "\\2") t)))
672
673 ;; See if we should import version-control from the environment variable.
674 (let ((vc (getenv "VERSION_CONTROL")))
675 (cond ((eq vc nil)) ;don't do anything if not set
676 ((member vc '("t" "numbered"))
677 (setq version-control t))
678 ((member vc '("nil" "existing"))
679 (setq version-control nil))
680 ((member vc '("never" "simple"))
681 (setq version-control 'never))))
682
683 ;;! This has been commented out; I currently find the behavior when
684 ;;! split-window-keep-point is nil disturbing, but if I can get used
685 ;;! to it, then it would be better to eliminate the option.
686 ;;! ;; Choose a good default value for split-window-keep-point.
687 ;;! (setq split-window-keep-point (> baud-rate 2400))
688
689 ;; Set the default strings to display in mode line for
690 ;; end-of-line formats that aren't native to this platform.
691 (cond
692 ((memq system-type '(ms-dos windows-nt emx))
693 (setq eol-mnemonic-unix "(Unix)"
694 eol-mnemonic-mac "(Mac)"))
695 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
696 ;; abbreviated strings `/' and `:' set in coding.c for them.
697 ((eq system-type 'macos)
698 (setq eol-mnemonic-dos "(DOS)"))
699 (t ; this is for Unix/GNU/Linux systems
700 (setq eol-mnemonic-dos "(DOS)"
701 eol-mnemonic-mac "(Mac)")))
702
703 ;; Read window system's init file if using a window system.
704 (condition-case error
705 (if (and window-system (not noninteractive))
706 (load (concat term-file-prefix
707 (symbol-name window-system)
708 "-win")
709 ;; Every window system should have a startup file;
710 ;; barf if we can't find it.
711 nil t))
712 ;; If we can't read it, print the error message and exit.
713 (error
714 (princ
715 (if (eq (car error) 'error)
716 (apply 'concat (cdr error))
717 (if (memq 'file-error (get (car error) 'error-conditions))
718 (format "%s: %s"
719 (nth 1 error)
720 (mapconcat (lambda (obj) (prin1-to-string obj t))
721 (cdr (cdr error)) ", "))
722 (format "%s: %s"
723 (get (car error) 'error-message)
724 (mapconcat (lambda (obj) (prin1-to-string obj t))
725 (cdr error) ", "))))
726 'external-debugging-output)
727 (terpri 'external-debugging-output)
728 (setq window-system nil)
729 (kill-emacs)))
730
731 ;; Windowed displays do this inside their *-win.el.
732 (unless (or (display-graphic-p) noninteractive)
733 (setq command-line-args (tty-handle-args command-line-args)))
734
735 (set-locale-environment nil)
736
737 ;; Convert the arguments to Emacs internal representation.
738 (let ((args (cdr command-line-args)))
739 (while args
740 (setcar args
741 (decode-coding-string (car args) locale-coding-system t))
742 (pop args)))
743
744 (let ((done nil)
745 (args (cdr command-line-args)))
746
747 ;; Figure out which user's init file to load,
748 ;; either from the environment or from the options.
749 (setq init-file-user (if noninteractive nil (user-login-name)))
750 ;; If user has not done su, use current $HOME to find .emacs.
751 (and init-file-user
752 (equal init-file-user (user-real-login-name))
753 (setq init-file-user ""))
754
755 ;; Process the command-line args, and delete the arguments
756 ;; processed. This is consistent with the way main in emacs.c
757 ;; does things.
758 (while (and (not done) args)
759 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
760 ("--debug-init") ("--iconic") ("--icon-type")))
761 (argi (pop args))
762 (orig-argi argi)
763 argval)
764 ;; Handle --OPTION=VALUE format.
765 (when (string-match "^\\(--[^=]*\\)=" argi)
766 (setq argval (substring argi (match-end 0))
767 argi (match-string 1 argi)))
768 (unless (equal argi "--")
769 (let ((completion (try-completion argi longopts)))
770 (if (eq completion t)
771 (setq argi (substring argi 1))
772 (if (stringp completion)
773 (let ((elt (assoc completion longopts)))
774 (or elt
775 (error "Option `%s' is ambiguous" argi))
776 (setq argi (substring (car elt) 1)))
777 (setq argval nil
778 argi orig-argi)))))
779 (cond
780 ((member argi '("-q" "-no-init-file"))
781 (setq init-file-user nil))
782 ((member argi '("-u" "-user"))
783 (setq init-file-user (or argval (pop args))
784 argval nil))
785 ((equal argi "-no-site-file")
786 (setq site-run-file nil))
787 ((equal argi "-debug-init")
788 (setq init-file-debug t))
789 ((equal argi "-iconic")
790 (push '(visibility . icon) initial-frame-alist))
791 ((member argi '("-icon-type" "-i" "-itype"))
792 (push '(icon-type . t) default-frame-alist))
793 ;; Push the popped arg back on the list of arguments.
794 (t
795 (push argi args)
796 (setq done t)))
797 ;; Was argval set but not used?
798 (and argval
799 (error "Option `%s' doesn't allow an argument" argi))))
800
801 ;; Re-attach the program name to the front of the arg list.
802 (and command-line-args
803 (setcdr command-line-args args)))
804
805 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
806 (when (fboundp 'frame-initialize)
807 (frame-initialize))
808
809 ;; If frame was created with a menu bar, set menu-bar-mode on.
810 (unless (or noninteractive
811 (and (memq window-system '(x w32))
812 (<= (frame-parameter nil 'menu-bar-lines) 0)))
813 (menu-bar-mode 1))
814
815 ;; If frame was created with a tool bar, switch tool-bar-mode on.
816 (unless (or noninteractive
817 (not (display-graphic-p))
818 (<= (frame-parameter nil 'tool-bar-lines) 0))
819 (tool-bar-mode 1))
820
821 ;; Can't do this init in defcustom because window-system isn't set.
822 (unless (or noninteractive
823 (eq system-type 'ms-dos)
824 (not (memq window-system '(x w32))))
825 (setq-default blink-cursor t)
826 (blink-cursor-mode 1))
827
828 (unless noninteractive
829 ;; DOS/Windows systems have a PC-type keyboard which has both
830 ;; <delete> and <backspace> keys.
831 (when (or (memq system-type '(ms-dos windows-nt))
832 (and (memq window-system '(x))
833 (fboundp 'x-backspace-delete-keys-p)
834 (x-backspace-delete-keys-p))
835 ;; If the terminal Emacs is running on has erase char
836 ;; set to ^H, use the Backspace key for deleting
837 ;; backward and, and the Delete key for deleting forward.
838 (and (null window-system)
839 (eq tty-erase-char 8)))
840 (setq-default normal-erase-is-backspace t)
841 (normal-erase-is-backspace-mode 1)))
842
843 (unless (or noninteractive
844 (not (display-graphic-p))
845 (not (fboundp 'x-show-tip)))
846 (setq-default tooltip-mode t)
847 (tooltip-mode 1))
848
849 ;; Register default TTY colors for the case the terminal hasn't a
850 ;; terminal init file.
851 (unless (memq window-system '(x w32))
852 ;; We do this regardles of whether the terminal supports colors
853 ;; or not, since they can switch that support on or off in
854 ;; mid-session by setting the tty-color-mode frame parameter.
855 (tty-register-default-colors))
856
857 ;; Record whether the tool-bar is present before the user and site
858 ;; init files are processed. frame-notice-user-settings uses this
859 ;; to determine if the tool-bar has been disabled by the init files,
860 ;; and the frame needs to be resized.
861 (when (fboundp 'frame-notice-user-settings)
862 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
863 (assq 'tool-bar-lines default-frame-alist))))
864 (setq tool-bar-originally-present
865 (and tool-bar-lines
866 (cdr tool-bar-lines)
867 (not (eq 0 (cdr tool-bar-lines)))))))
868
869 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
870 (old-font-list-limit font-list-limit)
871 (old-face-ignored-fonts face-ignored-fonts))
872
873 (run-hooks 'before-init-hook)
874
875 ;; Run the site-start library if it exists. The point of this file is
876 ;; that it is run before .emacs. There is no point in doing this after
877 ;; .emacs; that is useless.
878 (if site-run-file
879 (load site-run-file t t))
880
881 ;; Sites should not disable this. Only individuals should disable
882 ;; the startup message.
883 (setq inhibit-startup-message nil)
884
885 ;; Load that user's init file, or the default one, or none.
886 (let (debug-on-error-from-init-file
887 debug-on-error-should-be-set
888 (debug-on-error-initial
889 (if (eq init-file-debug t) 'startup init-file-debug))
890 (orig-enable-multibyte default-enable-multibyte-characters))
891 (let ((debug-on-error debug-on-error-initial)
892 ;; This function actually reads the init files.
893 (inner
894 (function
895 (lambda ()
896 (if init-file-user
897 (let ((user-init-file-1
898 (cond
899 ((eq system-type 'ms-dos)
900 (concat "~" init-file-user "/_emacs"))
901 ((eq system-type 'windows-nt)
902 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
903 "~/.emacs"
904 "~/_emacs"))
905 ((eq system-type 'vax-vms)
906 "sys$login:.emacs")
907 (t
908 (concat "~" init-file-user "/.emacs")))))
909 ;; This tells `load' to store the file name found
910 ;; into user-init-file.
911 (setq user-init-file t)
912 (load user-init-file-1 t t)
913
914 (when (eq user-init-file t)
915 ;; If we did not find ~/.emacs, try
916 ;; ~/.emacs.d/.emacs.
917 (let ((otherfile
918 (expand-file-name
919 (file-name-nondirectory user-init-file-1)
920 (file-name-as-directory
921 (expand-file-name
922 ".emacs.d"
923 (file-name-directory user-init-file-1))))))
924 (load otherfile t t)
925
926 ;; If we did not find the user's init file,
927 ;; set user-init-file conclusively.
928 ;; Don't let it be set from default.el.
929 (when (eq user-init-file t)
930 (setq user-init-file user-init-file-1))))
931
932 ;; If we loaded a compiled file, set
933 ;; `user-init-file' to the source version if that
934 ;; exists.
935 (when (and user-init-file
936 (equal (file-name-extension user-init-file)
937 "elc"))
938 (let* ((source (file-name-sans-extension user-init-file))
939 (alt (concat source ".el")))
940 (setq source (cond ((file-exists-p alt) alt)
941 ((file-exists-p source) source)
942 (t nil)))
943 (when source
944 (when (file-newer-than-file-p source user-init-file)
945 (message "Warning: %s is newer than %s"
946 source user-init-file)
947 (sit-for 1))
948 (setq user-init-file source))))
949
950 (when (stringp custom-file)
951 (unless (assoc custom-file load-history)
952 ;; If the .emacs file has set `custom-file' but hasn't
953 ;; loaded the file yet, let's load it.
954 (load custom-file t t)))
955
956 (unless inhibit-default-init
957 (let ((inhibit-startup-message nil))
958 ;; Users are supposed to be told their rights.
959 ;; (Plus how to get help and how to undo.)
960 ;; Don't you dare turn this off for anyone
961 ;; except yourself.
962 (load "default" t t)))))))))
963 (if init-file-debug
964 ;; Do this without a condition-case if the user wants to debug.
965 (funcall inner)
966 (condition-case error
967 (progn
968 (funcall inner)
969 (setq init-file-had-error nil))
970 (error
971 (let ((message-log-max nil))
972 (save-excursion
973 (set-buffer (get-buffer-create "*Messages*"))
974 (insert "\n\n"
975 (format "An error has occurred while loading `%s':\n\n"
976 user-init-file)
977 (format "%s%s%s"
978 (get (car error) 'error-message)
979 (if (cdr error) ": " "")
980 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
981 "\n\n"
982 "To ensure normal operation, you should investigate and remove the\n"
983 "cause of the error in your initialization file. Start Emacs with\n"
984 "the `--debug-init' option to view a complete error backtrace.\n\n"))
985 (message "Error in init file: %s%s%s"
986 (get (car error) 'error-message)
987 (if (cdr error) ": " "")
988 (mapconcat 'prin1-to-string (cdr error) ", "))
989 (let ((pop-up-windows nil))
990 (pop-to-buffer "*Messages*"))
991 (setq init-file-had-error t)))))
992
993 ;; If the user has a file of abbrevs, read it.
994 (if (file-exists-p abbrev-file-name)
995 (quietly-read-abbrev-file abbrev-file-name))
996
997 ;; If the abbrevs came entirely from the init file or the
998 ;; abbrevs file, they do not need saving.
999 (setq abbrevs-changed nil)
1000
1001 ;; If we can tell that the init file altered debug-on-error,
1002 ;; arrange to preserve the value that it set up.
1003 (or (eq debug-on-error debug-on-error-initial)
1004 (setq debug-on-error-should-be-set t
1005 debug-on-error-from-init-file debug-on-error)))
1006 (if debug-on-error-should-be-set
1007 (setq debug-on-error debug-on-error-from-init-file))
1008 (unless (or default-enable-multibyte-characters
1009 (eq orig-enable-multibyte default-enable-multibyte-characters))
1010 ;; Init file changed to unibyte. Reset existing multibyte
1011 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1012 ;; Arguably this should only be done if they're free of
1013 ;; multibyte characters.
1014 (mapcar (lambda (buffer)
1015 (with-current-buffer buffer
1016 (if enable-multibyte-characters
1017 (set-buffer-multibyte nil))))
1018 (buffer-list))
1019 ;; Also re-set the language environment in case it was
1020 ;; originally done before unibyte was set and is sensitive to
1021 ;; unibyte (display table, terminal coding system &c).
1022 (set-language-environment current-language-environment)))
1023
1024 ;; Do this here in case the init file sets mail-host-address.
1025 (if (equal user-mail-address "")
1026 (setq user-mail-address (concat (user-login-name) "@"
1027 (or mail-host-address
1028 (system-name)))))
1029
1030 ;; If parameter have been changed in the init file which influence
1031 ;; face realization, clear the face cache so that new faces will
1032 ;; be realized.
1033 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1034 (eq font-list-limit old-font-list-limit)
1035 (eq face-ignored-fonts old-face-ignored-fonts))
1036 (clear-face-cache)))
1037
1038 (run-hooks 'after-init-hook)
1039
1040 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1041 (if (get-buffer "*scratch*")
1042 (with-current-buffer "*scratch*"
1043 (if (eq major-mode 'fundamental-mode)
1044 (funcall initial-major-mode))))
1045
1046 ;; Load library for our terminal type.
1047 ;; User init file can set term-file-prefix to nil to prevent this.
1048 (unless (or noninteractive
1049 window-system
1050 (null term-file-prefix))
1051 (let ((term (getenv "TERM"))
1052 hyphend)
1053 (while (and term
1054 (not (load (concat term-file-prefix term) t t)))
1055 ;; Strip off last hyphen and what follows, then try again
1056 (setq term
1057 (if (setq hyphend (string-match "[-_][^-_]+$" term))
1058 (substring term 0 hyphend)
1059 nil)))))
1060
1061 ;; Update the out-of-memory error message based on user's key bindings
1062 ;; for save-some-buffers.
1063 (setq memory-signal-data
1064 (list 'error
1065 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1066
1067 ;; Process the remaining args.
1068 (command-line-1 (cdr command-line-args))
1069
1070 ;; If -batch, terminate after processing the command options.
1071 (if noninteractive (kill-emacs t))
1072
1073 ;; Run emacs-session-restore (session management) if started by
1074 ;; the session manager and we have a session manager connection.
1075 (if (and (boundp 'x-session-previous-id)
1076 (stringp x-session-previous-id))
1077 (emacs-session-restore x-session-previous-id)))
1078
1079 (defcustom initial-scratch-message (purecopy "\
1080 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1081 ;; If you want to create a file, visit that file with C-x C-f,
1082 ;; then enter the text in that file's own buffer.
1083
1084 ")
1085 "Initial message displayed in *scratch* buffer at startup.
1086 If this is nil, no message will be displayed."
1087 :type '(choice (text :tag "Message")
1088 (const :tag "none" nil))
1089 :group 'initialization)
1090
1091 \f
1092 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1093 ;;; Fancy splash screen
1094 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1095
1096 (defvar fancy-splash-text
1097 '((:face variable-pitch
1098 "You can do basic editing with the menu bar and scroll bar \
1099 using the mouse.\n\n"
1100 :face (variable-pitch :weight bold)
1101 "Important Help menu items:\n"
1102 :face variable-pitch "\
1103 Emacs Tutorial\tLearn-by-doing tutorial for using Emacs efficiently
1104 Emacs FAQ\tFrequently asked questions and answers
1105 Read the Emacs Manual\tView the Emacs manual using Info
1106 \(Non)Warranty\tGNU Emacs comes with "
1107 :face (variable-pitch :slant oblique)
1108 "ABSOLUTELY NO WARRANTY\n"
1109 :face variable-pitch
1110 "\
1111 Copying Conditions\tConditions for redistributing and changing Emacs
1112 More Manuals / Ordering Manuals Buying printed manuals from the FSF\n")
1113 (:face variable-pitch
1114 "You can do basic editing with the menu bar and scroll bar \
1115 using the mouse.\n\n"
1116 :face (variable-pitch :weight bold)
1117 "Useful File menu items:\n"
1118 :face variable-pitch "\
1119 Exit Emacs\t(Or type Control-x followed by Control-c)
1120 Recover Session\tRecover files you were editing before a crash
1121
1122
1123
1124
1125 "
1126 ))
1127 "A list of texts to show in the middle part of splash screens.
1128 Each element in the list should be a list of strings or pairs
1129 `:face FACE', like `fancy-splash-insert' accepts them.")
1130
1131
1132 (defgroup fancy-splash-screen ()
1133 "Fancy splash screen when Emacs starts."
1134 :version "21.1"
1135 :group 'initialization)
1136
1137
1138 (defcustom fancy-splash-delay 10
1139 "*Delay in seconds between splash screens."
1140 :group 'fancy-splash-screen
1141 :type 'integer)
1142
1143
1144 (defcustom fancy-splash-max-time 60
1145 "*Show splash screens for at most this number of seconds.
1146 Values less than 60 seconds are ignored."
1147 :group 'fancy-splash-screen
1148 :type 'integer)
1149
1150
1151 (defcustom fancy-splash-image nil
1152 "*The image to show in the splash screens, or nil for defaults."
1153 :group 'fancy-splash-screen
1154 :type '(choice (const :tag "Default" nil)
1155 (file :tag "File")))
1156
1157
1158 ;; These are temporary storage areas for the splash screen display.
1159
1160 (defvar fancy-current-text nil)
1161 (defvar fancy-splash-help-echo nil)
1162 (defvar fancy-splash-stop-time nil)
1163 (defvar fancy-splash-outer-buffer nil)
1164
1165 (defun fancy-splash-insert (&rest args)
1166 "Insert text into the current buffer, with faces.
1167 Arguments from ARGS should be either strings or pairs `:face FACE',
1168 where FACE is a valid face specification, as it can be used with
1169 `put-text-properties'."
1170 (let ((current-face nil))
1171 (while args
1172 (if (eq (car args) :face)
1173 (setq args (cdr args) current-face (car args))
1174 (insert (propertize (car args)
1175 'face current-face
1176 'help-echo fancy-splash-help-echo)))
1177 (setq args (cdr args)))))
1178
1179
1180 (defun fancy-splash-head ()
1181 "Insert the head part of the splash screen into the current buffer."
1182 (let* ((image-file (cond ((stringp fancy-splash-image)
1183 fancy-splash-image)
1184 ((and (display-color-p)
1185 (image-type-available-p 'xpm))
1186 (if (and (fboundp 'x-display-planes)
1187 (= (funcall 'x-display-planes) 8))
1188 "splash8.xpm"
1189 "splash.xpm"))
1190 (t "splash.pbm")))
1191 (img (create-image image-file))
1192 (image-width (and img (car (image-size img))))
1193 (window-width (window-width (selected-window))))
1194 (when img
1195 (when (> window-width image-width)
1196 ;; Center the image in the window.
1197 (let ((pos (/ (- window-width image-width) 2)))
1198 (insert (propertize " " 'display `(space :align-to ,pos))))
1199
1200 ;; Change the color of the XPM version of the splash image
1201 ;; so that it is visible with a dark frame background.
1202 (when (and (memq 'xpm img)
1203 (eq (frame-parameter nil 'background-mode) 'dark))
1204 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1205
1206 ;; Insert the image with a help-echo and a keymap.
1207 (let ((map (make-sparse-keymap))
1208 (help-echo "mouse-2: browse http://www.gnu.org/"))
1209 (define-key map [mouse-2]
1210 (lambda ()
1211 (interactive)
1212 (browse-url "http://www.gnu.org/")
1213 (throw 'exit nil)))
1214 (define-key map [down-mouse-2] 'ignore)
1215 (define-key map [up-mouse-2] 'ignore)
1216 (insert-image img (propertize "xxx" 'help-echo help-echo
1217 'keymap map)))
1218 (insert "\n"))))
1219 (fancy-splash-insert
1220 :face '(variable-pitch :foreground "red")
1221 (if (eq system-type 'gnu/linux)
1222 "GNU Emacs is one component of the GNU/Linux operating system."
1223 "GNU Emacs is one component of the GNU operating system."))
1224 (insert "\n")
1225 (unless (equal (buffer-name fancy-splash-outer-buffer) "*scratch*")
1226 (fancy-splash-insert :face 'variable-pitch
1227 (substitute-command-keys
1228 "Type \\[recenter] to begin editing your file.\n"))))
1229
1230
1231 (defun fancy-splash-tail ()
1232 "Insert the tail part of the splash screen into the current buffer."
1233 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1234 "cyan" "darkblue")))
1235 (fancy-splash-insert :face `(variable-pitch :foreground ,fg)
1236 "\nThis is "
1237 (emacs-version)
1238 "\n"
1239 :face '(variable-pitch :height 0.5)
1240 "Copyright (C) 2002 Free Software Foundation, Inc.")
1241 (and auto-save-list-file-prefix
1242 ;; Don't signal an error if the
1243 ;; directory for auto-save-list files
1244 ;; does not yet exist.
1245 (file-directory-p (file-name-directory
1246 auto-save-list-file-prefix))
1247 (directory-files
1248 (file-name-directory auto-save-list-file-prefix)
1249 nil
1250 (concat "\\`"
1251 (regexp-quote (file-name-nondirectory
1252 auto-save-list-file-prefix)))
1253 t)
1254 (fancy-splash-insert :face '(variable-pitch :foreground "red")
1255 "\n\nIf an Emacs session crashed recently, "
1256 "type M-x recover-session RET\nto recover"
1257 " the files you were editing."))))
1258
1259 (defun fancy-splash-screens-1 (buffer)
1260 "Timer function displaying a splash screen."
1261 (when (> (float-time) fancy-splash-stop-time)
1262 (throw 'stop-splashing nil))
1263 (unless fancy-current-text
1264 (setq fancy-current-text fancy-splash-text))
1265 (let ((text (car fancy-current-text)))
1266 (set-buffer buffer)
1267 (erase-buffer)
1268 (if pure-space-overflow
1269 (insert "Warning Warning Pure space overflow Warning Warning\n"))
1270 (fancy-splash-head)
1271 (apply #'fancy-splash-insert text)
1272 (fancy-splash-tail)
1273 (unless (current-message)
1274 (message fancy-splash-help-echo))
1275 (set-buffer-modified-p nil)
1276 (goto-char (point-min))
1277 (force-mode-line-update)
1278 (setq fancy-current-text (cdr fancy-current-text))))
1279
1280
1281 (defun fancy-splash-default-action ()
1282 "Stop displaying the splash screen buffer.
1283 This is an internal function used to turn off the splash screen after
1284 the user caused an input event by hitting a key or clicking with the
1285 mouse."
1286 (interactive)
1287 (push last-command-event unread-command-events)
1288 (throw 'exit nil))
1289
1290
1291 (defun fancy-splash-screens ()
1292 "Display fancy splash screens when Emacs starts."
1293 (setq fancy-splash-help-echo (startup-echo-area-message))
1294 (let ((old-hourglass display-hourglass)
1295 (fancy-splash-outer-buffer (current-buffer))
1296 splash-buffer
1297 (old-minor-mode-map-alist minor-mode-map-alist)
1298 (frame (fancy-splash-frame))
1299 timer)
1300 (save-selected-window
1301 (select-frame frame)
1302 (switch-to-buffer "GNU Emacs")
1303 (setq tab-width 20)
1304 (setq splash-buffer (current-buffer))
1305 (catch 'stop-splashing
1306 (unwind-protect
1307 (let ((map (make-sparse-keymap)))
1308 (use-local-map map)
1309 (define-key map [switch-frame] 'ignore)
1310 (define-key map [t] 'fancy-splash-default-action)
1311 (define-key map [mouse-movement] 'ignore)
1312 (define-key map [mode-line t] 'ignore)
1313 (setq cursor-type nil
1314 display-hourglass nil
1315 minor-mode-map-alist nil
1316 buffer-undo-list t
1317 mode-line-format (propertize "---- %b %-"
1318 'face '(:weight bold))
1319 fancy-splash-stop-time (+ (float-time)
1320 (max 60 fancy-splash-max-time))
1321 timer (run-with-timer 0 fancy-splash-delay
1322 #'fancy-splash-screens-1
1323 splash-buffer))
1324 (recursive-edit))
1325 (cancel-timer timer)
1326 (setq display-hourglass old-hourglass
1327 minor-mode-map-alist old-minor-mode-map-alist)
1328 (kill-buffer splash-buffer))))))
1329
1330 (defun fancy-splash-frame ()
1331 "Return the frame to use for the fancy splash screen.
1332 Returning non-nil does not mean we should necessarily
1333 use the fancy splash screen, but if we do use it,
1334 we put it on this frame."
1335 (let (chosen-frame)
1336 (dolist (frame (append (frame-list) (list (selected-frame))))
1337 (if (and (frame-visible-p frame)
1338 (not (window-minibuffer-p (frame-selected-window frame))))
1339 (setq chosen-frame frame)))
1340 chosen-frame))
1341
1342 (defun use-fancy-splash-screens-p ()
1343 "Return t if fancy splash screens should be used."
1344 (when (or (and (display-color-p)
1345 (image-type-available-p 'xpm))
1346 (image-type-available-p 'pbm))
1347 (let ((frame (fancy-splash-frame)))
1348 (when frame
1349 (let* ((img (create-image (or fancy-splash-image
1350 (if (and (display-color-p)
1351 (image-type-available-p 'xpm))
1352 "splash.xpm" "splash.pbm"))))
1353 (image-height (and img (cdr (image-size img))))
1354 (window-height (1- (window-height (frame-selected-window frame)))))
1355 (> window-height (+ image-height 19)))))))
1356
1357
1358 (defun normal-splash-screen ()
1359 "Display splash screen when Emacs starts."
1360 (let ((prev-buffer (current-buffer)))
1361 (unwind-protect
1362 (with-current-buffer (get-buffer-create "GNU Emacs")
1363 (let ((tab-width 8)
1364 (mode-line-format (propertize "---- %b %-"
1365 'face '(:weight bold))))
1366
1367 (if pure-space-overflow
1368 (insert "Warning Warning Pure space overflow Warning Warning\n"))
1369
1370 ;; The convention for this piece of code is that
1371 ;; each piece of output starts with one or two newlines
1372 ;; and does not end with any newlines.
1373 (insert "Welcome to GNU Emacs")
1374 (insert
1375 (if (eq system-type 'gnu/linux)
1376 ", one component of the GNU/Linux operating system.\n"
1377 ", a part of the GNU operating system.\n"))
1378
1379 (unless (equal (buffer-name prev-buffer) "*scratch*")
1380 (insert (substitute-command-keys
1381 "\nType \\[recenter] to begin editing your file.\n")))
1382
1383 (if (display-mouse-p)
1384 ;; The user can use the mouse to activate menus
1385 ;; so give help in terms of menu items.
1386 (progn
1387 (insert "\
1388 You can do basic editing with the menu bar and scroll bar using the mouse.
1389
1390 Useful File menu items:
1391 Exit Emacs (or type Control-x followed by Control-c)
1392 Recover Session recover files you were editing before a crash
1393
1394 Important Help menu items:
1395 Emacs Tutorial Learn-by-doing tutorial for using Emacs efficiently.
1396 Emacs FAQ Frequently asked questions and answers
1397 Read the Emacs Manual View the Emacs manual using Info
1398 \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY
1399 Copying Conditions Conditions for redistributing and changing Emacs.
1400 Getting New Versions How to obtain the latest version of Emacs.
1401 More Manuals / Ordering Manuals How to order printed manuals from the FSF.
1402 ")
1403 (insert "\n\n" (emacs-version)
1404 "
1405 Copyright (C) 2002 Free Software Foundation, Inc."))
1406
1407 ;; No mouse menus, so give help using kbd commands.
1408
1409 ;; If keys have their default meanings,
1410 ;; use precomputed string to save lots of time.
1411 (if (and (eq (key-binding "\C-h") 'help-command)
1412 (eq (key-binding "\C-xu") 'advertised-undo)
1413 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
1414 (eq (key-binding "\C-ht") 'help-with-tutorial)
1415 (eq (key-binding "\C-hi") 'info)
1416 (eq (key-binding "\C-hr") 'info-emacs-manual)
1417 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
1418 (insert "
1419 Get help C-h (Hold down CTRL and press h)
1420 Emacs manual C-h r
1421 Emacs tutorial C-h t Undo changes C-x u
1422 Buy manuals C-h C-m Exit Emacs C-x C-c
1423 Browse manuals C-h i")
1424
1425 (insert (substitute-command-keys
1426 (format "\n
1427 Get help %s
1428 Emacs manual \\[info-emacs-manual]
1429 Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
1430 Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs]
1431 Browse manuals \\[info]"
1432 (let ((where (where-is-internal
1433 'help-command nil t)))
1434 (if where
1435 (key-description where)
1436 "M-x help"))))))
1437
1438 ;; Say how to use the menu bar with the keyboard.
1439 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1440 (eq (key-binding [f10]) 'tmm-menubar))
1441 (insert "
1442 Activate menubar F10 or ESC ` or M-`")
1443 (insert (substitute-command-keys "
1444 Activate menubar \\[tmm-menubar]")))
1445
1446 ;; Many users seem to have problems with these.
1447 (insert "
1448 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1449 If you have no Meta key, you may instead type ESC followed by the character.)")
1450
1451 (insert "\n\n" (emacs-version)
1452 "
1453 Copyright (C) 2002 Free Software Foundation, Inc.")
1454
1455 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1456 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1457 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1458 (insert
1459 "\n
1460 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
1461 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1462 of Emacs and modify it; type C-h C-c to see the conditions.
1463 Type C-h C-d for information on getting the latest version.")
1464 (insert (substitute-command-keys
1465 "\n
1466 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
1467 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1468 of Emacs and modify it; type \\[describe-copying] to see the conditions.
1469 Type \\[describe-distribution] for information on getting the latest version."))))
1470
1471 ;; The rest of the startup screen is the same on all
1472 ;; kinds of terminals.
1473
1474 ;; Give information on recovering, if there was a crash.
1475 (and auto-save-list-file-prefix
1476 ;; Don't signal an error if the
1477 ;; directory for auto-save-list files
1478 ;; does not yet exist.
1479 (file-directory-p (file-name-directory
1480 auto-save-list-file-prefix))
1481 (directory-files
1482 (file-name-directory auto-save-list-file-prefix)
1483 nil
1484 (concat "\\`"
1485 (regexp-quote (file-name-nondirectory
1486 auto-save-list-file-prefix)))
1487 t)
1488 (insert "\n\nIf an Emacs session crashed recently, "
1489 "type M-x recover-session RET\nto recover"
1490 " the files you were editing."))
1491
1492 ;; Display the input that we set up in the buffer.
1493 (set-buffer-modified-p nil)
1494 (goto-char (point-min))
1495 (save-window-excursion
1496 (switch-to-buffer (current-buffer))
1497 (sit-for 120))))
1498 ;; Unwind ... ensure splash buffer is killed
1499 (kill-buffer "GNU Emacs"))))
1500
1501
1502 (defun startup-echo-area-message ()
1503 (if (eq (key-binding "\C-h\C-p") 'describe-project)
1504 "For information about the GNU Project and its goals, type C-h C-p."
1505 (substitute-command-keys
1506 "For information about the GNU Project and its goals, type \
1507 \\[describe-project].")))
1508
1509
1510 (defun display-startup-echo-area-message ()
1511 (let ((resize-mini-windows t))
1512 (message (startup-echo-area-message))))
1513
1514
1515 (defun display-splash-screen ()
1516 "Display splash screen according to display.
1517 Fancy splash screens are used on graphic displays,
1518 normal otherwise."
1519 (interactive)
1520 (if (and (display-graphic-p)
1521 (use-fancy-splash-screens-p))
1522 (fancy-splash-screens)
1523 (normal-splash-screen)))
1524
1525
1526 (defun command-line-1 (command-line-args-left)
1527 (or noninteractive (input-pending-p) init-file-had-error
1528 ;; t if the init file says to inhibit the echo area startup message.
1529 (and inhibit-startup-echo-area-message
1530 user-init-file
1531 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1532 (equal inhibit-startup-echo-area-message
1533 (if (equal init-file-user "")
1534 (user-login-name)
1535 init-file-user)))
1536 ;; Wasn't set with custom; see if .emacs has a setq.
1537 (let ((buffer (get-buffer-create " *temp*")))
1538 (prog1
1539 (condition-case nil
1540 (save-excursion
1541 (set-buffer buffer)
1542 (insert-file-contents user-init-file)
1543 (re-search-forward
1544 (concat
1545 "([ \t\n]*setq[ \t\n]+"
1546 "inhibit-startup-echo-area-message[ \t\n]+"
1547 (regexp-quote
1548 (prin1-to-string
1549 (if (equal init-file-user "")
1550 (user-login-name)
1551 init-file-user)))
1552 "[ \t\n]*)")
1553 nil t))
1554 (error nil))
1555 (kill-buffer buffer)))))
1556 (display-startup-echo-area-message))
1557
1558 ;; Delay 2 seconds after an init file error message
1559 ;; was displayed, so user can read it.
1560 (when init-file-had-error
1561 (sit-for 2))
1562
1563 (when command-line-args-left
1564 ;; We have command args; process them.
1565 (let ((dir command-line-default-directory)
1566 (file-count 0)
1567 first-file-buffer
1568 tem
1569 ;; The directories listed in --directory/-L options will *appear*
1570 ;; at the front of `load-path' in the order they appear on the
1571 ;; command-line. We cannot do this by *placing* them at the front
1572 ;; in the order they appear, so we need this variable to hold them,
1573 ;; temporarily.
1574 extra-load-path
1575 just-files ;; t if this follows the magic -- option.
1576 ;; This includes our standard options' long versions
1577 ;; and long versions of what's on command-switch-alist.
1578 (longopts
1579 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1580 ("--directory") ("--eval") ("--execute") ("--no-splash")
1581 ("--find-file") ("--visit") ("--file"))
1582 (mapcar (lambda (elt)
1583 (list (concat "-" (car elt))))
1584 command-switch-alist)))
1585 (line 0)
1586 (column 0))
1587
1588 ;; Add the long X options to longopts.
1589 (dolist (tem command-line-x-option-alist)
1590 (if (string-match "^--" (car tem))
1591 (push (list (car tem)) longopts)))
1592
1593 ;; Loop, processing options.
1594 (while command-line-args-left
1595 (let* ((argi (car command-line-args-left))
1596 (orig-argi argi)
1597 argval completion)
1598 (setq command-line-args-left (cdr command-line-args-left))
1599
1600 ;; Do preliminary decoding of the option.
1601 (if just-files
1602 ;; After --, don't look for options; treat all args as files.
1603 (setq argi "")
1604 ;; Convert long options to ordinary options
1605 ;; and separate out an attached option argument into argval.
1606 (when (string-match "^\\(--[^=]*\\)=" argi)
1607 (setq argval (substring argi (match-end 0))
1608 argi (match-string 1 argi)))
1609 (if (equal argi "--")
1610 (setq completion nil)
1611 (setq completion (try-completion argi longopts)))
1612 (if (eq completion t)
1613 (setq argi (substring argi 1))
1614 (if (stringp completion)
1615 (let ((elt (assoc completion longopts)))
1616 (or elt
1617 (error "Option `%s' is ambiguous" argi))
1618 (setq argi (substring (car elt) 1)))
1619 (setq argval nil
1620 argi orig-argi))))
1621
1622 ;; Execute the option.
1623 (cond ((setq tem (assoc argi command-switch-alist))
1624 (if argval
1625 (let ((command-line-args-left
1626 (cons argval command-line-args-left)))
1627 (funcall (cdr tem) argi))
1628 (funcall (cdr tem) argi)))
1629
1630 ((equal argi "-no-splash")
1631 (setq inhibit-startup-message t))
1632
1633 ((member argi '("-f" ; what the manual claims
1634 "-funcall"
1635 "-e")) ; what the source used to say
1636 (setq tem (intern (or argval (pop command-line-args-left))))
1637 (if (commandp tem)
1638 (command-execute tem)
1639 (funcall tem)))
1640
1641 ((member argi '("-eval" "-execute"))
1642 (eval (read (or argval (pop command-line-args-left)))))
1643 ;; Set the default directory as specified in -L.
1644
1645 ((member argi '("-L" "-directory"))
1646 (setq tem (or argval (pop command-line-args-left)))
1647 ;; We will reverse `extra-load-path' and prepend it to
1648 ;; `load-path' after all the arguments have been processed.
1649 (push
1650 (expand-file-name (command-line-normalize-file-name tem))
1651 extra-load-path))
1652
1653 ((member argi '("-l" "-load"))
1654 (let* ((file (command-line-normalize-file-name
1655 (or argval (pop command-line-args-left))))
1656 ;; Take file from default dir if it exists there;
1657 ;; otherwise let `load' search for it.
1658 (file-ex (expand-file-name file)))
1659 (when (file-exists-p file-ex)
1660 (setq file file-ex))
1661 (load file nil t)))
1662
1663 ((equal argi "-insert")
1664 (setq tem (or argval (pop command-line-args-left)))
1665 (or (stringp tem)
1666 (error "File name omitted from `-insert' option"))
1667 (insert-file-contents (command-line-normalize-file-name tem)))
1668
1669 ((equal argi "-kill")
1670 (kill-emacs t))
1671
1672 ((string-match "^\\+[0-9]+\\'" argi)
1673 (setq line (string-to-int argi)))
1674
1675 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
1676 (setq line (string-to-int (match-string 1 argi))
1677 column (string-to-int (match-string 2 argi))))
1678
1679 ((setq tem (assoc argi command-line-x-option-alist))
1680 ;; Ignore X-windows options and their args if not using X.
1681 (setq command-line-args-left
1682 (nthcdr (nth 1 tem) command-line-args-left)))
1683
1684 ((member argi '("-find-file" "-file" "-visit"))
1685 ;; An explicit option to specify visiting a file.
1686 (setq tem (or argval (pop command-line-args-left)))
1687 (unless (stringp tem)
1688 (error "File name omitted from `%s' option" argi))
1689 (setq file-count (1+ file-count))
1690 (let ((file (expand-file-name
1691 (command-line-normalize-file-name tem) dir)))
1692 (if (= file-count 1)
1693 (setq first-file-buffer (find-file file))
1694 (find-file-other-window file)))
1695 (or (zerop line)
1696 (goto-line line))
1697 (setq line 0)
1698 (unless (< column 1)
1699 (move-to-column (1- column)))
1700 (setq column 0))
1701
1702 ((equal argi "--")
1703 (setq just-files t))
1704 (t
1705 ;; We have almost exhausted our options. See if the
1706 ;; user has made any other command-line options available
1707 (let ((hooks command-line-functions) ;; lrs 7/31/89
1708 (did-hook nil))
1709 (while (and hooks
1710 (not (setq did-hook (funcall (car hooks)))))
1711 (setq hooks (cdr hooks)))
1712 (if (not did-hook)
1713 ;; Presume that the argument is a file name.
1714 (progn
1715 (if (string-match "\\`-" argi)
1716 (error "Unknown option `%s'" argi))
1717 (setq file-count (1+ file-count))
1718 (let ((file
1719 (expand-file-name
1720 (command-line-normalize-file-name orig-argi)
1721 dir)))
1722 (if (= file-count 1)
1723 (setq first-file-buffer (find-file file))
1724 (find-file-other-window file)))
1725 (or (zerop line)
1726 (goto-line line))
1727 (setq line 0)
1728 (unless (< column 1)
1729 (move-to-column (1- column)))
1730 (setq column 0))))))))
1731
1732 ;; See --directory/-L option above.
1733 (when extra-load-path
1734 (setq load-path (append (nreverse extra-load-path) load-path)))
1735
1736 ;; If 3 or more files visited, and not all visible,
1737 ;; show user what they all are. But leave the last one current.
1738 (and (> file-count 2)
1739 (not noninteractive)
1740 (not inhibit-startup-buffer-menu)
1741 (or (get-buffer-window first-file-buffer)
1742 (list-buffers)))))
1743
1744 ;; Maybe display a startup screen.
1745 (when (and (not inhibit-startup-message) (not noninteractive)
1746 ;; Don't display startup screen if init file
1747 ;; has started some sort of server.
1748 (not (and (fboundp 'process-list)
1749 (process-list))))
1750 ;; Display a startup screen, after some preparations.
1751
1752 ;; If there are no switches to process, we might as well
1753 ;; run this hook now, and there may be some need to do it
1754 ;; before doing any output.
1755 (run-hooks 'emacs-startup-hook)
1756 (and term-setup-hook
1757 (run-hooks 'term-setup-hook))
1758 (setq inhibit-startup-hooks t)
1759
1760 ;; It's important to notice the user settings before we
1761 ;; display the startup message; otherwise, the settings
1762 ;; won't take effect until the user gives the first
1763 ;; keystroke, and that's distracting.
1764 (when (fboundp 'frame-notice-user-settings)
1765 (frame-notice-user-settings))
1766
1767 ;; If there are no switches to process, we might as well
1768 ;; run this hook now, and there may be some need to do it
1769 ;; before doing any output.
1770 (when window-setup-hook
1771 (run-hooks 'window-setup-hook)
1772 ;; Don't let the hook be run twice.
1773 (setq window-setup-hook nil))
1774
1775 ;; Do this now to avoid an annoying delay if the user
1776 ;; clicks the menu bar during the sit-for.
1777 (when (display-popup-menus-p)
1778 (precompute-menubar-bindings))
1779 (with-no-warnings
1780 (setq menubar-bindings-done t))
1781
1782 ;; If *scratch* is selected and it is empty, insert an
1783 ;; initial message saying not to create a file there.
1784 (when (and initial-scratch-message
1785 (equal (buffer-name) "*scratch*")
1786 (= 0 (buffer-size)))
1787 (insert initial-scratch-message)
1788 (set-buffer-modified-p nil))
1789
1790 ;; If user typed input during all that work,
1791 ;; abort the startup screen. Otherwise, display it now.
1792 (unless (input-pending-p)
1793 (display-splash-screen))))
1794
1795
1796 (defun command-line-normalize-file-name (file)
1797 "Collapse multiple slashes to one, to handle non-Emacs file names."
1798 (save-match-data
1799 ;; Use arg 1 so that we don't collapse // at the start of the file name.
1800 ;; That is significant on some systems.
1801 ;; However, /// at the beginning is supposed to mean just /, not //.
1802 (if (string-match "^///+" file)
1803 (setq file (replace-match "/" t t file)))
1804 (while (string-match "//+" file 1)
1805 (setq file (replace-match "/" t t file)))
1806 file))
1807
1808 ;;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
1809 ;;; startup.el ends here