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