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