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