33ad8a586cb10a2f5741ea87f4eb6ff7d741cae2
[bpt/emacs.git] / 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, 2006, 2007, 2008
5 ;; Free Software Foundation, Inc.
6
7 ;; Maintainer: FSF
8 ;; Keywords: internal
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; This file parses the command line and gets Emacs running. Options
28 ;; on the command line are handled in precedence order. For priorities
29 ;; see the structure standard_args in the emacs.c file.
30
31 ;;; Code:
32
33 (setq top-level '(normal-top-level))
34
35 (defvar command-line-processed nil
36 "Non-nil once command line has been processed.")
37
38 (defgroup initialization nil
39 "Emacs start-up procedure."
40 :group 'environment)
41
42 (defcustom initial-buffer-choice nil
43 "Buffer to show after starting Emacs.
44 If the value is nil and `inhibit-startup-screen' is nil, show the
45 startup screen. If the value is string, visit the specified file or
46 directory using `find-file'. If t, open the `*scratch*' buffer."
47 :type '(choice
48 (const :tag "Startup screen" nil)
49 (directory :tag "Directory" :value "~/")
50 (file :tag "File" :value "~/file.txt")
51 (const :tag "Lisp scratch buffer" t))
52 :version "23.1"
53 :group 'initialization)
54
55 (defcustom inhibit-startup-screen nil
56 "Non-nil inhibits the startup screen.
57
58 This is for use in your personal init file (but NOT site-start.el), once
59 you are familiar with the contents of the startup screen."
60 :type 'boolean
61 :group 'initialization)
62
63 (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen)
64 (defvaralias 'inhibit-startup-message 'inhibit-startup-screen)
65
66 (defvar startup-screen-inhibit-startup-screen nil)
67
68 (defcustom inhibit-startup-echo-area-message nil
69 "*Non-nil inhibits the initial startup echo area message.
70 Setting this variable takes effect
71 only if you do it with the customization buffer
72 or if your `.emacs' file contains a line of this form:
73 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
74 If your `.emacs' file is byte-compiled, use the following form instead:
75 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
76 Thus, someone else using a copy of your `.emacs' file will see
77 the startup message unless he personally acts to inhibit it."
78 :type '(choice (const :tag "Don't inhibit")
79 (string :tag "Enter your user name, to inhibit"))
80 :group 'initialization)
81
82 (defcustom inhibit-default-init nil
83 "*Non-nil inhibits loading the `default' library."
84 :type 'boolean
85 :group 'initialization)
86
87 (defcustom inhibit-startup-buffer-menu nil
88 "*Non-nil inhibits display of buffer list when more than 2 files are loaded."
89 :type 'boolean
90 :group 'initialization)
91
92 (defvar command-switch-alist nil
93 "Alist of command-line switches.
94 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
95 HANDLER-FUNCTION receives the switch string as its sole argument;
96 the remaining command-line args are in the variable `command-line-args-left'.")
97
98 (defvar command-line-args-left nil
99 "List of command-line args not yet processed.")
100
101 (defvaralias 'argv 'command-line-args-left
102 "List of command-line args not yet processed.
103 This is a convenience alias, so that one can write \(pop argv\)
104 inside of --eval command line arguments in order to access
105 following arguments.")
106
107 (defvar command-line-functions nil ;; lrs 7/31/89
108 "List of functions to process unrecognized command-line arguments.
109 Each function should access the dynamically bound variables
110 `argi' (the current argument) and `command-line-args-left' (the remaining
111 arguments). The function should return non-nil only if it recognizes and
112 processes `argi'. If it does so, it may consume successive arguments by
113 altering `command-line-args-left' to remove them.")
114
115 (defvar command-line-default-directory nil
116 "Default directory to use for command line arguments.
117 This is normally copied from `default-directory' when Emacs starts.")
118
119 ;;; This is here, rather than in x-win.el, so that we can ignore these
120 ;;; options when we are not using X.
121 (defconst command-line-x-option-alist
122 '(("-bw" 1 x-handle-numeric-switch border-width)
123 ("-d" 1 x-handle-display)
124 ("-display" 1 x-handle-display)
125 ("-name" 1 x-handle-name-switch)
126 ("-title" 1 x-handle-switch title)
127 ("-T" 1 x-handle-switch title)
128 ("-r" 0 x-handle-switch reverse t)
129 ("-rv" 0 x-handle-switch reverse t)
130 ("-reverse" 0 x-handle-switch reverse t)
131 ("-reverse-video" 0 x-handle-switch reverse t)
132 ("-fn" 1 x-handle-switch font)
133 ("-font" 1 x-handle-switch font)
134 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
135 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
136 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
137 ("-ib" 1 x-handle-numeric-switch internal-border-width)
138 ("-g" 1 x-handle-geometry)
139 ("-lsp" 1 x-handle-numeric-switch line-spacing)
140 ("-geometry" 1 x-handle-geometry)
141 ("-fg" 1 x-handle-switch foreground-color)
142 ("-foreground" 1 x-handle-switch foreground-color)
143 ("-bg" 1 x-handle-switch background-color)
144 ("-background" 1 x-handle-switch background-color)
145 ("-ms" 1 x-handle-switch mouse-color)
146 ("-nbi" 0 x-handle-switch icon-type nil)
147 ("-iconic" 0 x-handle-iconic)
148 ("-xrm" 1 x-handle-xrm-switch)
149 ("-cr" 1 x-handle-switch cursor-color)
150 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
151 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
152 ("-bd" 1 x-handle-switch)
153 ("--border-width" 1 x-handle-numeric-switch border-width)
154 ("--display" 1 x-handle-display)
155 ("--name" 1 x-handle-name-switch)
156 ("--title" 1 x-handle-switch title)
157 ("--reverse-video" 0 x-handle-switch reverse t)
158 ("--font" 1 x-handle-switch font)
159 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
160 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
161 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
162 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
163 ("--geometry" 1 x-handle-geometry)
164 ("--foreground-color" 1 x-handle-switch foreground-color)
165 ("--background-color" 1 x-handle-switch background-color)
166 ("--mouse-color" 1 x-handle-switch mouse-color)
167 ("--no-bitmap-icon" 0 x-handle-no-bitmap-icon)
168 ("--iconic" 0 x-handle-iconic)
169 ("--xrm" 1 x-handle-xrm-switch)
170 ("--cursor-color" 1 x-handle-switch cursor-color)
171 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
172 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
173 ("--border-color" 1 x-handle-switch border-color)
174 ("--smid" 1 x-handle-smid)
175 ("--parent-id" 1 x-handle-parent-id))
176 "Alist of X Windows options.
177 Each element has the form
178 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
179 where NAME is the option name string, NUMARGS is the number of arguments
180 that the option accepts, HANDLER is a function to call to handle the option.
181 FRAME-PARAM (optional) is the frame parameter this option specifies,
182 and VALUE is the value which is given to that frame parameter
183 \(most options use the argument for this, so VALUE is not present).")
184
185 (defconst command-line-ns-option-alist
186 '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
187 ("-NXAutoLaunch" 1 ns-ignore-1-arg)
188 ("-macosx" 0 ns-ignore-0-arg)
189 ("-NSHost" 1 ns-ignore-1-arg)
190 ("-_NSMachLaunch" 1 ns-ignore-1-arg)
191 ("-MachLaunch" 1 ns-ignore-1-arg)
192 ("-NXOpen" 1 ns-ignore-1-arg)
193 ("-NSOpen" 1 ns-handle-nxopen)
194 ("-NXOpenTemp" 1 ns-ignore-1-arg)
195 ("-NSOpenTemp" 1 ns-handle-nxopentemp)
196 ("-GSFilePath" 1 ns-handle-nxopen)
197 ;;("-bw" . x-handle-numeric-switch)
198 ;;("-d" . x-handle-display)
199 ;;("-display" . x-handle-display)
200 ("-name" 1 ns-handle-name-switch)
201 ("-title" 1 ns-handle-switch title)
202 ("-T" 1 ns-handle-switch title)
203 ("-r" 0 ns-handle-switch reverse t)
204 ("-rv" 0 ns-handle-switch reverse t)
205 ("-reverse" 0 ns-handle-switch reverse t)
206 ("-fn" 1 ns-handle-switch font)
207 ("-font" 1 ns-handle-switch font)
208 ("-ib" 1 ns-handle-numeric-switch internal-border-width)
209 ;;("-g" . x-handle-geometry)
210 ;;("-geometry" . x-handle-geometry)
211 ("-fg" 1 ns-handle-switch foreground-color)
212 ("-foreground" 1 ns-handle-switch foreground-color)
213 ("-bg" 1 ns-handle-switch background-color)
214 ("-background" 1 ns-handle-switch background-color)
215 ; ("-ms" 1 ns-handle-switch mouse-color)
216 ("-itype" 0 ns-handle-switch icon-type t)
217 ("-i" 0 ns-handle-switch icon-type t)
218 ("-iconic" 0 ns-handle-iconic icon-type t)
219 ;;("-xrm" . x-handle-xrm-switch)
220 ("-cr" 1 ns-handle-switch cursor-color)
221 ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
222 ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
223 ("-bd" 1 ns-handle-switch)
224 ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
225 ;; ("--display" 1 ns-handle-display)
226 ("--name" 1 ns-handle-name-switch)
227 ("--title" 1 ns-handle-switch title)
228 ("--reverse-video" 0 ns-handle-switch reverse t)
229 ("--font" 1 ns-handle-switch font)
230 ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
231 ;; ("--geometry" 1 ns-handle-geometry)
232 ("--foreground-color" 1 ns-handle-switch foreground-color)
233 ("--background-color" 1 ns-handle-switch background-color)
234 ("--mouse-color" 1 ns-handle-switch mouse-color)
235 ("--icon-type" 0 ns-handle-switch icon-type t)
236 ("--iconic" 0 ns-handle-iconic)
237 ;; ("--xrm" 1 ns-handle-xrm-switch)
238 ("--cursor-color" 1 ns-handle-switch cursor-color)
239 ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
240 ("--border-color" 1 ns-handle-switch border-width))
241 "Alist of NS options.
242 Each element has the form
243 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
244 where NAME is the option name string, NUMARGS is the number of arguments
245 that the option accepts, HANDLER is a function to call to handle the option.
246 FRAME-PARAM (optional) is the frame parameter this option specifies,
247 and VALUE is the value which is given to that frame parameter
248 \(most options use the argument for this, so VALUE is not present).")
249
250
251 (defvar before-init-hook nil
252 "Normal hook run after handling urgent options but before loading init files.")
253
254 (defvar after-init-hook nil
255 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
256 There is no `condition-case' around the running of these functions;
257 therefore, if you set `debug-on-error' non-nil in `.emacs',
258 an error in one of these functions will invoke the debugger.")
259
260 (defvar before-init-time nil
261 "Value of `current-time' before Emacs begins initialization.")
262
263 (defvar after-init-time nil
264 "Value of `current-time' after loading the init files.")
265
266 (defvar emacs-startup-hook nil
267 "Normal hook run after loading init files and handling the command line.")
268
269 (defvar term-setup-hook nil
270 "Normal hook run after loading terminal-specific Lisp code.
271 It also follows `emacs-startup-hook'. This hook exists for users to set,
272 so as to override the definitions made by the terminal-specific file.
273 Emacs never sets this variable itself.")
274
275 (defvar inhibit-startup-hooks nil
276 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
277 This is because we already did so.")
278
279 (defvar keyboard-type nil
280 "The brand of keyboard you are using.
281 This variable is used to define the proper function and keypad
282 keys for use under X. It is used in a fashion analogous to the
283 environment variable TERM.")
284
285 (defvar window-setup-hook nil
286 "Normal hook run to initialize window system display.
287 Emacs runs this hook after processing the command line arguments and loading
288 the user's init file.")
289
290 (defcustom initial-major-mode 'lisp-interaction-mode
291 "Major mode command symbol to use for the initial `*scratch*' buffer."
292 :type 'function
293 :group 'initialization)
294
295 (defvar init-file-user nil
296 "Identity of user whose `.emacs' file is or was read.
297 The value is nil if `-q' or `--no-init-file' was specified,
298 meaning do not load any init file.
299
300 Otherwise, the value may be an empty string, meaning
301 use the init file for the user who originally logged in,
302 or it may be a string containing a user's name meaning
303 use that person's init file.
304
305 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
306 evaluates to the name of the directory where the `.emacs' file was
307 looked for.
308
309 Setting `init-file-user' does not prevent Emacs from loading
310 `site-start.el'. The only way to do that is to use `--no-site-file'.")
311
312 (defcustom site-run-file "site-start"
313 "File containing site-wide run-time initializations.
314 This file is loaded at run-time before `~/.emacs'. It contains inits
315 that need to be in place for the entire site, but which, due to their
316 higher incidence of change, don't make sense to load into Emacs's
317 dumped image. Thus, the run-time load order is: 1. file described in
318 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
319
320 Don't use the `site-start.el' file for things some users may not like.
321 Put them in `default.el' instead, so that users can more easily
322 override them. Users can prevent loading `default.el' with the `-q'
323 option or by setting `inhibit-default-init' in their own init files,
324 but inhibiting `site-start.el' requires `--no-site-file', which
325 is less convenient.
326
327 This variable is defined for customization so as to make
328 it visible in the relevant context. However, actually customizing it
329 is not allowed, since it would not work anyway. The only way to set
330 this variable usefully is to set it while building and dumping Emacs."
331 :type '(choice (const :tag "none" nil) string)
332 :group 'initialization
333 :initialize 'custom-initialize-default
334 :set '(lambda (variable value)
335 (error "Customizing `site-run-file' does not work")))
336
337 (defcustom mail-host-address nil
338 "*Name of this machine, for purposes of naming users."
339 :type '(choice (const nil) string)
340 :group 'mail)
341
342 (defcustom user-mail-address (if command-line-processed
343 (or (getenv "EMAIL")
344 (concat (user-login-name) "@"
345 (or mail-host-address
346 (system-name))))
347 ;; Empty string means "not set yet".
348 "")
349 "*Full mailing address of this user.
350 This is initialized with environment variable `EMAIL' or, as a
351 fallback, using `mail-host-address'. This is done after your
352 init file is read, in case it sets `mail-host-address'."
353 :type 'string
354 :group 'mail)
355
356 (defcustom auto-save-list-file-prefix
357 (cond ((eq system-type 'ms-dos)
358 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
359 (concat user-emacs-directory "auto-save.list/_s"))
360 (t
361 (concat user-emacs-directory "auto-save-list/.saves-")))
362 "Prefix for generating `auto-save-list-file-name'.
363 This is used after reading your `.emacs' file to initialize
364 `auto-save-list-file-name', by appending Emacs's pid and the system name,
365 if you have not already set `auto-save-list-file-name' yourself.
366 Directories in the prefix will be created if necessary.
367 Set this to nil if you want to prevent `auto-save-list-file-name'
368 from being initialized."
369 :type '(choice (const :tag "Don't record a session's auto save list" nil)
370 string)
371 :group 'auto-save)
372
373 (defvar emacs-quick-startup nil)
374
375 (defvar emacs-basic-display nil)
376
377 (defvar init-file-debug nil)
378
379 (defvar init-file-had-error nil
380 "Non-nil if there was an error loading the user's init file.")
381
382 (defvar normal-top-level-add-subdirs-inode-list nil)
383
384 (defvar no-blinking-cursor nil)
385
386 (defvar default-frame-background-mode)
387
388 (defvar pure-space-overflow nil
389 "Non-nil if building Emacs overflowed pure space.")
390
391 (defvar pure-space-overflow-message "\
392 Warning Warning!!! Pure space overflow !!!Warning Warning
393 \(See the node Pure Storage in the Lisp manual for details.)\n")
394
395 (defvar tutorial-directory nil
396 "Directory containing the Emacs TUTORIAL files.")
397
398 ;; Get correct value in a dumped, installed Emacs.
399 (eval-at-startup
400 (setq tutorial-directory (file-name-as-directory
401 (expand-file-name "tutorials" data-directory))))
402
403 (defun normal-top-level-add-subdirs-to-load-path ()
404 "Add all subdirectories of current directory to `load-path'.
405 More precisely, this uses only the subdirectories whose names
406 start with letters or digits; it excludes any subdirectory named `RCS'
407 or `CVS', and any subdirectory that contains a file named `.nosearch'."
408 (let (dirs
409 attrs
410 (pending (list default-directory)))
411 ;; This loop does a breadth-first tree walk on DIR's subtree,
412 ;; putting each subdir into DIRS as its contents are examined.
413 (while pending
414 (push (pop pending) dirs)
415 (let* ((this-dir (car dirs))
416 (contents (directory-files this-dir))
417 (default-directory this-dir)
418 (canonicalized (if (fboundp 'untranslated-canonical-name)
419 (untranslated-canonical-name this-dir))))
420 ;; The Windows version doesn't report meaningful inode
421 ;; numbers, so use the canonicalized absolute file name of the
422 ;; directory instead.
423 (setq attrs (or canonicalized
424 (nthcdr 10 (file-attributes this-dir))))
425 (unless (member attrs normal-top-level-add-subdirs-inode-list)
426 (push attrs normal-top-level-add-subdirs-inode-list)
427 (dolist (file contents)
428 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
429 (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs"))
430 (when (and (string-match "\\`[[:alnum:]]" file)
431 ;; Avoid doing a `stat' when it isn't necessary
432 ;; because that can cause trouble when an NFS server
433 ;; is down.
434 (not (string-match "\\.elc?\\'" file))
435 (file-directory-p file))
436 (let ((expanded (expand-file-name file)))
437 (unless (file-exists-p (expand-file-name ".nosearch"
438 expanded))
439 (setq pending (nconc pending (list expanded)))))))))))
440 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
441
442 ;; This function is called from a subdirs.el file.
443 ;; It assumes that default-directory is the directory
444 ;; in which the subdirs.el file exists,
445 ;; and it adds to load-path the subdirs of that directory
446 ;; as specified in DIRS. Normally the elements of DIRS are relative.
447 (defun normal-top-level-add-to-load-path (dirs)
448 (let ((tail load-path)
449 (thisdir (directory-file-name default-directory)))
450 (while (and tail
451 ;;Don't go all the way to the nil terminator.
452 (cdr tail)
453 (not (equal thisdir (car tail)))
454 (not (and (memq system-type '(ms-dos windows-nt))
455 (equal (downcase thisdir) (downcase (car tail))))))
456 (setq tail (cdr tail)))
457 ;;Splice the new section in.
458 (when tail
459 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
460
461 (defun normal-top-level ()
462 (if command-line-processed
463 (message "Back to top level.")
464 (setq command-line-processed t)
465 (let ((dir default-directory))
466 (with-current-buffer "*Messages*"
467 ;; Make it easy to do like "tail -f".
468 (set (make-local-variable 'window-point-insertion-type) t)
469 ;; Give *Messages* the same default-directory as *scratch*,
470 ;; just to keep things predictable.
471 (setq default-directory dir)))
472 ;; `user-full-name' is now known; reset its standard-value here.
473 (put 'user-full-name 'standard-value
474 (list (default-value 'user-full-name)))
475 ;; For root, preserve owner and group when editing files.
476 (if (equal (user-uid) 0)
477 (setq backup-by-copying-when-mismatch t))
478 ;; Look in each dir in load-path for a subdirs.el file.
479 ;; If we find one, load it, which will add the appropriate subdirs
480 ;; of that dir into load-path,
481 ;; Look for a leim-list.el file too. Loading it will register
482 ;; available input methods.
483 (let ((tail load-path) dir)
484 (while tail
485 (setq dir (car tail))
486 (let ((default-directory dir))
487 (load (expand-file-name "subdirs.el") t t t))
488 (let ((default-directory dir))
489 (load (expand-file-name "leim-list.el") t t t))
490 ;; We don't use a dolist loop and we put this "setq-cdr" command at
491 ;; the end, because the subdirs.el files may add elements to the end
492 ;; of load-path and we want to take it into account.
493 (setq tail (cdr tail))))
494 (unless (eq system-type 'vax-vms)
495 ;; If the PWD environment variable isn't accurate, delete it.
496 (let ((pwd (getenv "PWD")))
497 (and (stringp pwd)
498 ;; Use FOO/., so that if FOO is a symlink, file-attributes
499 ;; describes the directory linked to, not FOO itself.
500 (or (equal (file-attributes
501 (concat (file-name-as-directory pwd) "."))
502 (file-attributes
503 (concat (file-name-as-directory default-directory)
504 ".")))
505 (setq process-environment
506 (delete (concat "PWD=" pwd)
507 process-environment))))))
508 (setq default-directory (abbreviate-file-name default-directory))
509 (let ((menubar-bindings-done nil))
510 (unwind-protect
511 (command-line)
512 ;; Do this again, in case .emacs defined more abbreviations.
513 (setq default-directory (abbreviate-file-name default-directory))
514 ;; Specify the file for recording all the auto save files of this session.
515 ;; This is used by recover-session.
516 (or auto-save-list-file-name
517 (and auto-save-list-file-prefix
518 (setq auto-save-list-file-name
519 ;; Under MS-DOS our PID is almost always reused between
520 ;; Emacs invocations. We need something more unique.
521 (cond ((eq system-type 'ms-dos)
522 ;; We are going to access the auto-save
523 ;; directory, so make sure it exists.
524 (make-directory
525 (file-name-directory auto-save-list-file-prefix)
526 t)
527 (concat
528 (make-temp-name
529 (expand-file-name
530 auto-save-list-file-prefix))
531 "~"))
532 (t
533 (expand-file-name
534 (format "%s%d-%s~"
535 auto-save-list-file-prefix
536 (emacs-pid)
537 (system-name))))))))
538 (unless inhibit-startup-hooks
539 (run-hooks 'emacs-startup-hook)
540 (and term-setup-hook
541 (run-hooks 'term-setup-hook)))
542
543 ;; Don't do this if we failed to create the initial frame,
544 ;; for instance due to a dense colormap.
545 (when (or frame-initial-frame
546 ;; If frame-initial-frame has no meaning, do this anyway.
547 (not (and initial-window-system
548 (not noninteractive)
549 (not (eq initial-window-system 'pc)))))
550 ;; Modify the initial frame based on what .emacs puts into
551 ;; ...-frame-alist.
552 (if (fboundp 'frame-notice-user-settings)
553 (frame-notice-user-settings))
554 ;; Set the faces for the initial background mode even if
555 ;; frame-notice-user-settings didn't (such as on a tty).
556 ;; frame-set-background-mode is idempotent, so it won't
557 ;; cause any harm if it's already been done.
558 (if (fboundp 'frame-set-background-mode)
559 (frame-set-background-mode (selected-frame))))
560
561 ;; Now we know the user's default font, so add it to the menu.
562 (if (fboundp 'font-menu-add-default)
563 (font-menu-add-default))
564 (and window-setup-hook
565 (run-hooks 'window-setup-hook))
566 (or menubar-bindings-done
567 (if (display-popup-menus-p)
568 (precompute-menubar-bindings)))))
569 ;; Subprocesses of Emacs do not have direct access to the terminal, so
570 ;; unless told otherwise they should only assume a dumb terminal.
571 ;; We are careful to do it late (after term-setup-hook), although the
572 ;; new multi-tty code does not use $TERM any more there anyway.
573 (setenv "TERM" "dumb")
574 ;; Remove DISPLAY from the process-environment as well. This allows
575 ;; `callproc.c' to give it a useful adaptive default which is either
576 ;; the value of the `display' frame-parameter or the DISPLAY value
577 ;; from initial-environment.
578 (let ((display (frame-parameter nil 'display)))
579 ;; Be careful which DISPLAY to remove from process-environment: follow
580 ;; the logic of `callproc.c'.
581 (if (stringp display) (setq display (concat "DISPLAY=" display))
582 (dolist (varval initial-environment)
583 (if (string-match "\\`DISPLAY=" varval)
584 (setq display varval))))
585 (when display
586 (delete display process-environment)))))
587
588 ;; Precompute the keyboard equivalents in the menu bar items.
589 (defun precompute-menubar-bindings ()
590 (let ((submap (lookup-key global-map [menu-bar])))
591 (while submap
592 (and (consp (car submap))
593 (symbolp (car (car submap)))
594 (stringp (car-safe (cdr (car submap))))
595 (keymapp (cdr (cdr (car submap))))
596 (progn
597 (x-popup-menu nil (cdr (cdr (car submap))))
598 (if purify-flag
599 (garbage-collect))))
600 (setq submap (cdr submap))))
601 (setq define-key-rebound-commands t))
602
603 ;; Command-line options supported by tty's:
604 (defconst tty-long-option-alist
605 '(("--name" . "-name")
606 ("--title" . "-T")
607 ("--reverse-video" . "-reverse")
608 ("--foreground-color" . "-fg")
609 ("--background-color" . "-bg")
610 ("--color" . "-color")))
611
612 (defconst tool-bar-images-pixel-height 24
613 "Height in pixels of images in the tool bar.")
614
615 (defvar tool-bar-originally-present nil
616 "Non-nil if tool-bars are present before user and site init files are read.")
617
618 (defvar handle-args-function-alist '((nil . tty-handle-args))
619 "Functions for processing window-system dependent command-line arguments.
620 Window system startup files should add their own function to this
621 alist, which should parse the command line arguments. Those
622 pertaining to the window system should be processed and removed
623 from the returned command line.")
624
625 (defvar window-system-initialization-alist '((nil . ignore))
626 "Alist of window-system initialization functions.
627 Window-system startup files should add their own initialization
628 function to this list. The function should take no arguments,
629 and initialize the window system environment to prepare for
630 opening the first frame (e.g. open a connection to an X server).")
631
632 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
633 (defun tty-handle-args (args)
634 (let (rest)
635 (message "%S" args)
636 (while (and args
637 (not (equal (car args) "--")))
638 (let* ((argi (pop args))
639 (orig-argi argi)
640 argval completion)
641 ;; Check for long options with attached arguments
642 ;; and separate out the attached option argument into argval.
643 (when (string-match "^\\(--[^=]*\\)=" argi)
644 (setq argval (substring argi (match-end 0))
645 argi (match-string 1 argi)))
646 (when (string-match "^--" argi)
647 (setq completion (try-completion argi tty-long-option-alist))
648 (if (eq completion t)
649 ;; Exact match for long option.
650 (setq argi (cdr (assoc argi tty-long-option-alist)))
651 (if (stringp completion)
652 (let ((elt (assoc completion tty-long-option-alist)))
653 ;; Check for abbreviated long option.
654 (or elt
655 (error "Option `%s' is ambiguous" argi))
656 (setq argi (cdr elt)))
657 ;; Check for a short option.
658 (setq argval nil
659 argi orig-argi))))
660 (cond ((member argi '("-fg" "-foreground"))
661 (push (cons 'foreground-color (or argval (pop args)))
662 default-frame-alist))
663 ((member argi '("-bg" "-background"))
664 (push (cons 'background-color (or argval (pop args)))
665 default-frame-alist))
666 ((member argi '("-T" "-name"))
667 (unless argval (setq argval (pop args)))
668 (push (cons 'title
669 (if (stringp argval)
670 argval
671 (let ((case-fold-search t)
672 i)
673 (setq argval (invocation-name))
674
675 ;; Change any . or * characters in name to
676 ;; hyphens, so as to emulate behavior on X.
677 (while
678 (setq i (string-match "[.*]" argval))
679 (aset argval i ?-))
680 argval)))
681 default-frame-alist))
682 ((member argi '("-r" "-rv" "-reverse"))
683 (push '(reverse . t)
684 default-frame-alist))
685 ((equal argi "-color")
686 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
687 (push (cons 'tty-color-mode
688 (cond
689 ((numberp argval) argval)
690 ((string-match "-?[0-9]+" argval)
691 (string-to-number argval))
692 (t (intern argval))))
693 default-frame-alist))
694 (t
695 (push argi rest)))))
696 (nreverse rest)))
697
698 (declare-function x-get-resource "frame.c"
699 (attribute class &optional component subclass))
700 (declare-function tool-bar-mode "tool-bar" (&optional arg))
701
702 (defun command-line ()
703 (setq before-init-time (current-time)
704 command-line-default-directory default-directory)
705
706 ;; Choose a reasonable location for temporary files.
707 (custom-reevaluate-setting 'temporary-file-directory)
708 (custom-reevaluate-setting 'small-temporary-file-directory)
709 (custom-reevaluate-setting 'auto-save-file-name-transforms)
710
711 ;; See if we should import version-control from the environment variable.
712 (let ((vc (getenv "VERSION_CONTROL")))
713 (cond ((eq vc nil)) ;don't do anything if not set
714 ((member vc '("t" "numbered"))
715 (setq version-control t))
716 ((member vc '("nil" "existing"))
717 (setq version-control nil))
718 ((member vc '("never" "simple"))
719 (setq version-control 'never))))
720
721 ;;! This has been commented out; I currently find the behavior when
722 ;;! split-window-keep-point is nil disturbing, but if I can get used
723 ;;! to it, then it would be better to eliminate the option.
724 ;;! ;; Choose a good default value for split-window-keep-point.
725 ;;! (setq split-window-keep-point (> baud-rate 2400))
726
727 ;; Set the default strings to display in mode line for
728 ;; end-of-line formats that aren't native to this platform.
729 (cond
730 ((memq system-type '(ms-dos windows-nt emx))
731 (setq eol-mnemonic-unix "(Unix)"
732 eol-mnemonic-mac "(Mac)"))
733 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
734 ;; abbreviated strings `/' and `:' set in coding.c for them.
735 ((eq system-type 'macos)
736 (setq eol-mnemonic-dos "(DOS)"))
737 (t ; this is for Unix/GNU/Linux systems
738 (setq eol-mnemonic-dos "(DOS)"
739 eol-mnemonic-mac "(Mac)")))
740
741 ;; Make sure window system's init file was loaded in loadup.el if using a window system.
742 (condition-case error
743 (unless noninteractive
744 (if (and initial-window-system
745 (not (featurep
746 (intern (concat (symbol-name initial-window-system) "-win")))))
747 (error "Unsupported window system `%s'" initial-window-system))
748 ;; Process window-system specific command line parameters.
749 (setq command-line-args
750 (funcall (or (cdr (assq initial-window-system handle-args-function-alist))
751 (error "Unsupported window system `%s'" initial-window-system))
752 command-line-args))
753 ;; Initialize the window system. (Open connection, etc.)
754 (funcall (or (cdr (assq initial-window-system window-system-initialization-alist))
755 (error "Unsupported window system `%s'" initial-window-system))))
756 ;; If there was an error, print the error message and exit.
757 (error
758 (princ
759 (if (eq (car error) 'error)
760 (apply 'concat (cdr error))
761 (if (memq 'file-error (get (car error) 'error-conditions))
762 (format "%s: %s"
763 (nth 1 error)
764 (mapconcat (lambda (obj) (prin1-to-string obj t))
765 (cdr (cdr error)) ", "))
766 (format "%s: %s"
767 (get (car error) 'error-message)
768 (mapconcat (lambda (obj) (prin1-to-string obj t))
769 (cdr error) ", "))))
770 'external-debugging-output)
771 (terpri 'external-debugging-output)
772 (setq initial-window-system nil)
773 (kill-emacs)))
774
775 (set-locale-environment nil)
776
777 ;; Convert preloaded file names in load-history to absolute.
778 (let ((simple-file-name
779 ;; Look for simple.el or simple.elc and use their directory
780 ;; as the place where all Lisp files live.
781 (locate-file "simple" load-path (get-load-suffixes)))
782 lisp-dir)
783 ;; Don't abort if simple.el cannot be found, but print a warning.
784 (if (null simple-file-name)
785 (progn
786 (princ "Warning: Could not find simple.el nor simple.elc"
787 'external-debugging-output)
788 (terpri 'external-debugging-output))
789 (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
790 (setq load-history
791 (mapcar (lambda (elt)
792 (if (and (stringp (car elt))
793 (not (file-name-absolute-p (car elt))))
794 (cons (concat lisp-dir
795 (car elt))
796 (cdr elt))
797 elt))
798 load-history))))
799
800 ;; Convert the arguments to Emacs internal representation.
801 (let ((args (cdr command-line-args)))
802 (while args
803 (setcar args
804 (decode-coding-string (car args) locale-coding-system t))
805 (pop args)))
806
807 (let ((done nil)
808 (args (cdr command-line-args)))
809
810 ;; Figure out which user's init file to load,
811 ;; either from the environment or from the options.
812 (setq init-file-user (if noninteractive nil (user-login-name)))
813 ;; If user has not done su, use current $HOME to find .emacs.
814 (and init-file-user
815 (equal init-file-user (user-real-login-name))
816 (setq init-file-user ""))
817
818 ;; Process the command-line args, and delete the arguments
819 ;; processed. This is consistent with the way main in emacs.c
820 ;; does things.
821 (while (and (not done) args)
822 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
823 ("--user") ("--iconic") ("--icon-type") ("--quick")
824 ("--no-blinking-cursor") ("--basic-display")))
825 (argi (pop args))
826 (orig-argi argi)
827 argval)
828 ;; Handle --OPTION=VALUE format.
829 (when (string-match "^\\(--[^=]*\\)=" argi)
830 (setq argval (substring argi (match-end 0))
831 argi (match-string 1 argi)))
832 (unless (equal argi "--")
833 (let ((completion (try-completion argi longopts)))
834 (if (eq completion t)
835 (setq argi (substring argi 1))
836 (if (stringp completion)
837 (let ((elt (assoc completion longopts)))
838 (or elt
839 (error "Option `%s' is ambiguous" argi))
840 (setq argi (substring (car elt) 1)))
841 (setq argval nil
842 argi orig-argi)))))
843 (cond
844 ((member argi '("-Q" "-quick"))
845 (setq init-file-user nil
846 site-run-file nil
847 emacs-quick-startup t))
848 ((member argi '("-D" "-basic-display"))
849 (setq no-blinking-cursor t
850 emacs-basic-display t)
851 (push '(vertical-scroll-bars . nil) initial-frame-alist))
852 ((member argi '("-q" "-no-init-file"))
853 (setq init-file-user nil))
854 ((member argi '("-u" "-user"))
855 (setq init-file-user (or argval (pop args))
856 argval nil))
857 ((equal argi "-no-site-file")
858 (setq site-run-file nil))
859 ((equal argi "-debug-init")
860 (setq init-file-debug t))
861 ((equal argi "-iconic")
862 (push '(visibility . icon) initial-frame-alist))
863 ((member argi '("-icon-type" "-i" "-itype"))
864 (push '(icon-type . t) default-frame-alist))
865 ((member argi '("-nbc" "-no-blinking-cursor"))
866 (setq no-blinking-cursor t))
867 ;; Push the popped arg back on the list of arguments.
868 (t
869 (push argi args)
870 (setq done t)))
871 ;; Was argval set but not used?
872 (and argval
873 (error "Option `%s' doesn't allow an argument" argi))))
874
875 ;; Re-attach the program name to the front of the arg list.
876 (and command-line-args
877 (setcdr command-line-args args)))
878
879 (run-hooks 'before-init-hook)
880
881 ;; Under X Window, this creates the X frame and deletes the terminal frame.
882 (when (fboundp 'frame-initialize)
883 (frame-initialize))
884
885 ;; Turn off blinking cursor if so specified in X resources. This is here
886 ;; only because all other settings of no-blinking-cursor are here.
887 (unless (or noninteractive
888 emacs-basic-display
889 (and (memq window-system '(x w32 mac ns))
890 (not (member (x-get-resource "cursorBlink" "CursorBlink")
891 '("off" "false")))))
892 (setq no-blinking-cursor t))
893
894 ;; If frame was created with a menu bar, set menu-bar-mode on.
895 (unless (or noninteractive
896 emacs-basic-display
897 (and (memq initial-window-system '(x w32))
898 (<= (frame-parameter nil 'menu-bar-lines) 0)))
899 (menu-bar-mode 1))
900
901 ;; If frame was created with a tool bar, switch tool-bar-mode on.
902 (unless (or noninteractive
903 emacs-basic-display
904 (not (display-graphic-p))
905 (<= (frame-parameter nil 'tool-bar-lines) 0))
906 (tool-bar-mode 1))
907
908 ;; Can't do this init in defcustom because the relevant variables
909 ;; are not set.
910 (custom-reevaluate-setting 'blink-cursor-mode)
911 (custom-reevaluate-setting 'tooltip-mode)
912 (custom-reevaluate-setting 'global-font-lock-mode)
913 (custom-reevaluate-setting 'mouse-wheel-down-event)
914 (custom-reevaluate-setting 'mouse-wheel-up-event)
915 (custom-reevaluate-setting 'file-name-shadow-mode)
916 (custom-reevaluate-setting 'send-mail-function)
917 (custom-reevaluate-setting 'focus-follows-mouse)
918 (custom-reevaluate-setting 'global-auto-composition-mode)
919 (custom-reevaluate-setting 'transient-mark-mode)
920 (custom-reevaluate-setting 'auto-encryption-mode)
921
922 (normal-erase-is-backspace-setup-frame)
923
924 ;; Register default TTY colors for the case the terminal hasn't a
925 ;; terminal init file. We do this regardles of whether the terminal
926 ;; supports colors or not and regardless the current display type,
927 ;; since users can connect to color-capable terminals and also
928 ;; switch color support on or off in mid-session by setting the
929 ;; tty-color-mode frame parameter.
930 (tty-register-default-colors)
931
932 ;; Record whether the tool-bar is present before the user and site
933 ;; init files are processed. frame-notice-user-settings uses this
934 ;; to determine if the tool-bar has been disabled by the init files,
935 ;; and the frame needs to be resized.
936 (when (fboundp 'frame-notice-user-settings)
937 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
938 (assq 'tool-bar-lines default-frame-alist))))
939 (setq tool-bar-originally-present
940 (and tool-bar-lines
941 (cdr tool-bar-lines)
942 (not (eq 0 (cdr tool-bar-lines)))))))
943
944 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
945 (old-font-list-limit font-list-limit)
946 (old-face-ignored-fonts face-ignored-fonts))
947
948 ;; Run the site-start library if it exists. The point of this file is
949 ;; that it is run before .emacs. There is no point in doing this after
950 ;; .emacs; that is useless.
951 ;; Note that user-init-file is nil at this point. Code that might
952 ;; be loaded from site-run-file and wants to test if -q was given
953 ;; should check init-file-user instead, since that is already set.
954 ;; See cus-edit.el for an example.
955 (if site-run-file
956 (load site-run-file t t))
957
958 ;; Sites should not disable this. Only individuals should disable
959 ;; the startup screen.
960 (setq inhibit-startup-screen nil)
961
962 ;; Warn for invalid user name.
963 (when init-file-user
964 (if (string-match "[~/:\n]" init-file-user)
965 (display-warning 'initialization
966 (format "Invalid user name %s"
967 init-file-user)
968 :error)
969 (if (file-directory-p (expand-file-name
970 ;; We don't support ~USER on MS-Windows except
971 ;; for the current user, and always load .emacs
972 ;; from the current user's home directory (see
973 ;; below). So always check "~", even if invoked
974 ;; with "-u USER", or if $USER or $LOGNAME are
975 ;; set to something different.
976 (if (eq system-type 'windows-nt)
977 "~"
978 (concat "~" init-file-user))))
979 nil
980 (display-warning 'initialization
981 (format "User %s has no home directory"
982 init-file-user)
983 :error))))
984
985 ;; Load that user's init file, or the default one, or none.
986 (let (debug-on-error-from-init-file
987 debug-on-error-should-be-set
988 (debug-on-error-initial
989 (if (eq init-file-debug t) 'startup init-file-debug))
990 (orig-enable-multibyte default-enable-multibyte-characters))
991 (let ((debug-on-error debug-on-error-initial)
992 ;; This function actually reads the init files.
993 (inner
994 (function
995 (lambda ()
996 (if init-file-user
997 (let ((user-init-file-1
998 (cond
999 ((eq system-type 'ms-dos)
1000 (concat "~" init-file-user "/_emacs"))
1001 ((eq system-type 'windows-nt)
1002 ;; Prefer .emacs on Windows.
1003 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
1004 "~/.emacs"
1005 ;; Also support _emacs for compatibility.
1006 (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
1007 "~/_emacs"
1008 ;; But default to .emacs if _emacs does not exist.
1009 "~/.emacs")))
1010 ((eq system-type 'vax-vms)
1011 "sys$login:.emacs")
1012 (t
1013 (concat "~" init-file-user "/.emacs")))))
1014 ;; This tells `load' to store the file name found
1015 ;; into user-init-file.
1016 (setq user-init-file t)
1017 (load user-init-file-1 t t)
1018
1019 (when (eq user-init-file t)
1020 ;; If we did not find ~/.emacs, try
1021 ;; ~/.emacs.d/init.el.
1022 (let ((otherfile
1023 (expand-file-name
1024 "init"
1025 (file-name-as-directory
1026 (concat "~" init-file-user "/.emacs.d")))))
1027 (load otherfile t t)
1028
1029 ;; If we did not find the user's init file,
1030 ;; set user-init-file conclusively.
1031 ;; Don't let it be set from default.el.
1032 (when (eq user-init-file t)
1033 (setq user-init-file user-init-file-1))))
1034
1035 ;; If we loaded a compiled file, set
1036 ;; `user-init-file' to the source version if that
1037 ;; exists.
1038 (when (and user-init-file
1039 (equal (file-name-extension user-init-file)
1040 "elc"))
1041 (let* ((source (file-name-sans-extension user-init-file))
1042 (alt (concat source ".el")))
1043 (setq source (cond ((file-exists-p alt) alt)
1044 ((file-exists-p source) source)
1045 (t nil)))
1046 (when source
1047 (when (file-newer-than-file-p source user-init-file)
1048 (message "Warning: %s is newer than %s"
1049 source user-init-file)
1050 (sit-for 1))
1051 (setq user-init-file source))))
1052
1053 (unless inhibit-default-init
1054 (let ((inhibit-startup-screen nil))
1055 ;; Users are supposed to be told their rights.
1056 ;; (Plus how to get help and how to undo.)
1057 ;; Don't you dare turn this off for anyone
1058 ;; except yourself.
1059 (load "default" t t)))))))))
1060 (if init-file-debug
1061 ;; Do this without a condition-case if the user wants to debug.
1062 (funcall inner)
1063 (condition-case error
1064 (progn
1065 (funcall inner)
1066 (setq init-file-had-error nil))
1067 (error
1068 (let ((message-log-max nil))
1069 (with-current-buffer (get-buffer-create "*Messages*")
1070 (insert "\n\n"
1071 (format "An error has occurred while loading `%s':\n\n"
1072 user-init-file)
1073 (format "%s%s%s"
1074 (get (car error) 'error-message)
1075 (if (cdr error) ": " "")
1076 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
1077 "\n\n"
1078 "To ensure normal operation, you should investigate and remove the\n"
1079 "cause of the error in your initialization file. Start Emacs with\n"
1080 "the `--debug-init' option to view a complete error backtrace.\n\n"))
1081 (message "Error in init file: %s%s%s"
1082 (get (car error) 'error-message)
1083 (if (cdr error) ": " "")
1084 (mapconcat 'prin1-to-string (cdr error) ", "))
1085 (let ((pop-up-windows nil))
1086 (pop-to-buffer "*Messages*"))
1087 (setq init-file-had-error t)))))
1088
1089 (if (and deactivate-mark transient-mark-mode)
1090 (with-current-buffer (window-buffer)
1091 (deactivate-mark)))
1092
1093 ;; If the user has a file of abbrevs, read it (unless -batch).
1094 (when (and (not noninteractive)
1095 (file-exists-p abbrev-file-name)
1096 (file-readable-p abbrev-file-name))
1097 (quietly-read-abbrev-file abbrev-file-name))
1098
1099 ;; If the abbrevs came entirely from the init file or the
1100 ;; abbrevs file, they do not need saving.
1101 (setq abbrevs-changed nil)
1102
1103 ;; If we can tell that the init file altered debug-on-error,
1104 ;; arrange to preserve the value that it set up.
1105 (or (eq debug-on-error debug-on-error-initial)
1106 (setq debug-on-error-should-be-set t
1107 debug-on-error-from-init-file debug-on-error)))
1108 (if debug-on-error-should-be-set
1109 (setq debug-on-error debug-on-error-from-init-file))
1110 (unless (or default-enable-multibyte-characters
1111 (eq orig-enable-multibyte default-enable-multibyte-characters))
1112 ;; Init file changed to unibyte. Reset existing multibyte
1113 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1114 ;; Arguably this should only be done if they're free of
1115 ;; multibyte characters.
1116 (mapc (lambda (buffer)
1117 (with-current-buffer buffer
1118 (if enable-multibyte-characters
1119 (set-buffer-multibyte nil))))
1120 (buffer-list))
1121 ;; Also re-set the language environment in case it was
1122 ;; originally done before unibyte was set and is sensitive to
1123 ;; unibyte (display table, terminal coding system &c).
1124 (set-language-environment current-language-environment)))
1125
1126 ;; Do this here in case the init file sets mail-host-address.
1127 (if (equal user-mail-address "")
1128 (setq user-mail-address (or (getenv "EMAIL")
1129 (concat (user-login-name) "@"
1130 (or mail-host-address
1131 (system-name))))))
1132
1133 ;; Originally face attributes were specified via
1134 ;; `font-lock-face-attributes'. Users then changed the default
1135 ;; face attributes by setting that variable. However, we try and
1136 ;; be back-compatible and respect its value if set except for
1137 ;; faces where M-x customize has been used to save changes for the
1138 ;; face.
1139 (when (boundp 'font-lock-face-attributes)
1140 (let ((face-attributes font-lock-face-attributes))
1141 (while face-attributes
1142 (let* ((face-attribute (pop face-attributes))
1143 (face (car face-attribute)))
1144 ;; Rustle up a `defface' SPEC from a
1145 ;; `font-lock-face-attributes' entry.
1146 (unless (get face 'saved-face)
1147 (let ((foreground (nth 1 face-attribute))
1148 (background (nth 2 face-attribute))
1149 (bold-p (nth 3 face-attribute))
1150 (italic-p (nth 4 face-attribute))
1151 (underline-p (nth 5 face-attribute))
1152 face-spec)
1153 (when foreground
1154 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1155 (when background
1156 (setq face-spec (cons ':background (cons background face-spec))))
1157 (when bold-p
1158 (setq face-spec (append '(:weight bold) face-spec)))
1159 (when italic-p
1160 (setq face-spec (append '(:slant italic) face-spec)))
1161 (when underline-p
1162 (setq face-spec (append '(:underline t) face-spec)))
1163 (face-spec-set face (list (list t face-spec)) nil)))))))
1164
1165 ;; If parameter have been changed in the init file which influence
1166 ;; face realization, clear the face cache so that new faces will
1167 ;; be realized.
1168 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1169 (eq font-list-limit old-font-list-limit)
1170 (eq face-ignored-fonts old-face-ignored-fonts))
1171 (clear-face-cache)))
1172
1173 (setq after-init-time (current-time))
1174 (run-hooks 'after-init-hook)
1175
1176 ;; Decode all default-directory.
1177 (if (and default-enable-multibyte-characters locale-coding-system)
1178 (save-excursion
1179 (dolist (elt (buffer-list))
1180 (set-buffer elt)
1181 (if default-directory
1182 (setq default-directory
1183 (decode-coding-string default-directory
1184 locale-coding-system t))))
1185 (setq command-line-default-directory
1186 (decode-coding-string command-line-default-directory
1187 locale-coding-system t))))
1188
1189 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1190 (if (get-buffer "*scratch*")
1191 (with-current-buffer "*scratch*"
1192 (if (eq major-mode 'fundamental-mode)
1193 (funcall initial-major-mode))))
1194
1195 ;; Load library for our terminal type.
1196 ;; User init file can set term-file-prefix to nil to prevent this.
1197 (unless (or noninteractive
1198 initial-window-system)
1199 (tty-run-terminal-initialization (selected-frame)))
1200
1201 ;; Update the out-of-memory error message based on user's key bindings
1202 ;; for save-some-buffers.
1203 (setq memory-signal-data
1204 (list 'error
1205 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1206
1207 ;; Process the remaining args.
1208 (command-line-1 (cdr command-line-args))
1209
1210 ;; If -batch, terminate after processing the command options.
1211 (if noninteractive (kill-emacs t))
1212
1213 ;; Run emacs-session-restore (session management) if started by
1214 ;; the session manager and we have a session manager connection.
1215 (if (and (boundp 'x-session-previous-id)
1216 (stringp x-session-previous-id))
1217 (with-no-warnings
1218 (emacs-session-restore x-session-previous-id))))
1219
1220 (defcustom initial-scratch-message (purecopy "\
1221 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1222 ;; If you want to create a file, visit that file with C-x C-f,
1223 ;; then enter the text in that file's own buffer.
1224
1225 ")
1226 "Initial message displayed in *scratch* buffer at startup.
1227 If this is nil, no message will be displayed."
1228 :type '(choice (text :tag "Message")
1229 (const :tag "none" nil))
1230 :group 'initialization)
1231
1232 \f
1233 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1234 ;;; Fancy splash screen
1235 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1236
1237 (defvar fancy-startup-text
1238 '((:face (variable-pitch (:foreground "red"))
1239 "Welcome to "
1240 :link ("GNU Emacs"
1241 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/"))
1242 "Browse http://www.gnu.org/software/emacs/")
1243 ", one component of the "
1244 :link
1245 (lambda ()
1246 (if (eq system-type 'gnu/linux)
1247 '("GNU/Linux"
1248 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1249 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1250 '("GNU" (lambda (button) (describe-gnu-project))
1251 "Display info on the GNU project")))
1252 " operating system.\n"
1253 :face variable-pitch "To quit a partially entered command, type "
1254 :face default "Control-g"
1255 :face variable-pitch ".\n\n"
1256 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1257 "\tLearn basic keystroke commands"
1258 (lambda ()
1259 (let* ((en "TUTORIAL")
1260 (tut (or (get-language-info current-language-environment
1261 'tutorial)
1262 en))
1263 (title (with-temp-buffer
1264 (insert-file-contents
1265 (expand-file-name tut tutorial-directory)
1266 nil 0 256)
1267 (search-forward ".")
1268 (buffer-substring (point-min) (1- (point))))))
1269 ;; If there is a specific tutorial for the current language
1270 ;; environment and it is not English, append its title.
1271 (if (string= en tut)
1272 ""
1273 (concat " (" title ")"))))
1274 "\n"
1275 :face variable-pitch
1276 :link ("Emacs Guided Tour"
1277 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
1278 "Browse http://www.gnu.org/software/emacs/tour/")
1279 "\tOverview of Emacs features\n"
1280 :link ("View Emacs Manual" (lambda (button) (info-emacs-manual)))
1281 "\tView the Emacs manual using Info\n"
1282 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1283 "\tGNU Emacs comes with "
1284 :face (variable-pitch (:slant oblique))
1285 "ABSOLUTELY NO WARRANTY\n"
1286 :face variable-pitch
1287 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1288 "\tConditions for redistributing and changing Emacs\n"
1289 :link ("Ordering Manuals" (lambda (button) (view-order-manuals)))
1290 "\tPurchasing printed copies of manuals\n"
1291 "\n"))
1292 "A list of texts to show in the middle part of splash screens.
1293 Each element in the list should be a list of strings or pairs
1294 `:face FACE', like `fancy-splash-insert' accepts them.")
1295
1296 (defvar fancy-about-text
1297 '((:face (variable-pitch (:foreground "red"))
1298 "This is "
1299 :link ("GNU Emacs"
1300 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/"))
1301 "Browse http://www.gnu.org/software/emacs/")
1302 ", one component of the "
1303 :link
1304 (lambda ()
1305 (if (eq system-type 'gnu/linux)
1306 '("GNU/Linux"
1307 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1308 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1309 '("GNU" (lambda (button) (describe-gnu-project))
1310 "Display info on the GNU project.")))
1311 " operating system.\n"
1312 :face (lambda ()
1313 (list 'variable-pitch
1314 (list :foreground
1315 (if (eq (frame-parameter nil 'background-mode) 'dark)
1316 "cyan" "darkblue"))))
1317 "\n"
1318 (lambda () (emacs-version))
1319 "\n"
1320 :face (variable-pitch (:height 0.8))
1321 (lambda () emacs-copyright)
1322 "\n\n"
1323 :face variable-pitch
1324 :link ("Authors"
1325 (lambda (button)
1326 (view-file (expand-file-name "AUTHORS" data-directory))
1327 (goto-char (point-min))))
1328 "\tMany people have contributed code included in GNU Emacs\n"
1329 :link ("Contributing"
1330 (lambda (button)
1331 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1332 (goto-char (point-min))))
1333 "\tHow to contribute improvements to Emacs\n"
1334 "\n"
1335 :link ("GNU and Freedom" (lambda (button) (describe-gnu-project)))
1336 "\tWhy we developed GNU Emacs, and the GNU operating system\n"
1337 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1338 "\tGNU Emacs comes with "
1339 :face (variable-pitch (:slant oblique))
1340 "ABSOLUTELY NO WARRANTY\n"
1341 :face variable-pitch
1342 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1343 "\tConditions for redistributing and changing Emacs\n"
1344 :link ("Getting New Versions" (lambda (button) (describe-distribution)))
1345 "\tHow to obtain the latest version of Emacs\n"
1346 :link ("Ordering Manuals" (lambda (button) (view-order-manuals)))
1347 "\tBuying printed manuals from the FSF\n"
1348 "\n"
1349 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1350 "\tLearn basic Emacs keystroke commands"
1351 (lambda ()
1352 (let* ((en "TUTORIAL")
1353 (tut (or (get-language-info current-language-environment
1354 'tutorial)
1355 en))
1356 (title (with-temp-buffer
1357 (insert-file-contents
1358 (expand-file-name tut tutorial-directory)
1359 nil 0 256)
1360 (search-forward ".")
1361 (buffer-substring (point-min) (1- (point))))))
1362 ;; If there is a specific tutorial for the current language
1363 ;; environment and it is not English, append its title.
1364 (if (string= en tut)
1365 ""
1366 (concat " (" title ")"))))
1367 "\n"
1368 :link ("Emacs Guided Tour"
1369 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
1370 "Browse http://www.gnu.org/software/emacs/tour/")
1371 "\tSee an overview of the many facilities of GNU Emacs"
1372 ))
1373 "A list of texts to show in the middle part of the About screen.
1374 Each element in the list should be a list of strings or pairs
1375 `:face FACE', like `fancy-splash-insert' accepts them.")
1376
1377
1378 (defgroup fancy-splash-screen ()
1379 "Fancy splash screen when Emacs starts."
1380 :version "21.1"
1381 :group 'initialization)
1382
1383 (defcustom fancy-splash-image nil
1384 "*The image to show in the splash screens, or nil for defaults."
1385 :group 'fancy-splash-screen
1386 :type '(choice (const :tag "Default" nil)
1387 (file :tag "File")))
1388
1389
1390 (defvar splash-screen-keymap
1391 (let ((map (make-sparse-keymap)))
1392 (suppress-keymap map)
1393 (set-keymap-parent map button-buffer-map)
1394 (define-key map "\C-?" 'scroll-down)
1395 (define-key map " " 'scroll-up)
1396 (define-key map "q" 'exit-splash-screen)
1397 map)
1398 "Keymap for splash screen buffer.")
1399
1400 ;; These are temporary storage areas for the splash screen display.
1401
1402 (defun fancy-splash-insert (&rest args)
1403 "Insert text into the current buffer, with faces.
1404 Arguments from ARGS should be either strings; functions called
1405 with no args that return a string; pairs `:face FACE', where FACE
1406 is a face specification usable with `put-text-property'; or pairs
1407 `:link LINK' where LINK is a list of arguments to pass to
1408 `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which
1409 specifies the button's label, `action' property and help-echo string.
1410 FACE and LINK can also be functions, which are evaluated to obtain
1411 a face or button specification."
1412 (let ((current-face nil))
1413 (while args
1414 (cond ((eq (car args) :face)
1415 (setq args (cdr args) current-face (car args))
1416 (if (functionp current-face)
1417 (setq current-face (funcall current-face))))
1418 ((eq (car args) :link)
1419 (setq args (cdr args))
1420 (let ((spec (car args)))
1421 (if (functionp spec)
1422 (setq spec (funcall spec)))
1423 (insert-button (car spec)
1424 'face (list 'link current-face)
1425 'action (cadr spec)
1426 'help-echo (concat "mouse-2, RET: "
1427 (or (nth 2 spec)
1428 "Follow this link"))
1429 'follow-link t)))
1430 (t (insert (propertize (let ((it (car args)))
1431 (if (functionp it)
1432 (funcall it)
1433 it))
1434 'face current-face
1435 'help-echo (startup-echo-area-message)))))
1436 (setq args (cdr args)))))
1437
1438 (declare-function image-size "image.c" (spec &optional pixels frame))
1439
1440 (defun fancy-splash-head ()
1441 "Insert the head part of the splash screen into the current buffer."
1442 (let* ((image-file (cond ((stringp fancy-splash-image)
1443 fancy-splash-image)
1444 ((display-color-p)
1445 (cond ((image-type-available-p 'svg)
1446 "splash.svg")
1447 ((image-type-available-p 'png)
1448 "splash.png")
1449 ((image-type-available-p 'xpm)
1450 (if (and (fboundp 'x-display-planes)
1451 (= (funcall 'x-display-planes) 8))
1452 "splash8.xpm"
1453 "splash.xpm"))))
1454 (t "splash.pbm")))
1455 (img (create-image image-file))
1456 (image-width (and img (car (image-size img))))
1457 (window-width (window-width (selected-window))))
1458 (when img
1459 (when (> window-width image-width)
1460 ;; Center the image in the window.
1461 (insert (propertize " " 'display
1462 `(space :align-to (+ center (-0.5 . ,img)))))
1463
1464 ;; Change the color of the XPM version of the splash image
1465 ;; so that it is visible with a dark frame background.
1466 (when (and (memq 'xpm img)
1467 (eq (frame-parameter nil 'background-mode) 'dark))
1468 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1469
1470 ;; Insert the image with a help-echo and a link.
1471 (make-button (prog1 (point) (insert-image img)) (point)
1472 'face 'default
1473 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
1474 'action (lambda (button) (browse-url "http://www.gnu.org/"))
1475 'follow-link t)
1476 (insert "\n\n")))))
1477
1478 (defun fancy-startup-tail (&optional concise)
1479 "Insert the tail part of the splash screen into the current buffer."
1480 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1481 "cyan" "darkblue")))
1482 (unless concise
1483 (fancy-splash-insert
1484 :face 'variable-pitch
1485 "\nTo start... "
1486 :link '("Open a File"
1487 (lambda (button) (call-interactively 'find-file))
1488 "Specify a new file's name, to edit the file")
1489 " "
1490 :link '("Open Home Directory"
1491 (lambda (button) (dired "~"))
1492 "Open your home directory, to operate on its files")
1493 " "
1494 :link '("Customize Startup"
1495 (lambda (button) (customize-group 'initialization))
1496 "Change initialization settings including this screen")
1497 "\n"))
1498 (fancy-splash-insert :face `(variable-pitch (:foreground ,fg))
1499 "\nThis is "
1500 (emacs-version)
1501 "\n"
1502 :face '(variable-pitch (:height 0.8))
1503 emacs-copyright
1504 "\n")
1505 (and auto-save-list-file-prefix
1506 ;; Don't signal an error if the
1507 ;; directory for auto-save-list files
1508 ;; does not yet exist.
1509 (file-directory-p (file-name-directory
1510 auto-save-list-file-prefix))
1511 (directory-files
1512 (file-name-directory auto-save-list-file-prefix)
1513 nil
1514 (concat "\\`"
1515 (regexp-quote (file-name-nondirectory
1516 auto-save-list-file-prefix)))
1517 t)
1518 (fancy-splash-insert :face '(variable-pitch (:foreground "red"))
1519 "\nIf an Emacs session crashed recently, "
1520 "type "
1521 :face '(fixed-pitch :foreground "red")
1522 "Meta-x recover-session RET"
1523 :face '(variable-pitch (:foreground "red"))
1524 "\nto recover"
1525 " the files you were editing."))
1526
1527 (when concise
1528 (fancy-splash-insert
1529 :face 'variable-pitch "\n"
1530 :link '("Dismiss this startup screen"
1531 (lambda (button)
1532 (when startup-screen-inhibit-startup-screen
1533 (customize-set-variable 'inhibit-startup-screen t)
1534 (customize-mark-to-save 'inhibit-startup-screen)
1535 (custom-save-all))
1536 (let ((w (get-buffer-window "*GNU Emacs*")))
1537 (and w (not (one-window-p)) (delete-window w)))
1538 (kill-buffer "*GNU Emacs*")))
1539 " ")
1540 (when (or user-init-file custom-file)
1541 (let ((checked (create-image "\300\300\141\143\067\076\034\030"
1542 'xbm t :width 8 :height 8 :background "grey75"
1543 :foreground "black" :relief -2 :ascent 'center))
1544 (unchecked (create-image (make-string 8 0)
1545 'xbm t :width 8 :height 8 :background "grey75"
1546 :foreground "black" :relief -2 :ascent 'center)))
1547 (insert-button
1548 " " :on-glyph checked :off-glyph unchecked 'checked nil
1549 'display unchecked 'follow-link t
1550 'action (lambda (button)
1551 (if (overlay-get button 'checked)
1552 (progn (overlay-put button 'checked nil)
1553 (overlay-put button 'display (overlay-get button :off-glyph))
1554 (setq startup-screen-inhibit-startup-screen nil))
1555 (overlay-put button 'checked t)
1556 (overlay-put button 'display (overlay-get button :on-glyph))
1557 (setq startup-screen-inhibit-startup-screen t)))))
1558 (fancy-splash-insert :face '(variable-pitch (:height 0.9))
1559 " Never show it again.")))))
1560
1561 (defun exit-splash-screen ()
1562 "Stop displaying the splash screen buffer."
1563 (interactive)
1564 (quit-window t))
1565
1566 (defun fancy-startup-screen (&optional concise)
1567 "Display fancy startup screen.
1568 If CONCISE is non-nil, display a concise version of the
1569 splash screen in another window."
1570 (let ((splash-buffer (get-buffer-create "*GNU Emacs*")))
1571 (with-current-buffer splash-buffer
1572 (let ((inhibit-read-only t))
1573 (erase-buffer)
1574 (setq default-directory command-line-default-directory)
1575 (make-local-variable 'startup-screen-inhibit-startup-screen)
1576 (if pure-space-overflow
1577 (insert pure-space-overflow-message))
1578 (unless concise
1579 (fancy-splash-head))
1580 (dolist (text fancy-startup-text)
1581 (apply #'fancy-splash-insert text)
1582 (insert "\n"))
1583 (skip-chars-backward "\n")
1584 (delete-region (point) (point-max))
1585 (insert "\n")
1586 (fancy-startup-tail concise))
1587 (use-local-map splash-screen-keymap)
1588 (setq tab-width 22
1589 buffer-read-only t)
1590 (set-buffer-modified-p nil)
1591 (if (and view-read-only (not view-mode))
1592 (view-mode-enter nil 'kill-buffer))
1593 (goto-char (point-min))
1594 (forward-line (if concise 2 4)))
1595 (if concise
1596 (progn
1597 (display-buffer splash-buffer)
1598 ;; If the splash screen is in a split window, fit it.
1599 (let ((window (get-buffer-window splash-buffer t)))
1600 (or (null window)
1601 (eq window (selected-window))
1602 (eq window (next-window window))
1603 (fit-window-to-buffer window))))
1604 (switch-to-buffer splash-buffer))))
1605
1606 (defun fancy-about-screen ()
1607 "Display fancy About screen."
1608 (let ((frame (fancy-splash-frame)))
1609 (save-selected-window
1610 (select-frame frame)
1611 (switch-to-buffer "*About GNU Emacs*")
1612 (setq buffer-undo-list t
1613 mode-line-format (propertize "---- %b %-"
1614 'face 'mode-line-buffer-id))
1615 (let ((inhibit-read-only t))
1616 (erase-buffer)
1617 (if pure-space-overflow
1618 (insert pure-space-overflow-message))
1619 (fancy-splash-head)
1620 (dolist (text fancy-about-text)
1621 (apply #'fancy-splash-insert text)
1622 (insert "\n"))
1623 (set-buffer-modified-p nil)
1624 (goto-char (point-min))
1625 (force-mode-line-update))
1626 (use-local-map splash-screen-keymap)
1627 (setq tab-width 22)
1628 (message "%s" (startup-echo-area-message))
1629 (setq buffer-read-only t)
1630 (goto-char (point-min))
1631 (forward-line 3))))
1632
1633 (defun fancy-splash-frame ()
1634 "Return the frame to use for the fancy splash screen.
1635 Returning non-nil does not mean we should necessarily
1636 use the fancy splash screen, but if we do use it,
1637 we put it on this frame."
1638 (let (chosen-frame)
1639 (dolist (frame (append (frame-list) (list (selected-frame))))
1640 (if (and (frame-visible-p frame)
1641 (not (window-minibuffer-p (frame-selected-window frame))))
1642 (setq chosen-frame frame)))
1643 chosen-frame))
1644
1645 (defun use-fancy-splash-screens-p ()
1646 "Return t if fancy splash screens should be used."
1647 (when (and (display-graphic-p)
1648 (or (and (display-color-p)
1649 (image-type-available-p 'xpm))
1650 (image-type-available-p 'pbm)))
1651 (let ((frame (fancy-splash-frame)))
1652 (when frame
1653 (let* ((img (create-image (or fancy-splash-image
1654 (if (and (display-color-p)
1655 (image-type-available-p 'xpm))
1656 "splash.xpm" "splash.pbm"))))
1657 (image-height (and img (cdr (image-size img nil frame))))
1658 ;; We test frame-height so that, if the frame is split
1659 ;; by displaying a warning, that doesn't cause the normal
1660 ;; splash screen to be used.
1661 (frame-height (1- (frame-height frame))))
1662 (> frame-height (+ image-height 19)))))))
1663
1664
1665 (defun normal-splash-screen (&optional startup concise)
1666 "Display non-graphic splash screen.
1667 If optional argument STARTUP is non-nil, display the startup screen
1668 after Emacs starts. If STARTUP is nil, display the About screen.
1669 If CONCISE is non-nil, display a concise version of the
1670 splash screen in another window."
1671 (let ((splash-buffer (get-buffer-create "*About GNU Emacs*")))
1672 (with-current-buffer splash-buffer
1673 (setq buffer-read-only nil)
1674 (erase-buffer)
1675 (setq default-directory command-line-default-directory)
1676 (set (make-local-variable 'tab-width) 8)
1677 (if (not startup)
1678 (set (make-local-variable 'mode-line-format)
1679 (propertize "---- %b %-" 'face 'mode-line-buffer-id)))
1680
1681 (if pure-space-overflow
1682 (insert pure-space-overflow-message))
1683
1684 ;; The convention for this piece of code is that
1685 ;; each piece of output starts with one or two newlines
1686 ;; and does not end with any newlines.
1687 (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs"))
1688 (insert
1689 (if (eq system-type 'gnu/linux)
1690 ", one component of the GNU/Linux operating system.\n"
1691 ", a part of the GNU operating system.\n"))
1692
1693 (if startup
1694 (if (display-mouse-p)
1695 ;; The user can use the mouse to activate menus
1696 ;; so give help in terms of menu items.
1697 (normal-mouse-startup-screen)
1698
1699 ;; No mouse menus, so give help using kbd commands.
1700 (normal-no-mouse-startup-screen))
1701
1702 (normal-about-screen))
1703
1704 ;; The rest of the startup screen is the same on all
1705 ;; kinds of terminals.
1706
1707 ;; Give information on recovering, if there was a crash.
1708 (and startup
1709 auto-save-list-file-prefix
1710 ;; Don't signal an error if the
1711 ;; directory for auto-save-list files
1712 ;; does not yet exist.
1713 (file-directory-p (file-name-directory
1714 auto-save-list-file-prefix))
1715 (directory-files
1716 (file-name-directory auto-save-list-file-prefix)
1717 nil
1718 (concat "\\`"
1719 (regexp-quote (file-name-nondirectory
1720 auto-save-list-file-prefix)))
1721 t)
1722 (insert "\n\nIf an Emacs session crashed recently, "
1723 "type Meta-x recover-session RET\nto recover"
1724 " the files you were editing.\n"))
1725
1726 (use-local-map splash-screen-keymap)
1727
1728 ;; Display the input that we set up in the buffer.
1729 (set-buffer-modified-p nil)
1730 (setq buffer-read-only t)
1731 (if (and view-read-only (not view-mode))
1732 (view-mode-enter nil 'kill-buffer))
1733 (if startup (rename-buffer "*GNU Emacs*" t))
1734 (goto-char (point-min)))
1735 (if concise
1736 (display-buffer splash-buffer)
1737 (switch-to-buffer splash-buffer))))
1738
1739 (defun normal-mouse-startup-screen ()
1740 ;; The user can use the mouse to activate menus
1741 ;; so give help in terms of menu items.
1742 (insert "\
1743 To follow a link, click Mouse-1 on it, or move to it and type RET.
1744 To quit a partially entered command, type Control-g.\n")
1745
1746 (insert "\nImportant Help menu items:\n")
1747 (insert-button "Emacs Tutorial"
1748 'action (lambda (button) (help-with-tutorial))
1749 'follow-link t)
1750 (insert "\t\tLearn basic Emacs keystroke commands\n")
1751 (insert-button "Read the Emacs Manual"
1752 'action (lambda (button) (info-emacs-manual))
1753 'follow-link t)
1754 (insert "\tView the Emacs manual using Info\n")
1755 (insert-button "\(Non)Warranty"
1756 'action (lambda (button) (describe-no-warranty))
1757 'follow-link t)
1758 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1759 (insert-button "Copying Conditions"
1760 'action (lambda (button) (describe-copying))
1761 'follow-link t)
1762 (insert "\tConditions for redistributing and changing Emacs\n")
1763 (insert-button "More Manuals / Ordering Manuals"
1764 'action (lambda (button) (view-order-manuals))
1765 'follow-link t)
1766 (insert " How to order printed manuals from the FSF\n")
1767
1768 (insert "\nUseful tasks:\n")
1769 (insert-button "Visit New File"
1770 'action (lambda (button) (call-interactively 'find-file))
1771 'follow-link t)
1772 (insert "\t\tSpecify a new file's name, to edit the file\n")
1773 (insert-button "Open Home Directory"
1774 'action (lambda (button) (dired "~"))
1775 'follow-link t)
1776 (insert "\tOpen your home directory, to operate on its files\n")
1777 (insert-button "Customize Startup"
1778 'action (lambda (button) (customize-group 'initialization))
1779 'follow-link t)
1780 (insert "\tChange initialization settings including this screen\n")
1781
1782 (insert "\n" (emacs-version)
1783 "\n" emacs-copyright))
1784
1785 ;; No mouse menus, so give help using kbd commands.
1786 (defun normal-no-mouse-startup-screen ()
1787
1788 ;; If keys have their default meanings,
1789 ;; use precomputed string to save lots of time.
1790 (if (and (eq (key-binding "\C-h") 'help-command)
1791 (eq (key-binding "\C-xu") 'advertised-undo)
1792 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
1793 (eq (key-binding "\C-ht") 'help-with-tutorial)
1794 (eq (key-binding "\C-hi") 'info)
1795 (eq (key-binding "\C-hr") 'info-emacs-manual)
1796 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
1797 (progn
1798 (insert "
1799 Get help\t C-h (Hold down CTRL and press h)
1800 ")
1801 (insert-button "Emacs manual"
1802 'action (lambda (button) (info-emacs-manual))
1803 'follow-link t)
1804 (insert " C-h r\t")
1805 (insert-button "Browse manuals"
1806 'action (lambda (button) (Info-directory))
1807 'follow-link t)
1808 (insert "\t C-h i
1809 ")
1810 (insert-button "Emacs tutorial"
1811 'action (lambda (button) (help-with-tutorial))
1812 'follow-link t)
1813 (insert " C-h t\tUndo changes\t C-x u
1814 ")
1815 (insert-button "Buy manuals"
1816 'action (lambda (button) (view-order-manuals))
1817 'follow-link t)
1818 (insert "\t C-h C-m\tExit Emacs\t C-x C-c"))
1819
1820 (insert (format "
1821 Get help\t %s
1822 "
1823 (let ((where (where-is-internal
1824 'help-command nil t)))
1825 (if where
1826 (key-description where)
1827 "M-x help"))))
1828 (insert-button "Emacs manual"
1829 'action (lambda (button) (info-emacs-manual))
1830 'follow-link t)
1831 (insert (substitute-command-keys"\t \\[info-emacs-manual]\t"))
1832 (insert-button "Browse manuals"
1833 'action (lambda (button) (Info-directory))
1834 'follow-link t)
1835 (insert (substitute-command-keys "\t \\[info]
1836 "))
1837 (insert-button "Emacs tutorial"
1838 'action (lambda (button) (help-with-tutorial))
1839 'follow-link t)
1840 (insert (substitute-command-keys
1841 "\t \\[help-with-tutorial]\tUndo changes\t \\[advertised-undo]
1842 "))
1843 (insert-button "Buy manuals"
1844 'action (lambda (button) (view-order-manuals))
1845 'follow-link t)
1846 (insert (substitute-command-keys
1847 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
1848
1849 ;; Say how to use the menu bar with the keyboard.
1850 (insert "\n")
1851 (insert-button "Activate menubar"
1852 'action (lambda (button) (tmm-menubar))
1853 'follow-link t)
1854 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1855 (eq (key-binding [f10]) 'tmm-menubar))
1856 (insert " F10 or ESC ` or M-`")
1857 (insert (substitute-command-keys " \\[tmm-menubar]")))
1858
1859 ;; Many users seem to have problems with these.
1860 (insert "
1861 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1862 If you have no Meta key, you may instead type ESC followed by the character.)")
1863
1864 ;; Insert links to useful tasks
1865 (insert "\nUseful tasks:\n")
1866
1867 (insert-button "Visit New File"
1868 'action (lambda (button) (call-interactively 'find-file))
1869 'follow-link t)
1870 (insert "\t\t\t")
1871 (insert-button "Open Home Directory"
1872 'action (lambda (button) (dired "~"))
1873 'follow-link t)
1874 (insert "\n")
1875
1876 (insert-button "Customize Startup"
1877 'action (lambda (button) (customize-group 'initialization))
1878 'follow-link t)
1879 (insert "\t\t")
1880 (insert-button "Open *scratch* buffer"
1881 'action (lambda (button) (switch-to-buffer
1882 (get-buffer-create "*scratch*")))
1883 'follow-link t)
1884 (insert "\n")
1885 (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
1886
1887 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1888 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1889 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1890 (progn
1891 (insert
1892 "
1893 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1894 (insert-button "full details"
1895 'action (lambda (button) (describe-no-warranty))
1896 'follow-link t)
1897 (insert ".
1898 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1899 of Emacs and modify it; type C-h C-c to see ")
1900 (insert-button "the conditions"
1901 'action (lambda (button) (describe-copying))
1902 'follow-link t)
1903 (insert ".
1904 Type C-h C-d for information on ")
1905 (insert-button "getting the latest version"
1906 'action (lambda (button) (describe-distribution))
1907 'follow-link t)
1908 (insert "."))
1909 (insert (substitute-command-keys
1910 "
1911 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1912 (insert-button "full details"
1913 'action (lambda (button) (describe-no-warranty))
1914 'follow-link t)
1915 (insert (substitute-command-keys ".
1916 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1917 of Emacs and modify it; type \\[describe-copying] to see "))
1918 (insert-button "the conditions"
1919 'action (lambda (button) (describe-copying))
1920 'follow-link t)
1921 (insert (substitute-command-keys".
1922 Type \\[describe-distribution] for information on "))
1923 (insert-button "getting the latest version"
1924 'action (lambda (button) (describe-distribution))
1925 'follow-link t)
1926 (insert ".")))
1927
1928 (defun normal-about-screen ()
1929 (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n")
1930
1931 (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n")
1932
1933 (insert-button "Authors"
1934 'action
1935 (lambda (button)
1936 (view-file (expand-file-name "AUTHORS" data-directory))
1937 (goto-char (point-min)))
1938 'follow-link t)
1939 (insert "\t\tMany people have contributed code included in GNU Emacs\n")
1940
1941 (insert-button "Contributing"
1942 'action
1943 (lambda (button)
1944 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1945 (goto-char (point-min)))
1946 'follow-link t)
1947 (insert "\tHow to contribute improvements to Emacs\n\n")
1948
1949 (insert-button "GNU and Freedom"
1950 'action (lambda (button) (describe-gnu-project))
1951 'follow-link t)
1952 (insert "\t\tWhy we developed GNU Emacs and the GNU system\n")
1953
1954 (insert-button "Absence of Warranty"
1955 'action (lambda (button) (describe-no-warranty))
1956 'follow-link t)
1957 (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1958
1959 (insert-button "Copying Conditions"
1960 'action (lambda (button) (describe-copying))
1961 'follow-link t)
1962 (insert "\tConditions for redistributing and changing Emacs\n")
1963
1964 (insert-button "Getting New Versions"
1965 'action (lambda (button) (describe-distribution))
1966 'follow-link t)
1967 (insert "\tHow to get the latest version of GNU Emacs\n")
1968
1969 (insert-button "More Manuals / Ordering Manuals"
1970 'action (lambda (button) (view-order-manuals))
1971 'follow-link t)
1972 (insert "\tBuying printed manuals from the FSF\n"))
1973
1974 (defun startup-echo-area-message ()
1975 (if (eq (key-binding "\C-h\C-a") 'about-emacs)
1976 "For information about GNU Emacs and the GNU system, type C-h C-a."
1977 (substitute-command-keys
1978 "For information about GNU Emacs and the GNU system, type \
1979 \\[about-emacs].")))
1980
1981
1982 (defun display-startup-echo-area-message ()
1983 (let ((resize-mini-windows t))
1984 (or noninteractive ;(input-pending-p) init-file-had-error
1985 ;; t if the init file says to inhibit the echo area startup message.
1986 (and inhibit-startup-echo-area-message
1987 user-init-file
1988 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1989 (equal inhibit-startup-echo-area-message
1990 (if (equal init-file-user "")
1991 (user-login-name)
1992 init-file-user)))
1993 ;; Wasn't set with custom; see if .emacs has a setq.
1994 (let ((buffer (get-buffer-create " *temp*")))
1995 (prog1
1996 (condition-case nil
1997 (save-excursion
1998 (set-buffer buffer)
1999 (insert-file-contents user-init-file)
2000 (re-search-forward
2001 (concat
2002 "([ \t\n]*setq[ \t\n]+"
2003 "inhibit-startup-echo-area-message[ \t\n]+"
2004 (regexp-quote
2005 (prin1-to-string
2006 (if (equal init-file-user "")
2007 (user-login-name)
2008 init-file-user)))
2009 "[ \t\n]*)")
2010 nil t))
2011 (error nil))
2012 (kill-buffer buffer)))))
2013 (message "%s" (startup-echo-area-message)))))
2014
2015 (defun display-startup-screen (&optional concise)
2016 "Display startup screen according to display.
2017 A fancy display is used on graphic displays, normal otherwise.
2018
2019 If CONCISE is non-nil, display a concise version of the startup
2020 screen."
2021 ;; Prevent recursive calls from server-process-filter.
2022 (if (not (get-buffer "*GNU Emacs*"))
2023 (if (use-fancy-splash-screens-p)
2024 (fancy-startup-screen concise)
2025 (normal-splash-screen t concise))))
2026
2027 (defun display-about-screen ()
2028 "Display the *About GNU Emacs* buffer.
2029 A fancy display is used on graphic displays, normal otherwise."
2030 (interactive)
2031 (if (use-fancy-splash-screens-p)
2032 (fancy-about-screen)
2033 (normal-splash-screen nil)))
2034
2035 (defalias 'about-emacs 'display-about-screen)
2036 (defalias 'display-splash-screen 'display-startup-screen)
2037
2038 (defun command-line-1 (command-line-args-left)
2039 (display-startup-echo-area-message)
2040
2041 ;; Delay 2 seconds after an init file error message
2042 ;; was displayed, so user can read it.
2043 (when init-file-had-error
2044 (sit-for 2))
2045
2046 (when (and pure-space-overflow
2047 (not noninteractive))
2048 (display-warning
2049 'initialization
2050 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
2051 :warning))
2052
2053 (let ((file-count 0)
2054 first-file-buffer)
2055 (when command-line-args-left
2056 ;; We have command args; process them.
2057 (let ((dir command-line-default-directory)
2058 tem
2059 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
2060 ;; if foo is intended to be found in DIR.
2061 ;;
2062 ;; ;; The directories listed in --directory/-L options will *appear*
2063 ;; ;; at the front of `load-path' in the order they appear on the
2064 ;; ;; command-line. We cannot do this by *placing* them at the front
2065 ;; ;; in the order they appear, so we need this variable to hold them,
2066 ;; ;; temporarily.
2067 ;; extra-load-path
2068 ;;
2069 ;; To DTRT we keep track of the splice point and modify `load-path'
2070 ;; straight away upon any --directory/-L option.
2071 splice
2072 just-files ;; t if this follows the magic -- option.
2073 ;; This includes our standard options' long versions
2074 ;; and long versions of what's on command-switch-alist.
2075 (longopts
2076 (append '(("--funcall") ("--load") ("--insert") ("--kill")
2077 ("--directory") ("--eval") ("--execute") ("--no-splash")
2078 ("--find-file") ("--visit") ("--file") ("--no-desktop"))
2079 (mapcar (lambda (elt)
2080 (list (concat "-" (car elt))))
2081 command-switch-alist)))
2082 (line 0)
2083 (column 0))
2084
2085 ;; Add the long X options to longopts.
2086 (dolist (tem command-line-x-option-alist)
2087 (if (string-match "^--" (car tem))
2088 (push (list (car tem)) longopts)))
2089
2090 ;; Add the long NS options to longopts.
2091 (setq tem command-line-ns-option-alist)
2092 (while tem
2093 (if (string-match "^--" (car (car tem)))
2094 (setq longopts (cons (list (car (car tem))) longopts)))
2095 (setq tem (cdr tem)))
2096
2097 ;; Loop, processing options.
2098 (while command-line-args-left
2099 (let* ((argi (car command-line-args-left))
2100 (orig-argi argi)
2101 argval completion)
2102 (setq command-line-args-left (cdr command-line-args-left))
2103
2104 ;; Do preliminary decoding of the option.
2105 (if just-files
2106 ;; After --, don't look for options; treat all args as files.
2107 (setq argi "")
2108 ;; Convert long options to ordinary options
2109 ;; and separate out an attached option argument into argval.
2110 (when (string-match "^\\(--[^=]*\\)=" argi)
2111 (setq argval (substring argi (match-end 0))
2112 argi (match-string 1 argi)))
2113 (if (equal argi "--")
2114 (setq completion nil)
2115 (setq completion (try-completion argi longopts)))
2116 (if (eq completion t)
2117 (setq argi (substring argi 1))
2118 (if (stringp completion)
2119 (let ((elt (assoc completion longopts)))
2120 (or elt
2121 (error "Option `%s' is ambiguous" argi))
2122 (setq argi (substring (car elt) 1)))
2123 (setq argval nil
2124 argi orig-argi))))
2125
2126 ;; Execute the option.
2127 (cond ((setq tem (assoc argi command-switch-alist))
2128 (if argval
2129 (let ((command-line-args-left
2130 (cons argval command-line-args-left)))
2131 (funcall (cdr tem) argi))
2132 (funcall (cdr tem) argi)))
2133
2134 ((equal argi "-no-splash")
2135 (setq inhibit-startup-screen t))
2136
2137 ((member argi '("-f" ; what the manual claims
2138 "-funcall"
2139 "-e")) ; what the source used to say
2140 (setq inhibit-startup-screen t)
2141 (setq tem (intern (or argval (pop command-line-args-left))))
2142 (if (commandp tem)
2143 (command-execute tem)
2144 (funcall tem)))
2145
2146 ((member argi '("-eval" "-execute"))
2147 (setq inhibit-startup-screen t)
2148 (eval (read (or argval (pop command-line-args-left)))))
2149
2150 ((member argi '("-L" "-directory"))
2151 (setq tem (expand-file-name
2152 (command-line-normalize-file-name
2153 (or argval (pop command-line-args-left)))))
2154 (cond (splice (setcdr splice (cons tem (cdr splice)))
2155 (setq splice (cdr splice)))
2156 (t (setq load-path (cons tem load-path)
2157 splice load-path))))
2158
2159 ((member argi '("-l" "-load"))
2160 (let* ((file (command-line-normalize-file-name
2161 (or argval (pop command-line-args-left))))
2162 ;; Take file from default dir if it exists there;
2163 ;; otherwise let `load' search for it.
2164 (file-ex (expand-file-name file)))
2165 (when (file-exists-p file-ex)
2166 (setq file file-ex))
2167 (load file nil t)))
2168
2169 ;; This is used to handle -script. It's not clear
2170 ;; we need to document it (it is totally internal).
2171 ((member argi '("-scriptload"))
2172 (let* ((file (command-line-normalize-file-name
2173 (or argval (pop command-line-args-left))))
2174 ;; Take file from default dir.
2175 (file-ex (expand-file-name file)))
2176 (load file-ex nil t t)))
2177
2178 ((equal argi "-insert")
2179 (setq inhibit-startup-screen t)
2180 (setq tem (or argval (pop command-line-args-left)))
2181 (or (stringp tem)
2182 (error "File name omitted from `-insert' option"))
2183 (insert-file-contents (command-line-normalize-file-name tem)))
2184
2185 ((equal argi "-kill")
2186 (kill-emacs t))
2187
2188 ;; This is for when they use --no-desktop with -q, or
2189 ;; don't load Desktop in their .emacs. If desktop.el
2190 ;; _is_ loaded, it will handle this switch, and we
2191 ;; won't see it by the time we get here.
2192 ((equal argi "-no-desktop")
2193 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
2194
2195 ((string-match "^\\+[0-9]+\\'" argi)
2196 (setq line (string-to-number argi)))
2197
2198 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
2199 (setq line (string-to-number (match-string 1 argi))
2200 column (string-to-number (match-string 2 argi))))
2201
2202 ((setq tem (assoc argi command-line-x-option-alist))
2203 ;; Ignore X-windows options and their args if not using X.
2204 (setq command-line-args-left
2205 (nthcdr (nth 1 tem) command-line-args-left)))
2206
2207 ((setq tem (assoc argi command-line-ns-option-alist))
2208 ;; Ignore NS-windows options and their args if not using NS.
2209 (setq command-line-args-left
2210 (nthcdr (nth 1 tem) command-line-args-left)))
2211
2212 ((member argi '("-find-file" "-file" "-visit"))
2213 (setq inhibit-startup-screen t)
2214 ;; An explicit option to specify visiting a file.
2215 (setq tem (or argval (pop command-line-args-left)))
2216 (unless (stringp tem)
2217 (error "File name omitted from `%s' option" argi))
2218 (setq file-count (1+ file-count))
2219 (let ((file (expand-file-name
2220 (command-line-normalize-file-name tem) dir)))
2221 (if (= file-count 1)
2222 (setq first-file-buffer (find-file file))
2223 (find-file-other-window file)))
2224 (or (zerop line)
2225 (goto-line line))
2226 (setq line 0)
2227 (unless (< column 1)
2228 (move-to-column (1- column)))
2229 (setq column 0))
2230
2231 ((equal argi "--")
2232 (setq just-files t))
2233 (t
2234 ;; We have almost exhausted our options. See if the
2235 ;; user has made any other command-line options available
2236 (let ((hooks command-line-functions)
2237 (did-hook nil))
2238 (while (and hooks
2239 (not (setq did-hook (funcall (car hooks)))))
2240 (setq hooks (cdr hooks)))
2241 (if (not did-hook)
2242 ;; Presume that the argument is a file name.
2243 (progn
2244 (if (string-match "\\`-" argi)
2245 (error "Unknown option `%s'" argi))
2246 (unless initial-window-system
2247 (setq inhibit-startup-screen t))
2248 (setq file-count (1+ file-count))
2249 (let ((file
2250 (expand-file-name
2251 (command-line-normalize-file-name orig-argi)
2252 dir)))
2253 (cond ((= file-count 1)
2254 (setq first-file-buffer (find-file file)))
2255 (inhibit-startup-screen
2256 (find-file-other-window file))
2257 (t (find-file file))))
2258 (or (zerop line)
2259 (goto-line line))
2260 (setq line 0)
2261 (unless (< column 1)
2262 (move-to-column (1- column)))
2263 (setq column 0))))))
2264 ;; In unusual circumstances, the execution of Lisp code due
2265 ;; to command-line options can cause the last visible frame
2266 ;; to be deleted. In this case, kill emacs to avoid an
2267 ;; abort later.
2268 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))))
2269
2270 (when initial-buffer-choice
2271 (cond ((eq initial-buffer-choice t)
2272 (switch-to-buffer (get-buffer-create "*scratch*")))
2273 ((stringp initial-buffer-choice)
2274 (find-file initial-buffer-choice))))
2275
2276 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2277 (and initial-scratch-message
2278 (get-buffer "*scratch*")
2279 (with-current-buffer "*scratch*"
2280 (when (zerop (buffer-size))
2281 (insert initial-scratch-message)
2282 (set-buffer-modified-p nil))))
2283
2284 (if (or inhibit-startup-screen
2285 initial-buffer-choice
2286 noninteractive
2287 emacs-quick-startup)
2288
2289 ;; Not displaying a startup screen. If 3 or more files
2290 ;; visited, and not all visible, show user what they all are.
2291 (and (> file-count 2)
2292 (not noninteractive)
2293 (not inhibit-startup-buffer-menu)
2294 (or (get-buffer-window first-file-buffer)
2295 (list-buffers)))
2296
2297 ;; Display a startup screen, after some preparations.
2298
2299 ;; If there are no switches to process, we might as well
2300 ;; run this hook now, and there may be some need to do it
2301 ;; before doing any output.
2302 (run-hooks 'emacs-startup-hook)
2303 (and term-setup-hook
2304 (run-hooks 'term-setup-hook))
2305 (setq inhibit-startup-hooks t)
2306
2307 ;; It's important to notice the user settings before we
2308 ;; display the startup message; otherwise, the settings
2309 ;; won't take effect until the user gives the first
2310 ;; keystroke, and that's distracting.
2311 (when (fboundp 'frame-notice-user-settings)
2312 (frame-notice-user-settings))
2313
2314 ;; If there are no switches to process, we might as well
2315 ;; run this hook now, and there may be some need to do it
2316 ;; before doing any output.
2317 (when window-setup-hook
2318 (run-hooks 'window-setup-hook)
2319 ;; Don't let the hook be run twice.
2320 (setq window-setup-hook nil))
2321
2322 ;; ;; Do this now to avoid an annoying delay if the user
2323 ;; ;; clicks the menu bar during the sit-for.
2324 ;; (when (display-popup-menus-p)
2325 ;; (precompute-menubar-bindings))
2326 ;; (with-no-warnings
2327 ;; (setq menubar-bindings-done t))
2328
2329 (if (> file-count 0)
2330 (display-startup-screen t)
2331 (display-startup-screen nil)))))
2332
2333 (defun command-line-normalize-file-name (file)
2334 "Collapse multiple slashes to one, to handle non-Emacs file names."
2335 (save-match-data
2336 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2337 ;; That is significant on some systems.
2338 ;; However, /// at the beginning is supposed to mean just /, not //.
2339 (if (string-match "^///+" file)
2340 (setq file (replace-match "/" t t file)))
2341 (while (string-match "//+" file 1)
2342 (setq file (replace-match "/" t t file)))
2343 file))
2344
2345 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
2346 ;;; startup.el ends here