* mh-mime.el (mh-decode-message-subject): Fix case of Subject.
[emacs.git] / lisp / startup.el
blobc6f3063ca900f31825c433fd24de5e7df7184c71
1 ;;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
3 ;; Copyright (C) 1985-1986, 1992, 1994-2011 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: internal
7 ;; Package: emacs
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; This file parses the command line and gets Emacs running. Options
27 ;; on the command line are handled in precedence order. For priorities
28 ;; see the structure standard_args in the emacs.c file.
30 ;;; Code:
32 (setq top-level '(normal-top-level))
34 (defvar command-line-processed nil
35 "Non-nil once command line has been processed.")
37 (defgroup initialization nil
38 "Emacs start-up procedure."
39 :group 'environment)
41 (defcustom initial-buffer-choice nil
42 "Buffer to show after starting Emacs.
43 If the value is nil and `inhibit-startup-screen' is nil, show the
44 startup screen. If the value is string, visit the specified file or
45 directory using `find-file'. If t, open the `*scratch*' buffer."
46 :type '(choice
47 (const :tag "Startup screen" nil)
48 (directory :tag "Directory" :value "~/")
49 (file :tag "File" :value "~/.emacs")
50 (const :tag "Lisp scratch buffer" t))
51 :version "23.1"
52 :group 'initialization)
54 (defcustom inhibit-startup-screen nil
55 "Non-nil inhibits the startup screen.
57 This is for use in your personal init file (but NOT site-start.el),
58 once you are familiar with the contents of the startup screen."
59 :type 'boolean
60 :group 'initialization)
62 (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen)
63 (defvaralias 'inhibit-startup-message 'inhibit-startup-screen)
65 (defvar startup-screen-inhibit-startup-screen nil)
67 (defcustom inhibit-startup-echo-area-message nil
68 "Non-nil inhibits the initial startup echo area message.
69 Setting this variable takes effect
70 only if you do it with the customization buffer
71 or if your `.emacs' file contains a line of this form:
72 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
73 If your `.emacs' file is byte-compiled, use the following form instead:
74 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
75 Thus, someone else using a copy of your `.emacs' file will see
76 the startup message unless he personally acts to inhibit it."
77 :type '(choice (const :tag "Don't inhibit")
78 (string :tag "Enter your user name, to inhibit"))
79 :group 'initialization)
81 (defcustom inhibit-default-init nil
82 "Non-nil inhibits loading the `default' library."
83 :type 'boolean
84 :group 'initialization)
86 (defcustom inhibit-startup-buffer-menu nil
87 "Non-nil inhibits display of buffer list when more than 2 files are loaded."
88 :type 'boolean
89 :group 'initialization)
91 (defvar command-switch-alist nil
92 "Alist of command-line switches.
93 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
94 HANDLER-FUNCTION receives the switch string as its sole argument;
95 the remaining command-line args are in the variable `command-line-args-left'.")
97 (defvar command-line-args-left nil
98 "List of command-line args not yet processed.")
100 (defvaralias 'argv 'command-line-args-left
101 ;; FIXME: Bad name for a dynamically bound variable.
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 x-handle-name-switch)
203 ("-title" 1 x-handle-switch title)
204 ("-T" 1 x-handle-switch title)
205 ("-r" 0 x-handle-switch reverse t)
206 ("-rv" 0 x-handle-switch reverse t)
207 ("-reverse" 0 x-handle-switch reverse t)
208 ("-fn" 1 x-handle-switch font)
209 ("-font" 1 x-handle-switch font)
210 ("-ib" 1 x-handle-numeric-switch internal-border-width)
211 ;;("-g" . x-handle-geometry)
212 ;;("-geometry" . x-handle-geometry)
213 ("-fg" 1 x-handle-switch foreground-color)
214 ("-foreground" 1 x-handle-switch foreground-color)
215 ("-bg" 1 x-handle-switch background-color)
216 ("-background" 1 x-handle-switch background-color)
217 ; ("-ms" 1 x-handle-switch mouse-color)
218 ("-itype" 0 x-handle-switch icon-type t)
219 ("-i" 0 x-handle-switch icon-type t)
220 ("-iconic" 0 x-handle-iconic icon-type t)
221 ;;("-xrm" . x-handle-xrm-switch)
222 ("-cr" 1 x-handle-switch cursor-color)
223 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
224 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
225 ("-bd" 1 x-handle-switch)
226 ;; ("--border-width" 1 x-handle-numeric-switch border-width)
227 ;; ("--display" 1 ns-handle-display)
228 ("--name" 1 x-handle-name-switch)
229 ("--title" 1 x-handle-switch title)
230 ("--reverse-video" 0 x-handle-switch reverse t)
231 ("--font" 1 x-handle-switch font)
232 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
233 ;; ("--geometry" 1 ns-handle-geometry)
234 ("--foreground-color" 1 x-handle-switch foreground-color)
235 ("--background-color" 1 x-handle-switch background-color)
236 ("--mouse-color" 1 x-handle-switch mouse-color)
237 ("--icon-type" 0 x-handle-switch icon-type t)
238 ("--iconic" 0 x-handle-iconic)
239 ;; ("--xrm" 1 ns-handle-xrm-switch)
240 ("--cursor-color" 1 x-handle-switch cursor-color)
241 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
242 ("--border-color" 1 x-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 (purecopy "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-basic-display nil)
371 (defvar init-file-debug nil)
373 (defvar init-file-had-error nil
374 "Non-nil if there was an error loading the user's init file.")
376 (defvar normal-top-level-add-subdirs-inode-list nil)
378 (defvar no-blinking-cursor nil)
380 (defvar default-frame-background-mode)
382 (defvar pure-space-overflow nil
383 "Non-nil if building Emacs overflowed pure space.")
385 (defvar pure-space-overflow-message (purecopy "\
386 Warning Warning!!! Pure space overflow !!!Warning Warning
387 \(See the node Pure Storage in the Lisp manual for details.)\n"))
389 (defcustom tutorial-directory
390 (file-name-as-directory (expand-file-name "tutorials" data-directory))
391 "Directory containing the Emacs TUTORIAL files."
392 :group 'installation
393 :type 'directory
394 :initialize 'custom-initialize-delay)
396 (defconst package-subdirectory-regexp
397 "\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)"
398 "Regular expression matching the name of a package subdirectory.
399 The first subexpression is the package name.
400 The second subexpression is the version string.
402 The regexp should not contain a starting \"\\`\" or a trailing
403 \"\\'\"; those are added automatically by callers.")
405 (defun normal-top-level-add-subdirs-to-load-path ()
406 "Add all subdirectories of current directory to `load-path'.
407 More precisely, this uses only the subdirectories whose names
408 start with letters or digits; it excludes any subdirectory named `RCS'
409 or `CVS', and any subdirectory that contains a file named `.nosearch'."
410 (let (dirs
411 attrs
412 (pending (list default-directory)))
413 ;; This loop does a breadth-first tree walk on DIR's subtree,
414 ;; putting each subdir into DIRS as its contents are examined.
415 (while pending
416 (push (pop pending) dirs)
417 (let* ((this-dir (car dirs))
418 (contents (directory-files this-dir))
419 (default-directory this-dir)
420 (canonicalized (if (fboundp 'untranslated-canonical-name)
421 (untranslated-canonical-name this-dir))))
422 ;; The Windows version doesn't report meaningful inode numbers, so
423 ;; use the canonicalized absolute file name of the directory instead.
424 (setq attrs (or canonicalized
425 (nthcdr 10 (file-attributes this-dir))))
426 (unless (member attrs normal-top-level-add-subdirs-inode-list)
427 (push attrs normal-top-level-add-subdirs-inode-list)
428 (dolist (file contents)
429 (and (string-match "\\`[[:alnum:]]" file)
430 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
431 (not (member file '("RCS" "CVS" "rcs" "cvs")))
432 ;; Avoid doing a `stat' when it isn't necessary because
433 ;; that can cause trouble when an NFS server is down.
434 (not (string-match "\\.elc?\\'" file))
435 (file-directory-p file)
436 (let ((expanded (expand-file-name file)))
437 (or (file-exists-p (expand-file-name ".nosearch" expanded))
438 (setq pending (nconc pending (list expanded))))))))))
439 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
441 (defun normal-top-level-add-to-load-path (dirs)
442 "This function is called from a subdirs.el file.
443 It assumes that `default-directory' is the directory in which the
444 subdirs.el file exists, and it adds to `load-path' the subdirs of
445 that directory as specified in DIRS. Normally the elements of
446 DIRS are relative."
447 (let ((tail load-path)
448 (thisdir (directory-file-name default-directory)))
449 (while (and tail
450 ;;Don't go all the way to the nil terminator.
451 (cdr tail)
452 (not (equal thisdir (car tail)))
453 (not (and (memq system-type '(ms-dos windows-nt))
454 (equal (downcase thisdir) (downcase (car tail))))))
455 (setq tail (cdr tail)))
456 ;;Splice the new section in.
457 (when tail
458 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
460 (defun normal-top-level ()
461 (if command-line-processed
462 (message "Back to top level.")
463 (setq command-line-processed t)
464 (let ((dir default-directory))
465 (with-current-buffer "*Messages*"
466 ;; Make it easy to do like "tail -f".
467 (set (make-local-variable 'window-point-insertion-type) t)
468 ;; Give *Messages* the same default-directory as *scratch*,
469 ;; just to keep things predictable.
470 (setq default-directory dir)))
471 ;; `user-full-name' is now known; reset its standard-value here.
472 (put 'user-full-name 'standard-value
473 (list (default-value 'user-full-name)))
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 ((old-face-font-rescale-alist face-font-rescale-alist))
505 (unwind-protect
506 (command-line)
507 ;; Do this again, in case .emacs defined more abbreviations.
508 (setq default-directory (abbreviate-file-name default-directory))
509 ;; Specify the file for recording all the auto save files of this session.
510 ;; This is used by recover-session.
511 (or auto-save-list-file-name
512 (and auto-save-list-file-prefix
513 (setq auto-save-list-file-name
514 ;; Under MS-DOS our PID is almost always reused between
515 ;; Emacs invocations. We need something more unique.
516 (cond ((eq system-type 'ms-dos)
517 ;; We are going to access the auto-save
518 ;; directory, so make sure it exists.
519 (make-directory
520 (file-name-directory auto-save-list-file-prefix)
522 (concat
523 (make-temp-name
524 (expand-file-name
525 auto-save-list-file-prefix))
526 "~"))
528 (expand-file-name
529 (format "%s%d-%s~"
530 auto-save-list-file-prefix
531 (emacs-pid)
532 (system-name))))))))
533 (unless inhibit-startup-hooks
534 (run-hooks 'emacs-startup-hook)
535 (and term-setup-hook
536 (run-hooks 'term-setup-hook)))
538 ;; Don't do this if we failed to create the initial frame,
539 ;; for instance due to a dense colormap.
540 (when (or frame-initial-frame
541 ;; If frame-initial-frame has no meaning, do this anyway.
542 (not (and initial-window-system
543 (not noninteractive)
544 (not (eq initial-window-system 'pc)))))
546 ;; FIXME: The user's init file may change
547 ;; face-font-rescale-alist. However, the default face
548 ;; already has an assigned font object, which does not take
549 ;; face-font-rescale-alist into account. For such
550 ;; situations, we ought to have a way to find all font
551 ;; objects and regenerate them; currently we do not. As a
552 ;; workaround, we specifically reset te default face's :font
553 ;; attribute here. See bug#1785.
554 (unless (eq face-font-rescale-alist
555 old-face-font-rescale-alist)
556 (set-face-attribute 'default nil :font (font-spec)))
558 ;; Modify the initial frame based on what .emacs puts into
559 ;; ...-frame-alist.
560 (if (fboundp 'frame-notice-user-settings)
561 (frame-notice-user-settings))
562 ;; Set the faces for the initial background mode even if
563 ;; frame-notice-user-settings didn't (such as on a tty).
564 ;; frame-set-background-mode is idempotent, so it won't
565 ;; cause any harm if it's already been done.
566 (if (fboundp 'frame-set-background-mode)
567 (frame-set-background-mode (selected-frame))))
569 ;; Now we know the user's default font, so add it to the menu.
570 (if (fboundp 'font-menu-add-default)
571 (font-menu-add-default))
572 (and window-setup-hook
573 (run-hooks 'window-setup-hook))))
574 ;; Subprocesses of Emacs do not have direct access to the terminal, so
575 ;; unless told otherwise they should only assume a dumb terminal.
576 ;; We are careful to do it late (after term-setup-hook), although the
577 ;; new multi-tty code does not use $TERM any more there anyway.
578 (setenv "TERM" "dumb")
579 ;; Remove DISPLAY from the process-environment as well. This allows
580 ;; `callproc.c' to give it a useful adaptive default which is either
581 ;; the value of the `display' frame-parameter or the DISPLAY value
582 ;; from initial-environment.
583 (let ((display (frame-parameter nil 'display)))
584 ;; Be careful which DISPLAY to remove from process-environment: follow
585 ;; the logic of `callproc.c'.
586 (if (stringp display) (setq display (concat "DISPLAY=" display))
587 (dolist (varval initial-environment)
588 (if (string-match "\\`DISPLAY=" varval)
589 (setq display varval))))
590 (when display
591 (delete display process-environment)))))
593 ;; Precompute the keyboard equivalents in the menu bar items.
594 ;; Command-line options supported by tty's:
595 (defconst tty-long-option-alist
596 '(("--name" . "-name")
597 ("--title" . "-T")
598 ("--reverse-video" . "-reverse")
599 ("--foreground-color" . "-fg")
600 ("--background-color" . "-bg")
601 ("--color" . "-color")))
603 (defconst tool-bar-images-pixel-height 24
604 "Height in pixels of images in the tool-bar.")
606 (defvar tool-bar-originally-present nil
607 "Non-nil if tool-bars are present before user and site init files are read.")
609 (defvar handle-args-function-alist '((nil . tty-handle-args))
610 "Functions for processing window-system dependent command-line arguments.
611 Window system startup files should add their own function to this
612 alist, which should parse the command line arguments. Those
613 pertaining to the window system should be processed and removed
614 from the returned command line.")
616 (defvar window-system-initialization-alist '((nil . ignore))
617 "Alist of window-system initialization functions.
618 Window-system startup files should add their own initialization
619 function to this list. The function should take no arguments,
620 and initialize the window system environment to prepare for
621 opening the first frame (e.g. open a connection to an X server).")
623 (defun tty-handle-args (args)
624 "Handle the X-like command-line arguments \"-fg\", \"-bg\", \"-name\", etc."
625 (let (rest)
626 (message "%S" args)
627 (while (and args
628 (not (equal (car args) "--")))
629 (let* ((argi (pop args))
630 (orig-argi argi)
631 argval completion)
632 ;; Check for long options with attached arguments
633 ;; and separate out the attached option argument into argval.
634 (when (string-match "^\\(--[^=]*\\)=" argi)
635 (setq argval (substring argi (match-end 0))
636 argi (match-string 1 argi)))
637 (when (string-match "^--" argi)
638 (setq completion (try-completion argi tty-long-option-alist))
639 (if (eq completion t)
640 ;; Exact match for long option.
641 (setq argi (cdr (assoc argi tty-long-option-alist)))
642 (if (stringp completion)
643 (let ((elt (assoc completion tty-long-option-alist)))
644 ;; Check for abbreviated long option.
645 (or elt
646 (error "Option `%s' is ambiguous" argi))
647 (setq argi (cdr elt)))
648 ;; Check for a short option.
649 (setq argval nil
650 argi orig-argi))))
651 (cond ((member argi '("-fg" "-foreground"))
652 (push (cons 'foreground-color (or argval (pop args)))
653 default-frame-alist))
654 ((member argi '("-bg" "-background"))
655 (push (cons 'background-color (or argval (pop args)))
656 default-frame-alist))
657 ((member argi '("-T" "-name"))
658 (unless argval (setq argval (pop args)))
659 (push (cons 'title
660 (if (stringp argval)
661 argval
662 (let ((case-fold-search t)
664 (setq argval (invocation-name))
666 ;; Change any . or * characters in name to
667 ;; hyphens, so as to emulate behavior on X.
668 (while
669 (setq i (string-match "[.*]" argval))
670 (aset argval i ?-))
671 argval)))
672 default-frame-alist))
673 ((member argi '("-r" "-rv" "-reverse"))
674 (push '(reverse . t)
675 default-frame-alist))
676 ((equal argi "-color")
677 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
678 (push (cons 'tty-color-mode
679 (cond
680 ((numberp argval) argval)
681 ((string-match "-?[0-9]+" argval)
682 (string-to-number argval))
683 (t (intern argval))))
684 default-frame-alist))
686 (push argi rest)))))
687 (nreverse rest)))
689 (declare-function x-get-resource "frame.c"
690 (attribute class &optional component subclass))
691 (declare-function tool-bar-mode "tool-bar" (&optional arg))
692 (declare-function tool-bar-setup "tool-bar")
694 (defvar server-name)
695 (defvar server-process)
697 (defun command-line ()
698 (setq before-init-time (current-time)
699 after-init-time nil
700 command-line-default-directory default-directory)
702 ;; Force recomputation, in case it was computed during the dump.
703 (setq abbreviated-home-dir nil)
705 ;; See if we should import version-control from the environment variable.
706 (let ((vc (getenv "VERSION_CONTROL")))
707 (cond ((eq vc nil)) ;don't do anything if not set
708 ((member vc '("t" "numbered"))
709 (setq version-control t))
710 ((member vc '("nil" "existing"))
711 (setq version-control nil))
712 ((member vc '("never" "simple"))
713 (setq version-control 'never))))
715 ;;! This has been commented out; I currently find the behavior when
716 ;;! split-window-keep-point is nil disturbing, but if I can get used
717 ;;! to it, then it would be better to eliminate the option.
718 ;;! ;; Choose a good default value for split-window-keep-point.
719 ;;! (setq split-window-keep-point (> baud-rate 2400))
721 ;; Set the default strings to display in mode line for
722 ;; end-of-line formats that aren't native to this platform.
723 (cond
724 ((memq system-type '(ms-dos windows-nt))
725 (setq eol-mnemonic-unix "(Unix)"
726 eol-mnemonic-mac "(Mac)"))
727 (t ; this is for Unix/GNU/Linux systems
728 (setq eol-mnemonic-dos "(DOS)"
729 eol-mnemonic-mac "(Mac)")))
731 (set-locale-environment nil)
733 ;; Convert preloaded file names in load-history to absolute.
734 (let ((simple-file-name
735 ;; Look for simple.el or simple.elc and use their directory
736 ;; as the place where all Lisp files live.
737 (locate-file "simple" load-path (get-load-suffixes)))
738 lisp-dir)
739 ;; Don't abort if simple.el cannot be found, but print a warning.
740 (if (null simple-file-name)
741 (progn
742 (princ "Warning: Could not find simple.el nor simple.elc"
743 'external-debugging-output)
744 (terpri 'external-debugging-output))
745 (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
746 (setq load-history
747 (mapcar (lambda (elt)
748 (if (and (stringp (car elt))
749 (not (file-name-absolute-p (car elt))))
750 (cons (concat lisp-dir
751 (car elt))
752 (cdr elt))
753 elt))
754 load-history))))
756 ;; Convert the arguments to Emacs internal representation.
757 (let ((args (cdr command-line-args)))
758 (while args
759 (setcar args
760 (decode-coding-string (car args) locale-coding-system t))
761 (pop args)))
763 (let ((done nil)
764 (args (cdr command-line-args))
765 display-arg)
767 ;; Figure out which user's init file to load,
768 ;; either from the environment or from the options.
769 (setq init-file-user (if noninteractive nil (user-login-name)))
770 ;; If user has not done su, use current $HOME to find .emacs.
771 (and init-file-user
772 (equal init-file-user (user-real-login-name))
773 (setq init-file-user ""))
775 ;; Process the command-line args, and delete the arguments
776 ;; processed. This is consistent with the way main in emacs.c
777 ;; does things.
778 (while (and (not done) args)
779 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
780 ("--user") ("--iconic") ("--icon-type") ("--quick")
781 ("--no-blinking-cursor") ("--basic-display")))
782 (argi (pop args))
783 (orig-argi argi)
784 argval)
785 ;; Handle --OPTION=VALUE format.
786 (when (string-match "\\`\\(--[^=]*\\)=" argi)
787 (setq argval (substring argi (match-end 0))
788 argi (match-string 1 argi)))
789 (when (string-match "\\`--." orig-argi)
790 (let ((completion (try-completion argi longopts)))
791 (cond ((eq completion t)
792 (setq argi (substring argi 1)))
793 ((stringp completion)
794 (let ((elt (assoc completion longopts)))
795 (unless elt
796 (error "Option `%s' is ambiguous" argi))
797 (setq argi (substring (car elt) 1))))
799 (setq argval nil
800 argi orig-argi)))))
801 (cond
802 ;; The --display arg is handled partly in C, partly in Lisp.
803 ;; When it shows up here, we just put it back to be handled
804 ;; by `command-line-1'.
805 ((member argi '("-d" "-display"))
806 (setq display-arg (list argi (pop args))))
807 ((member argi '("-Q" "-quick"))
808 (setq init-file-user nil
809 site-run-file nil
810 inhibit-x-resources t))
811 ((member argi '("-D" "-basic-display"))
812 (setq no-blinking-cursor t
813 emacs-basic-display t)
814 (push '(vertical-scroll-bars . nil) initial-frame-alist))
815 ((member argi '("-q" "-no-init-file"))
816 (setq init-file-user nil))
817 ((member argi '("-u" "-user"))
818 (setq init-file-user (or argval (pop args))
819 argval nil))
820 ((equal argi "-no-site-file")
821 (setq site-run-file nil))
822 ((equal argi "-debug-init")
823 (setq init-file-debug t))
824 ((equal argi "-iconic")
825 (push '(visibility . icon) initial-frame-alist))
826 ((member argi '("-nbc" "-no-blinking-cursor"))
827 (setq no-blinking-cursor t))
828 ;; Push the popped arg back on the list of arguments.
830 (push argi args)
831 (setq done t)))
832 ;; Was argval set but not used?
833 (and argval
834 (error "Option `%s' doesn't allow an argument" argi))))
836 ;; Re-attach the --display arg.
837 (and display-arg (setq args (append display-arg args)))
839 ;; Re-attach the program name to the front of the arg list.
840 (and command-line-args
841 (setcdr command-line-args args)))
843 ;; Make sure window system's init file was loaded in loadup.el if
844 ;; using a window system.
845 ;; Initialize the window-system only after processing the command-line
846 ;; args so that -Q can influence this initialization.
847 (condition-case error
848 (unless noninteractive
849 (if (and initial-window-system
850 (not (featurep
851 (intern
852 (concat (symbol-name initial-window-system) "-win")))))
853 (error "Unsupported window system `%s'" initial-window-system))
854 ;; Process window-system specific command line parameters.
855 (setq command-line-args
856 (funcall
857 (or (cdr (assq initial-window-system handle-args-function-alist))
858 (error "Unsupported window system `%s'" initial-window-system))
859 command-line-args))
860 ;; Initialize the window system. (Open connection, etc.)
861 (funcall
862 (or (cdr (assq initial-window-system window-system-initialization-alist))
863 (error "Unsupported window system `%s'" initial-window-system))))
864 ;; If there was an error, print the error message and exit.
865 (error
866 (princ
867 (if (eq (car error) 'error)
868 (apply 'concat (cdr error))
869 (if (memq 'file-error (get (car error) 'error-conditions))
870 (format "%s: %s"
871 (nth 1 error)
872 (mapconcat (lambda (obj) (prin1-to-string obj t))
873 (cdr (cdr error)) ", "))
874 (format "%s: %s"
875 (get (car error) 'error-message)
876 (mapconcat (lambda (obj) (prin1-to-string obj t))
877 (cdr error) ", "))))
878 'external-debugging-output)
879 (terpri 'external-debugging-output)
880 (setq initial-window-system nil)
881 (kill-emacs)))
883 (run-hooks 'before-init-hook)
885 ;; Under X, this creates the X frame and deletes the terminal frame.
886 (unless (daemonp)
888 ;; If X resources are available, use them to initialize the values
889 ;; of `tool-bar-mode' and `menu-bar-mode', as well as the value of
890 ;; `no-blinking-cursor' and the `cursor' face.
891 (cond
892 ((or noninteractive emacs-basic-display)
893 (setq menu-bar-mode nil
894 tool-bar-mode nil
895 no-blinking-cursor t))
896 ((memq initial-window-system '(x w32 ns))
897 (let ((no-vals '("no" "off" "false" "0")))
898 (if (member (x-get-resource "menuBar" "MenuBar") no-vals)
899 (setq menu-bar-mode nil))
900 (if (member (x-get-resource "toolBar" "ToolBar") no-vals)
901 (setq tool-bar-mode nil))
902 (if (member (x-get-resource "cursorBlink" "CursorBlink")
903 no-vals)
904 (setq no-blinking-cursor t)))
905 ;; If the cursorColor X resource exists, alter the `cursor' face
906 ;; spec, but mark it as changed outside of Customize.
907 (let ((color (x-get-resource "cursorColor" "CursorColor")))
908 (when color
909 (put 'cursor 'theme-face
910 `((changed ((t :background ,color)))))
911 (put 'cursor 'face-modified t)))))
912 (frame-initialize))
914 (when (fboundp 'x-create-frame)
915 ;; Set up the tool-bar (even in tty frames, since Emacs might open a
916 ;; graphical frame later).
917 (unless noninteractive
918 (tool-bar-setup)))
920 ;; Turn off blinking cursor if so specified in X resources. This is here
921 ;; only because all other settings of no-blinking-cursor are here.
922 (unless (or noninteractive
923 emacs-basic-display
924 (and (memq window-system '(x w32 ns))
925 (not (member (x-get-resource "cursorBlink" "CursorBlink")
926 '("off" "false")))))
927 (setq no-blinking-cursor t))
929 ;; Re-evaluate predefined variables whose initial value depends on
930 ;; the runtime context.
931 (mapc 'custom-reevaluate-setting
932 ;; Initialize them in the same order they were loaded, in case there
933 ;; are dependencies between them.
934 (prog1 (nreverse custom-delayed-init-variables)
935 (setq custom-delayed-init-variables nil)))
937 (normal-erase-is-backspace-setup-frame)
939 ;; Register default TTY colors for the case the terminal hasn't a
940 ;; terminal init file. We do this regardles of whether the terminal
941 ;; supports colors or not and regardless the current display type,
942 ;; since users can connect to color-capable terminals and also
943 ;; switch color support on or off in mid-session by setting the
944 ;; tty-color-mode frame parameter.
945 ;; Exception: the `pc' ``window system'' has only 16 fixed colors,
946 ;; and they are already set at this point by a suitable function in
947 ;; window-system-initialization-alist.
948 (or (eq initial-window-system 'pc)
949 (tty-register-default-colors))
951 ;; Record whether the tool-bar is present before the user and site
952 ;; init files are processed. frame-notice-user-settings uses this
953 ;; to determine if the tool-bar has been disabled by the init files,
954 ;; and the frame needs to be resized.
955 (when (fboundp 'frame-notice-user-settings)
956 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
957 (assq 'tool-bar-lines default-frame-alist))))
958 (setq tool-bar-originally-present
959 (and tool-bar-lines
960 (cdr tool-bar-lines)
961 (not (eq 0 (cdr tool-bar-lines)))))))
963 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
964 (old-font-list-limit font-list-limit)
965 (old-face-ignored-fonts face-ignored-fonts))
967 ;; Run the site-start library if it exists. The point of this file is
968 ;; that it is run before .emacs. There is no point in doing this after
969 ;; .emacs; that is useless.
970 ;; Note that user-init-file is nil at this point. Code that might
971 ;; be loaded from site-run-file and wants to test if -q was given
972 ;; should check init-file-user instead, since that is already set.
973 ;; See cus-edit.el for an example.
974 (if site-run-file
975 (load site-run-file t t))
977 ;; Sites should not disable this. Only individuals should disable
978 ;; the startup screen.
979 (setq inhibit-startup-screen nil)
981 ;; Warn for invalid user name.
982 (when init-file-user
983 (if (string-match "[~/:\n]" init-file-user)
984 (display-warning 'initialization
985 (format "Invalid user name %s"
986 init-file-user)
987 :error)
988 (if (file-directory-p (expand-file-name
989 ;; We don't support ~USER on MS-Windows
990 ;; and MS-DOS except for the current
991 ;; user, and always load .emacs from
992 ;; the current user's home directory
993 ;; (see below). So always check "~",
994 ;; even if invoked with "-u USER", or
995 ;; if $USER or $LOGNAME are set to
996 ;; something different.
997 (if (memq system-type '(windows-nt ms-dos))
999 (concat "~" init-file-user))))
1001 (display-warning 'initialization
1002 (format "User %s has no home directory"
1003 init-file-user)
1004 :error))))
1006 ;; Load that user's init file, or the default one, or none.
1007 (let (debug-on-error-from-init-file
1008 debug-on-error-should-be-set
1009 (debug-on-error-initial
1010 (if (eq init-file-debug t) 'startup init-file-debug))
1011 (orig-enable-multibyte (default-value 'enable-multibyte-characters)))
1012 (let ((debug-on-error debug-on-error-initial)
1013 ;; This function actually reads the init files.
1014 (inner
1015 (function
1016 (lambda ()
1017 (if init-file-user
1018 (let ((user-init-file-1
1019 (cond
1020 ((eq system-type 'ms-dos)
1021 (concat "~" init-file-user "/_emacs"))
1022 ((not (eq system-type 'windows-nt))
1023 (concat "~" init-file-user "/.emacs"))
1024 ;; Else deal with the Windows situation
1025 ((directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
1026 ;; Prefer .emacs on Windows.
1027 "~/.emacs")
1028 ((directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
1029 ;; Also support _emacs for compatibility, but warn about it.
1030 (push '(initialization
1031 "`_emacs' init file is deprecated, please use `.emacs'")
1032 delayed-warnings-list)
1033 "~/_emacs")
1034 (t ;; But default to .emacs if _emacs does not exist.
1035 "~/.emacs"))))
1036 ;; This tells `load' to store the file name found
1037 ;; into user-init-file.
1038 (setq user-init-file t)
1039 (load user-init-file-1 t t)
1041 (when (eq user-init-file t)
1042 ;; If we did not find ~/.emacs, try
1043 ;; ~/.emacs.d/init.el.
1044 (let ((otherfile
1045 (expand-file-name
1046 "init"
1047 (file-name-as-directory
1048 (concat "~" init-file-user "/.emacs.d")))))
1049 (load otherfile t t)
1051 ;; If we did not find the user's init file,
1052 ;; set user-init-file conclusively.
1053 ;; Don't let it be set from default.el.
1054 (when (eq user-init-file t)
1055 (setq user-init-file user-init-file-1))))
1057 ;; If we loaded a compiled file, set
1058 ;; `user-init-file' to the source version if that
1059 ;; exists.
1060 (when (and user-init-file
1061 (equal (file-name-extension user-init-file)
1062 "elc"))
1063 (let* ((source (file-name-sans-extension user-init-file))
1064 (alt (concat source ".el")))
1065 (setq source (cond ((file-exists-p alt) alt)
1066 ((file-exists-p source) source)
1067 (t nil)))
1068 (when source
1069 (when (file-newer-than-file-p source user-init-file)
1070 (message "Warning: %s is newer than %s"
1071 source user-init-file)
1072 (sit-for 1))
1073 (setq user-init-file source))))
1075 (unless inhibit-default-init
1076 (let ((inhibit-startup-screen nil))
1077 ;; Users are supposed to be told their rights.
1078 ;; (Plus how to get help and how to undo.)
1079 ;; Don't you dare turn this off for anyone
1080 ;; except yourself.
1081 (load "default" t t)))))))))
1082 (if init-file-debug
1083 ;; Do this without a condition-case if the user wants to debug.
1084 (funcall inner)
1085 (condition-case error
1086 (progn
1087 (funcall inner)
1088 (setq init-file-had-error nil))
1089 (error
1090 (display-warning
1091 'initialization
1092 (format "An error occurred while loading `%s':\n\n%s%s%s\n\n\
1093 To ensure normal operation, you should investigate and remove the
1094 cause of the error in your initialization file. Start Emacs with
1095 the `--debug-init' option to view a complete error backtrace."
1096 user-init-file
1097 (get (car error) 'error-message)
1098 (if (cdr error) ": " "")
1099 (mapconcat (lambda (s) (prin1-to-string s t))
1100 (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-value 'enable-multibyte-characters)
1126 (eq orig-enable-multibyte (default-value
1127 'enable-multibyte-characters)))
1128 ;; Init file changed to unibyte. Reset existing multibyte
1129 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1130 ;; Arguably this should only be done if they're free of
1131 ;; multibyte characters.
1132 (mapc (lambda (buffer)
1133 (with-current-buffer buffer
1134 (if enable-multibyte-characters
1135 (set-buffer-multibyte nil))))
1136 (buffer-list))
1137 ;; Also re-set the language environment in case it was
1138 ;; originally done before unibyte was set and is sensitive to
1139 ;; unibyte (display table, terminal coding system &c).
1140 (set-language-environment current-language-environment)))
1142 ;; Do this here in case the init file sets mail-host-address.
1143 (if (equal user-mail-address "")
1144 (setq user-mail-address (or (getenv "EMAIL")
1145 (concat (user-login-name) "@"
1146 (or mail-host-address
1147 (system-name))))))
1149 ;; Originally face attributes were specified via
1150 ;; `font-lock-face-attributes'. Users then changed the default
1151 ;; face attributes by setting that variable. However, we try and
1152 ;; be back-compatible and respect its value if set except for
1153 ;; faces where M-x customize has been used to save changes for the
1154 ;; face.
1155 (when (boundp 'font-lock-face-attributes)
1156 (let ((face-attributes font-lock-face-attributes))
1157 (while face-attributes
1158 (let* ((face-attribute (pop face-attributes))
1159 (face (car face-attribute)))
1160 ;; Rustle up a `defface' SPEC from a
1161 ;; `font-lock-face-attributes' entry.
1162 (unless (get face 'saved-face)
1163 (let ((foreground (nth 1 face-attribute))
1164 (background (nth 2 face-attribute))
1165 (bold-p (nth 3 face-attribute))
1166 (italic-p (nth 4 face-attribute))
1167 (underline-p (nth 5 face-attribute))
1168 face-spec)
1169 (when foreground
1170 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1171 (when background
1172 (setq face-spec (cons ':background (cons background face-spec))))
1173 (when bold-p
1174 (setq face-spec (append '(:weight bold) face-spec)))
1175 (when italic-p
1176 (setq face-spec (append '(:slant italic) face-spec)))
1177 (when underline-p
1178 (setq face-spec (append '(:underline t) face-spec)))
1179 (face-spec-set face (list (list t face-spec)) nil)))))))
1181 ;; If parameter have been changed in the init file which influence
1182 ;; face realization, clear the face cache so that new faces will
1183 ;; be realized.
1184 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1185 (eq font-list-limit old-font-list-limit)
1186 (eq face-ignored-fonts old-face-ignored-fonts))
1187 (clear-face-cache)))
1189 ;; If any package directory exists, initialize the package system.
1190 (and user-init-file
1191 package-enable-at-startup
1192 (catch 'package-dir-found
1193 (let (dirs)
1194 (if (boundp 'package-directory-list)
1195 (setq dirs package-directory-list)
1196 (dolist (f load-path)
1197 (and (stringp f)
1198 (equal (file-name-nondirectory f) "site-lisp")
1199 (push (expand-file-name "elpa" f) dirs))))
1200 (push (if (boundp 'package-user-dir)
1201 package-user-dir
1202 (locate-user-emacs-file "elpa"))
1203 dirs)
1204 (dolist (dir dirs)
1205 (when (file-directory-p dir)
1206 (dolist (subdir (directory-files dir))
1207 (when (and (file-directory-p (expand-file-name subdir dir))
1208 (string-match
1209 (concat "\\`" package-subdirectory-regexp "\\'")
1210 subdir))
1211 (throw 'package-dir-found t)))))))
1212 (package-initialize))
1214 (setq after-init-time (current-time))
1215 (run-hooks 'after-init-hook)
1217 ;; Decode all default-directory.
1218 (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
1219 (save-excursion
1220 (dolist (elt (buffer-list))
1221 (set-buffer elt)
1222 (if default-directory
1223 (setq default-directory
1224 (decode-coding-string default-directory
1225 locale-coding-system t))))
1226 (setq command-line-default-directory
1227 (decode-coding-string command-line-default-directory
1228 locale-coding-system t))))
1230 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1231 (if (get-buffer "*scratch*")
1232 (with-current-buffer "*scratch*"
1233 (if (eq major-mode 'fundamental-mode)
1234 (funcall initial-major-mode))))
1236 ;; Load library for our terminal type.
1237 ;; User init file can set term-file-prefix to nil to prevent this.
1238 (unless (or noninteractive
1239 initial-window-system)
1240 (tty-run-terminal-initialization (selected-frame)))
1242 ;; Update the out-of-memory error message based on user's key bindings
1243 ;; for save-some-buffers.
1244 (setq memory-signal-data
1245 (list 'error
1246 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1248 ;; Process the remaining args.
1249 (command-line-1 (cdr command-line-args))
1251 ;; If -batch, terminate after processing the command options.
1252 (if noninteractive (kill-emacs t))
1254 ;; In daemon mode, start the server to allow clients to connect.
1255 ;; This is done after loading the user's init file and after
1256 ;; processing all command line arguments to allow e.g. `server-name'
1257 ;; to be changed before the server starts.
1258 (let ((dn (daemonp)))
1259 (when dn
1260 (when (stringp dn) (setq server-name dn))
1261 (server-start)
1262 (if server-process
1263 (daemon-initialized)
1264 (if (stringp dn)
1265 (message
1266 "Unable to start daemon: Emacs server named %S already running"
1267 server-name)
1268 (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."))
1269 (kill-emacs 1))))
1271 ;; Run emacs-session-restore (session management) if started by
1272 ;; the session manager and we have a session manager connection.
1273 (if (and (boundp 'x-session-previous-id)
1274 (stringp x-session-previous-id))
1275 (with-no-warnings
1276 (emacs-session-restore x-session-previous-id))))
1278 (defcustom initial-scratch-message (purecopy "\
1279 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1280 ;; If you want to create a file, visit that file with C-x C-f,
1281 ;; then enter the text in that file's own buffer.
1284 "Initial message displayed in *scratch* buffer at startup.
1285 If this is nil, no message will be displayed."
1286 :type '(choice (text :tag "Message")
1287 (const :tag "none" nil))
1288 :group 'initialization)
1291 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1292 ;;; Fancy splash screen
1293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1295 (defconst fancy-startup-text
1296 `((:face (variable-pitch font-lock-comment-face)
1297 "Welcome to "
1298 :link ("GNU Emacs"
1299 ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
1300 "Browse http://www.gnu.org/software/emacs/")
1301 ", one component of the "
1302 :link
1303 ,(lambda ()
1304 (if (eq system-type 'gnu/linux)
1305 `("GNU/Linux"
1306 ,(lambda (_button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1307 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1308 `("GNU" ,(lambda (_button) (describe-gnu-project))
1309 "Display info on the GNU project")))
1310 " operating system.\n\n"
1311 :face variable-pitch
1312 :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
1313 "\tLearn basic keystroke commands"
1314 ,(lambda ()
1315 (let* ((en "TUTORIAL")
1316 (tut (or (get-language-info current-language-environment
1317 'tutorial)
1318 en))
1319 (title (with-temp-buffer
1320 (insert-file-contents
1321 (expand-file-name tut tutorial-directory)
1322 nil 0 256)
1323 (search-forward ".")
1324 (buffer-substring (point-min) (1- (point))))))
1325 ;; If there is a specific tutorial for the current language
1326 ;; environment and it is not English, append its title.
1327 (if (string= en tut)
1329 (concat " (" title ")"))))
1330 "\n"
1331 :link ("Emacs Guided Tour"
1332 ,(lambda (_button)
1333 (browse-url "http://www.gnu.org/software/emacs/tour/"))
1334 "Browse http://www.gnu.org/software/emacs/tour/")
1335 "\tOverview of Emacs features at gnu.org\n"
1336 :link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual)))
1337 "\tView the Emacs manual using Info\n"
1338 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
1339 "\tGNU Emacs comes with "
1340 :face (variable-pitch (:slant oblique))
1341 "ABSOLUTELY NO WARRANTY\n"
1342 :face variable-pitch
1343 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
1344 "\tConditions for redistributing and changing Emacs\n"
1345 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
1346 "\tPurchasing printed copies of manuals\n"
1347 "\n"))
1348 "A list of texts to show in the middle part of splash screens.
1349 Each element in the list should be a list of strings or pairs
1350 `:face FACE', like `fancy-splash-insert' accepts them.")
1352 (defconst fancy-about-text
1353 `((:face (variable-pitch font-lock-comment-face)
1354 "This is "
1355 :link ("GNU Emacs"
1356 ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
1357 "Browse http://www.gnu.org/software/emacs/")
1358 ", one component of the "
1359 :link
1360 ,(lambda ()
1361 (if (eq system-type 'gnu/linux)
1362 `("GNU/Linux"
1363 ,(lambda (_button)
1364 (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1365 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1366 `("GNU" ,(lambda (_button) (describe-gnu-project))
1367 "Display info on the GNU project.")))
1368 " operating system.\n"
1369 :face (variable-pitch font-lock-builtin-face)
1370 "\n"
1371 ,(lambda () (emacs-version))
1372 "\n"
1373 :face (variable-pitch (:height 0.8))
1374 ,(lambda () emacs-copyright)
1375 "\n\n"
1376 :face variable-pitch
1377 :link ("Authors"
1378 ,(lambda (_button)
1379 (view-file (expand-file-name "AUTHORS" data-directory))
1380 (goto-char (point-min))))
1381 "\tMany people have contributed code included in GNU Emacs\n"
1382 :link ("Contributing"
1383 ,(lambda (_button)
1384 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1385 (goto-char (point-min))))
1386 "\tHow to contribute improvements to Emacs\n"
1387 "\n"
1388 :link ("GNU and Freedom" ,(lambda (_button) (describe-gnu-project)))
1389 "\tWhy we developed GNU Emacs, and the GNU operating system\n"
1390 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
1391 "\tGNU Emacs comes with "
1392 :face (variable-pitch (:slant oblique))
1393 "ABSOLUTELY NO WARRANTY\n"
1394 :face variable-pitch
1395 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
1396 "\tConditions for redistributing and changing Emacs\n"
1397 :link ("Getting New Versions" ,(lambda (_button) (describe-distribution)))
1398 "\tHow to obtain the latest version of Emacs\n"
1399 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
1400 "\tBuying printed manuals from the FSF\n"
1401 "\n"
1402 :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
1403 "\tLearn basic Emacs keystroke commands"
1404 ,(lambda ()
1405 (let* ((en "TUTORIAL")
1406 (tut (or (get-language-info current-language-environment
1407 'tutorial)
1408 en))
1409 (title (with-temp-buffer
1410 (insert-file-contents
1411 (expand-file-name tut tutorial-directory)
1412 nil 0 256)
1413 (search-forward ".")
1414 (buffer-substring (point-min) (1- (point))))))
1415 ;; If there is a specific tutorial for the current language
1416 ;; environment and it is not English, append its title.
1417 (if (string= en tut)
1419 (concat " (" title ")"))))
1420 "\n"
1421 :link ("Emacs Guided Tour"
1422 ,(lambda (_button)
1423 (browse-url "http://www.gnu.org/software/emacs/tour/"))
1424 "Browse http://www.gnu.org/software/emacs/tour/")
1425 "\tSee an overview of Emacs features at gnu.org"))
1426 "A list of texts to show in the middle part of the About screen.
1427 Each element in the list should be a list of strings or pairs
1428 `:face FACE', like `fancy-splash-insert' accepts them.")
1431 (defgroup fancy-splash-screen ()
1432 "Fancy splash screen when Emacs starts."
1433 :version "21.1"
1434 :group 'initialization)
1436 (defcustom fancy-splash-image nil
1437 "The image to show in the splash screens, or nil for defaults."
1438 :group 'fancy-splash-screen
1439 :type '(choice (const :tag "Default" nil)
1440 (file :tag "File")))
1443 (defvar splash-screen-keymap
1444 (let ((map (make-sparse-keymap)))
1445 (suppress-keymap map)
1446 (set-keymap-parent map button-buffer-map)
1447 (define-key map "\C-?" 'scroll-down)
1448 (define-key map " " 'scroll-up)
1449 (define-key map "q" 'exit-splash-screen)
1450 map)
1451 "Keymap for splash screen buffer.")
1453 ;; These are temporary storage areas for the splash screen display.
1455 (defun fancy-splash-insert (&rest args)
1456 "Insert text into the current buffer, with faces.
1457 Arguments from ARGS should be either strings; functions called
1458 with no args that return a string; pairs `:face FACE', where FACE
1459 is a face specification usable with `put-text-property'; or pairs
1460 `:link LINK' where LINK is a list of arguments to pass to
1461 `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which
1462 specifies the button's label, `action' property and help-echo string.
1463 FACE and LINK can also be functions, which are evaluated to obtain
1464 a face or button specification."
1465 (let ((current-face nil))
1466 (while args
1467 (cond ((eq (car args) :face)
1468 (setq args (cdr args) current-face (car args))
1469 (if (functionp current-face)
1470 (setq current-face (funcall current-face))))
1471 ((eq (car args) :link)
1472 (setq args (cdr args))
1473 (let ((spec (car args)))
1474 (if (functionp spec)
1475 (setq spec (funcall spec)))
1476 (insert-button (car spec)
1477 'face (list 'link current-face)
1478 'action (cadr spec)
1479 'help-echo (concat "mouse-2, RET: "
1480 (or (nth 2 spec)
1481 "Follow this link"))
1482 'follow-link t)))
1483 (t (insert (propertize (let ((it (car args)))
1484 (if (functionp it)
1485 (funcall it)
1486 it))
1487 'face current-face
1488 'help-echo (startup-echo-area-message)))))
1489 (setq args (cdr args)))))
1491 (declare-function image-size "image.c" (spec &optional pixels frame))
1493 (defun fancy-splash-head ()
1494 "Insert the head part of the splash screen into the current buffer."
1495 (let* ((image-file (cond ((stringp fancy-splash-image)
1496 fancy-splash-image)
1497 ((display-color-p)
1498 (cond ((<= (display-planes) 8)
1499 (if (image-type-available-p 'xpm)
1500 "splash.xpm"
1501 "splash.pbm"))
1502 ((image-type-available-p 'svg)
1503 "splash.svg")
1504 ((image-type-available-p 'png)
1505 "splash.png")
1506 ((image-type-available-p 'xpm)
1507 "splash.xpm")
1508 (t "splash.pbm")))
1509 (t "splash.pbm")))
1510 (img (create-image image-file))
1511 (image-width (and img (car (image-size img))))
1512 (window-width (window-width (selected-window))))
1513 (when img
1514 (when (> window-width image-width)
1515 ;; Center the image in the window.
1516 (insert (propertize " " 'display
1517 `(space :align-to (+ center (-0.5 . ,img)))))
1519 ;; Change the color of the XPM version of the splash image
1520 ;; so that it is visible with a dark frame background.
1521 (when (and (memq 'xpm img)
1522 (eq (frame-parameter nil 'background-mode) 'dark))
1523 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1525 ;; Insert the image with a help-echo and a link.
1526 (make-button (prog1 (point) (insert-image img)) (point)
1527 'face 'default
1528 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
1529 'action (lambda (_button) (browse-url "http://www.gnu.org/"))
1530 'follow-link t)
1531 (insert "\n\n")))))
1533 (defun fancy-startup-tail (&optional concise)
1534 "Insert the tail part of the splash screen into the current buffer."
1535 (unless concise
1536 (fancy-splash-insert
1537 :face 'variable-pitch
1538 "\nTo start... "
1539 :link `("Open a File"
1540 ,(lambda (_button) (call-interactively 'find-file))
1541 "Specify a new file's name, to edit the file")
1543 :link `("Open Home Directory"
1544 ,(lambda (_button) (dired "~"))
1545 "Open your home directory, to operate on its files")
1547 :link `("Customize Startup"
1548 ,(lambda (_button) (customize-group 'initialization))
1549 "Change initialization settings including this screen")
1550 "\n"))
1551 (fancy-splash-insert
1552 :face 'variable-pitch "To quit a partially entered command, type "
1553 :face 'default "Control-g"
1554 :face 'variable-pitch ".\n")
1555 (fancy-splash-insert :face `(variable-pitch font-lock-builtin-face)
1556 "\nThis is "
1557 (emacs-version)
1558 "\n"
1559 :face '(variable-pitch (:height 0.8))
1560 emacs-copyright
1561 "\n")
1562 (and auto-save-list-file-prefix
1563 ;; Don't signal an error if the
1564 ;; directory for auto-save-list files
1565 ;; does not yet exist.
1566 (file-directory-p (file-name-directory
1567 auto-save-list-file-prefix))
1568 (directory-files
1569 (file-name-directory auto-save-list-file-prefix)
1571 (concat "\\`"
1572 (regexp-quote (file-name-nondirectory
1573 auto-save-list-file-prefix)))
1575 (fancy-splash-insert :face '(variable-pitch font-lock-comment-face)
1576 "\nIf an Emacs session crashed recently, "
1577 "type "
1578 :face '(fixed-pitch font-lock-comment-face)
1579 "Meta-x recover-session RET"
1580 :face '(variable-pitch font-lock-comment-face)
1581 "\nto recover"
1582 " the files you were editing."))
1584 (when concise
1585 (fancy-splash-insert
1586 :face 'variable-pitch "\n"
1587 :link `("Dismiss this startup screen"
1588 ,(lambda (_button)
1589 (when startup-screen-inhibit-startup-screen
1590 (customize-set-variable 'inhibit-startup-screen t)
1591 (customize-mark-to-save 'inhibit-startup-screen)
1592 (custom-save-all))
1593 (let ((w (get-buffer-window "*GNU Emacs*")))
1594 (and w (not (one-window-p)) (delete-window w)))
1595 (kill-buffer "*GNU Emacs*")))
1596 " ")
1597 (when (or user-init-file custom-file)
1598 (let ((checked (create-image "checked.xpm"
1599 nil nil :ascent 'center))
1600 (unchecked (create-image "unchecked.xpm"
1601 nil nil :ascent 'center)))
1602 (insert-button
1604 :on-glyph checked
1605 :off-glyph unchecked
1606 'checked nil 'display unchecked 'follow-link t
1607 'action (lambda (button)
1608 (if (overlay-get button 'checked)
1609 (progn (overlay-put button 'checked nil)
1610 (overlay-put button 'display
1611 (overlay-get button :off-glyph))
1612 (setq startup-screen-inhibit-startup-screen
1613 nil))
1614 (overlay-put button 'checked t)
1615 (overlay-put button 'display
1616 (overlay-get button :on-glyph))
1617 (setq startup-screen-inhibit-startup-screen t)))))
1618 (fancy-splash-insert :face '(variable-pitch (:height 0.9))
1619 " Never show it again."))))
1621 (defun exit-splash-screen ()
1622 "Stop displaying the splash screen buffer."
1623 (interactive)
1624 (quit-window t))
1626 (defun fancy-startup-screen (&optional concise)
1627 "Display fancy startup screen.
1628 If CONCISE is non-nil, display a concise version of the
1629 splash screen in another window."
1630 (let ((splash-buffer (get-buffer-create "*GNU Emacs*")))
1631 (with-current-buffer splash-buffer
1632 (let ((inhibit-read-only t))
1633 (erase-buffer)
1634 (setq default-directory command-line-default-directory)
1635 (make-local-variable 'startup-screen-inhibit-startup-screen)
1636 (if pure-space-overflow
1637 (insert pure-space-overflow-message))
1638 (unless concise
1639 (fancy-splash-head))
1640 (dolist (text fancy-startup-text)
1641 (apply #'fancy-splash-insert text)
1642 (insert "\n"))
1643 (skip-chars-backward "\n")
1644 (delete-region (point) (point-max))
1645 (insert "\n")
1646 (fancy-startup-tail concise))
1647 (use-local-map splash-screen-keymap)
1648 (setq tab-width 22
1649 buffer-read-only t)
1650 (set-buffer-modified-p nil)
1651 (if (and view-read-only (not view-mode))
1652 (view-mode-enter nil 'kill-buffer))
1653 (goto-char (point-min))
1654 (forward-line (if concise 2 4)))
1655 (if concise
1656 (progn
1657 (display-buffer splash-buffer)
1658 ;; If the splash screen is in a split window, fit it.
1659 (let ((window (get-buffer-window splash-buffer t)))
1660 (or (null window)
1661 (eq window (selected-window))
1662 (eq window (next-window window))
1663 (fit-window-to-buffer window))))
1664 (switch-to-buffer splash-buffer))))
1666 (defun fancy-about-screen ()
1667 "Display fancy About screen."
1668 (let ((frame (fancy-splash-frame)))
1669 (save-selected-window
1670 (select-frame frame)
1671 (switch-to-buffer "*About GNU Emacs*")
1672 (setq buffer-undo-list t)
1673 (let ((inhibit-read-only t))
1674 (erase-buffer)
1675 (if pure-space-overflow
1676 (insert pure-space-overflow-message))
1677 (fancy-splash-head)
1678 (dolist (text fancy-about-text)
1679 (apply #'fancy-splash-insert text)
1680 (insert "\n"))
1681 (set-buffer-modified-p nil)
1682 (goto-char (point-min))
1683 (force-mode-line-update))
1684 (use-local-map splash-screen-keymap)
1685 (setq tab-width 22)
1686 (message "%s" (startup-echo-area-message))
1687 (setq buffer-read-only t)
1688 (goto-char (point-min))
1689 (forward-line 3))))
1691 (defun fancy-splash-frame ()
1692 "Return the frame to use for the fancy splash screen.
1693 Returning non-nil does not mean we should necessarily
1694 use the fancy splash screen, but if we do use it,
1695 we put it on this frame."
1696 (let (chosen-frame)
1697 (dolist (frame (append (frame-list) (list (selected-frame))))
1698 (if (and (frame-visible-p frame)
1699 (not (window-minibuffer-p (frame-selected-window frame))))
1700 (setq chosen-frame frame)))
1701 chosen-frame))
1703 (defun use-fancy-splash-screens-p ()
1704 "Return t if fancy splash screens should be used."
1705 (when (and (display-graphic-p)
1706 (or (and (display-color-p)
1707 (image-type-available-p 'xpm))
1708 (image-type-available-p 'pbm)))
1709 (let ((frame (fancy-splash-frame)))
1710 (when frame
1711 (let* ((img (create-image (or fancy-splash-image
1712 (if (and (display-color-p)
1713 (image-type-available-p 'xpm))
1714 "splash.xpm" "splash.pbm"))))
1715 (image-height (and img (cdr (image-size img nil frame))))
1716 ;; We test frame-height so that, if the frame is split
1717 ;; by displaying a warning, that doesn't cause the normal
1718 ;; splash screen to be used.
1719 (frame-height (1- (frame-height frame))))
1720 (> frame-height (+ image-height 19)))))))
1723 (defun normal-splash-screen (&optional startup concise)
1724 "Display non-graphic splash screen.
1725 If optional argument STARTUP is non-nil, display the startup screen
1726 after Emacs starts. If STARTUP is nil, display the About screen.
1727 If CONCISE is non-nil, display a concise version of the
1728 splash screen in another window."
1729 (let ((splash-buffer (get-buffer-create "*About GNU Emacs*")))
1730 (with-current-buffer splash-buffer
1731 (setq buffer-read-only nil)
1732 (erase-buffer)
1733 (setq default-directory command-line-default-directory)
1734 (set (make-local-variable 'tab-width) 8)
1736 (if pure-space-overflow
1737 (insert pure-space-overflow-message))
1739 ;; The convention for this piece of code is that
1740 ;; each piece of output starts with one or two newlines
1741 ;; and does not end with any newlines.
1742 (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs"))
1743 (insert
1744 (if (eq system-type 'gnu/linux)
1745 ", one component of the GNU/Linux operating system.\n"
1746 ", a part of the GNU operating system.\n"))
1748 (if startup
1749 (if (display-mouse-p)
1750 ;; The user can use the mouse to activate menus
1751 ;; so give help in terms of menu items.
1752 (normal-mouse-startup-screen)
1754 ;; No mouse menus, so give help using kbd commands.
1755 (normal-no-mouse-startup-screen))
1757 (normal-about-screen))
1759 ;; The rest of the startup screen is the same on all
1760 ;; kinds of terminals.
1762 ;; Give information on recovering, if there was a crash.
1763 (and startup
1764 auto-save-list-file-prefix
1765 ;; Don't signal an error if the
1766 ;; directory for auto-save-list files
1767 ;; does not yet exist.
1768 (file-directory-p (file-name-directory
1769 auto-save-list-file-prefix))
1770 (directory-files
1771 (file-name-directory auto-save-list-file-prefix)
1773 (concat "\\`"
1774 (regexp-quote (file-name-nondirectory
1775 auto-save-list-file-prefix)))
1777 (insert "\n\nIf an Emacs session crashed recently, "
1778 "type Meta-x recover-session RET\nto recover"
1779 " the files you were editing.\n"))
1781 (use-local-map splash-screen-keymap)
1783 ;; Display the input that we set up in the buffer.
1784 (set-buffer-modified-p nil)
1785 (setq buffer-read-only t)
1786 (if (and view-read-only (not view-mode))
1787 (view-mode-enter nil 'kill-buffer))
1788 (if startup (rename-buffer "*GNU Emacs*" t))
1789 (goto-char (point-min)))
1790 (if concise
1791 (display-buffer splash-buffer)
1792 (switch-to-buffer splash-buffer))))
1794 (defun normal-mouse-startup-screen ()
1795 ;; The user can use the mouse to activate menus
1796 ;; so give help in terms of menu items.
1797 (insert "\
1798 To follow a link, click Mouse-1 on it, or move to it and type RET.
1799 To quit a partially entered command, type Control-g.\n")
1801 (insert "\nImportant Help menu items:\n")
1802 (insert-button "Emacs Tutorial"
1803 'action (lambda (_button) (help-with-tutorial))
1804 'follow-link t)
1805 (insert "\t\tLearn basic Emacs keystroke commands\n")
1806 (insert-button "Read the Emacs Manual"
1807 'action (lambda (_button) (info-emacs-manual))
1808 'follow-link t)
1809 (insert "\tView the Emacs manual using Info\n")
1810 (insert-button "\(Non)Warranty"
1811 'action (lambda (_button) (describe-no-warranty))
1812 'follow-link t)
1813 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1814 (insert-button "Copying Conditions"
1815 'action (lambda (_button) (describe-copying))
1816 'follow-link t)
1817 (insert "\tConditions for redistributing and changing Emacs\n")
1818 (insert-button "More Manuals / Ordering Manuals"
1819 'action (lambda (_button) (view-order-manuals))
1820 'follow-link t)
1821 (insert " How to order printed manuals from the FSF\n")
1823 (insert "\nUseful tasks:\n")
1824 (insert-button "Visit New File"
1825 'action (lambda (_button) (call-interactively 'find-file))
1826 'follow-link t)
1827 (insert "\t\tSpecify a new file's name, to edit the file\n")
1828 (insert-button "Open Home Directory"
1829 'action (lambda (_button) (dired "~"))
1830 'follow-link t)
1831 (insert "\tOpen your home directory, to operate on its files\n")
1832 (insert-button "Customize Startup"
1833 'action (lambda (_button) (customize-group 'initialization))
1834 'follow-link t)
1835 (insert "\tChange initialization settings including this screen\n")
1837 (insert "\n" (emacs-version)
1838 "\n" emacs-copyright))
1840 ;; No mouse menus, so give help using kbd commands.
1841 (defun normal-no-mouse-startup-screen ()
1843 ;; If keys have their default meanings,
1844 ;; use precomputed string to save lots of time.
1845 (let* ((c-h-accessible
1846 ;; If normal-erase-is-backspace is used on a tty, there's
1847 ;; no way to invoke C-h and you have to use F1 instead.
1848 (or (not (char-table-p keyboard-translate-table))
1849 (eq (aref keyboard-translate-table ?\C-h) ?\C-h)))
1850 (minor-mode-overriding-map-alist
1851 (cons (cons (not c-h-accessible)
1852 ;; If C-h can't be invoked, temporarily disable its
1853 ;; binding, so where-is uses alternative bindings.
1854 (let ((map (make-sparse-keymap)))
1855 (define-key map [?\C-h] 'undefined)
1856 map))
1857 minor-mode-overriding-map-alist)))
1859 (insert (format "\nGet help\t %s\n"
1860 (let ((where (where-is-internal 'help-command nil t)))
1861 (cond
1862 ((equal where [?\C-h])
1863 "C-h (Hold down CTRL and press h)")
1864 (where (key-description where))
1865 (t "M-x help")))))
1866 (insert-button "Emacs manual"
1867 'action (lambda (_button) (info-emacs-manual))
1868 'follow-link t)
1869 (insert (substitute-command-keys"\t \\[info-emacs-manual]\t"))
1870 (insert-button "Browse manuals"
1871 'action (lambda (_button) (Info-directory))
1872 'follow-link t)
1873 (insert (substitute-command-keys "\t \\[info]\n"))
1874 (insert-button "Emacs tutorial"
1875 'action (lambda (_button) (help-with-tutorial))
1876 'follow-link t)
1877 (insert (substitute-command-keys
1878 "\t \\[help-with-tutorial]\tUndo changes\t \\[undo]\n"))
1879 (insert-button "Buy manuals"
1880 'action (lambda (_button) (view-order-manuals))
1881 'follow-link t)
1882 (insert (substitute-command-keys
1883 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
1885 ;; Say how to use the menu bar with the keyboard.
1886 (insert "\n")
1887 (insert-button "Activate menubar"
1888 'action (lambda (_button) (tmm-menubar))
1889 'follow-link t)
1890 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1891 (eq (key-binding [f10]) 'tmm-menubar))
1892 (insert " F10 or ESC ` or M-`")
1893 (insert (substitute-command-keys " \\[tmm-menubar]")))
1895 ;; Many users seem to have problems with these.
1896 (insert "
1897 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1898 If you have no Meta key, you may instead type ESC followed by the character.)")
1900 ;; Insert links to useful tasks
1901 (insert "\nUseful tasks:\n")
1903 (insert-button "Visit New File"
1904 'action (lambda (_button) (call-interactively 'find-file))
1905 'follow-link t)
1906 (insert "\t\t\t")
1907 (insert-button "Open Home Directory"
1908 'action (lambda (_button) (dired "~"))
1909 'follow-link t)
1910 (insert "\n")
1912 (insert-button "Customize Startup"
1913 'action (lambda (_button) (customize-group 'initialization))
1914 'follow-link t)
1915 (insert "\t\t")
1916 (insert-button "Open *scratch* buffer"
1917 'action (lambda (_button) (switch-to-buffer
1918 (get-buffer-create "*scratch*")))
1919 'follow-link t)
1920 (insert "\n")
1921 (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
1923 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1924 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1925 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1926 (progn
1927 (insert
1929 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1930 (insert-button "full details"
1931 'action (lambda (_button) (describe-no-warranty))
1932 'follow-link t)
1933 (insert ".
1934 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1935 of Emacs and modify it; type C-h C-c to see ")
1936 (insert-button "the conditions"
1937 'action (lambda (_button) (describe-copying))
1938 'follow-link t)
1939 (insert ".
1940 Type C-h C-d for information on ")
1941 (insert-button "getting the latest version"
1942 'action (lambda (_button) (describe-distribution))
1943 'follow-link t)
1944 (insert "."))
1945 (insert (substitute-command-keys
1947 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1948 (insert-button "full details"
1949 'action (lambda (_button) (describe-no-warranty))
1950 'follow-link t)
1951 (insert (substitute-command-keys ".
1952 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1953 of Emacs and modify it; type \\[describe-copying] to see "))
1954 (insert-button "the conditions"
1955 'action (lambda (_button) (describe-copying))
1956 'follow-link t)
1957 (insert (substitute-command-keys".
1958 Type \\[describe-distribution] for information on "))
1959 (insert-button "getting the latest version"
1960 'action (lambda (_button) (describe-distribution))
1961 'follow-link t)
1962 (insert ".")))
1964 (defun normal-about-screen ()
1965 (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n")
1967 (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n")
1969 (insert-button "Authors"
1970 'action
1971 (lambda (_button)
1972 (view-file (expand-file-name "AUTHORS" data-directory))
1973 (goto-char (point-min)))
1974 'follow-link t)
1975 (insert "\t\tMany people have contributed code included in GNU Emacs\n")
1977 (insert-button "Contributing"
1978 'action
1979 (lambda (_button)
1980 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1981 (goto-char (point-min)))
1982 'follow-link t)
1983 (insert "\tHow to contribute improvements to Emacs\n\n")
1985 (insert-button "GNU and Freedom"
1986 'action (lambda (_button) (describe-gnu-project))
1987 'follow-link t)
1988 (insert "\t\tWhy we developed GNU Emacs and the GNU system\n")
1990 (insert-button "Absence of Warranty"
1991 'action (lambda (_button) (describe-no-warranty))
1992 'follow-link t)
1993 (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1995 (insert-button "Copying Conditions"
1996 'action (lambda (_button) (describe-copying))
1997 'follow-link t)
1998 (insert "\tConditions for redistributing and changing Emacs\n")
2000 (insert-button "Getting New Versions"
2001 'action (lambda (_button) (describe-distribution))
2002 'follow-link t)
2003 (insert "\tHow to get the latest version of GNU Emacs\n")
2005 (insert-button "More Manuals / Ordering Manuals"
2006 'action (lambda (_button) (view-order-manuals))
2007 'follow-link t)
2008 (insert "\tBuying printed manuals from the FSF\n"))
2010 (defun startup-echo-area-message ()
2011 (cond ((daemonp)
2012 "Starting Emacs daemon.")
2013 ((eq (key-binding "\C-h\C-a") 'about-emacs)
2014 "For information about GNU Emacs and the GNU system, type C-h C-a.")
2016 (substitute-command-keys
2017 "For information about GNU Emacs and the GNU system, type \
2018 \\[about-emacs]."))))
2020 (defun display-startup-echo-area-message ()
2021 (let ((resize-mini-windows t))
2022 (or noninteractive ;(input-pending-p) init-file-had-error
2023 ;; t if the init file says to inhibit the echo area startup message.
2024 (and inhibit-startup-echo-area-message
2025 user-init-file
2026 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
2027 (equal inhibit-startup-echo-area-message
2028 (if (equal init-file-user "")
2029 (user-login-name)
2030 init-file-user)))
2031 ;; Wasn't set with custom; see if .emacs has a setq.
2032 (condition-case nil
2033 (with-temp-buffer
2034 (insert-file-contents user-init-file)
2035 (re-search-forward
2036 (concat
2037 "([ \t\n]*setq[ \t\n]+"
2038 "inhibit-startup-echo-area-message[ \t\n]+"
2039 (regexp-quote
2040 (prin1-to-string
2041 (if (equal init-file-user "")
2042 (user-login-name)
2043 init-file-user)))
2044 "[ \t\n]*)")
2045 nil t))
2046 (error nil))))
2047 (message "%s" (startup-echo-area-message)))))
2049 (defun display-startup-screen (&optional concise)
2050 "Display startup screen according to display.
2051 A fancy display is used on graphic displays, normal otherwise.
2053 If CONCISE is non-nil, display a concise version of the startup
2054 screen."
2055 ;; Prevent recursive calls from server-process-filter.
2056 (if (not (get-buffer "*GNU Emacs*"))
2057 (if (use-fancy-splash-screens-p)
2058 (fancy-startup-screen concise)
2059 (normal-splash-screen t concise))))
2061 (defun display-about-screen ()
2062 "Display the *About GNU Emacs* buffer.
2063 A fancy display is used on graphic displays, normal otherwise."
2064 (interactive)
2065 (if (use-fancy-splash-screens-p)
2066 (fancy-about-screen)
2067 (normal-splash-screen nil)))
2069 (defalias 'about-emacs 'display-about-screen)
2070 (defalias 'display-splash-screen 'display-startup-screen)
2072 (defun command-line-1 (args-left)
2073 (display-startup-echo-area-message)
2074 (when (and pure-space-overflow
2075 (not noninteractive))
2076 (display-warning
2077 'initialization
2078 "Building Emacs overflowed pure space.\
2079 (See the node Pure Storage in the Lisp manual for details.)"
2080 :warning))
2082 (let ((file-count 0)
2083 (command-line-args-left args-left)
2084 first-file-buffer)
2085 (when command-line-args-left
2086 ;; We have command args; process them.
2087 (let ((dir command-line-default-directory)
2089 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
2090 ;; if foo is intended to be found in DIR.
2092 ;; ;; The directories listed in --directory/-L options will *appear*
2093 ;; ;; at the front of `load-path' in the order they appear on the
2094 ;; ;; command-line. We cannot do this by *placing* them at the front
2095 ;; ;; in the order they appear, so we need this variable to hold them,
2096 ;; ;; temporarily.
2097 ;; extra-load-path
2099 ;; To DTRT we keep track of the splice point and modify `load-path'
2100 ;; straight away upon any --directory/-L option.
2101 splice
2102 just-files ;; t if this follows the magic -- option.
2103 ;; This includes our standard options' long versions
2104 ;; and long versions of what's on command-switch-alist.
2105 (longopts
2106 (append '("--funcall" "--load" "--insert" "--kill"
2107 "--directory" "--eval" "--execute" "--no-splash"
2108 "--find-file" "--visit" "--file" "--no-desktop")
2109 (mapcar (lambda (elt) (concat "-" (car elt)))
2110 command-switch-alist)))
2111 (line 0)
2112 (column 0))
2114 ;; Add the long X options to longopts.
2115 (dolist (tem command-line-x-option-alist)
2116 (if (string-match "^--" (car tem))
2117 (push (car tem) longopts)))
2119 ;; Add the long NS options to longopts.
2120 (dolist (tem command-line-ns-option-alist)
2121 (if (string-match "^--" (car tem))
2122 (push (list (car tem)) longopts)))
2124 ;; Loop, processing options.
2125 (while command-line-args-left
2126 (let* ((argi (car command-line-args-left))
2127 (orig-argi argi)
2128 argval completion)
2129 (setq command-line-args-left (cdr command-line-args-left))
2131 ;; Do preliminary decoding of the option.
2132 (if just-files
2133 ;; After --, don't look for options; treat all args as files.
2134 (setq argi "")
2135 ;; Convert long options to ordinary options
2136 ;; and separate out an attached option argument into argval.
2137 (when (string-match "\\`\\(--[^=]*\\)=" argi)
2138 (setq argval (substring argi (match-end 0))
2139 argi (match-string 1 argi)))
2140 (when (string-match "\\`--?[^-]" orig-argi)
2141 (setq completion (try-completion argi longopts))
2142 (if (eq completion t)
2143 (setq argi (substring argi 1))
2144 (if (stringp completion)
2145 (let ((elt (member completion longopts)))
2146 (or elt
2147 (error "Option `%s' is ambiguous" argi))
2148 (setq argi (substring (car elt) 1)))
2149 (setq argval nil
2150 argi orig-argi)))))
2152 ;; Execute the option.
2153 (cond ((setq tem (assoc argi command-switch-alist))
2154 (if argval
2155 (let ((command-line-args-left
2156 (cons argval command-line-args-left)))
2157 (funcall (cdr tem) argi))
2158 (funcall (cdr tem) argi)))
2160 ((equal argi "-no-splash")
2161 (setq inhibit-startup-screen t))
2163 ((member argi '("-f" ; what the manual claims
2164 "-funcall"
2165 "-e")) ; what the source used to say
2166 (setq inhibit-startup-screen t)
2167 (setq tem (intern (or argval (pop command-line-args-left))))
2168 (if (commandp tem)
2169 (command-execute tem)
2170 (funcall tem)))
2172 ((member argi '("-eval" "-execute"))
2173 (setq inhibit-startup-screen t)
2174 (eval (read (or argval (pop command-line-args-left)))))
2176 ((member argi '("-L" "-directory"))
2177 (setq tem (expand-file-name
2178 (command-line-normalize-file-name
2179 (or argval (pop command-line-args-left)))))
2180 (cond (splice (setcdr splice (cons tem (cdr splice)))
2181 (setq splice (cdr splice)))
2182 (t (setq load-path (cons tem load-path)
2183 splice load-path))))
2185 ((member argi '("-l" "-load"))
2186 (let* ((file (command-line-normalize-file-name
2187 (or argval (pop command-line-args-left))))
2188 ;; Take file from default dir if it exists there;
2189 ;; otherwise let `load' search for it.
2190 (file-ex (expand-file-name file)))
2191 (when (file-exists-p file-ex)
2192 (setq file file-ex))
2193 (load file nil t)))
2195 ;; This is used to handle -script. It's not clear
2196 ;; we need to document it (it is totally internal).
2197 ((member argi '("-scriptload"))
2198 (let* ((file (command-line-normalize-file-name
2199 (or argval (pop command-line-args-left))))
2200 ;; Take file from default dir.
2201 (file-ex (expand-file-name file)))
2202 (load file-ex nil t t)))
2204 ((equal argi "-insert")
2205 (setq inhibit-startup-screen t)
2206 (setq tem (or argval (pop command-line-args-left)))
2207 (or (stringp tem)
2208 (error "File name omitted from `-insert' option"))
2209 (insert-file-contents (command-line-normalize-file-name tem)))
2211 ((equal argi "-kill")
2212 (kill-emacs t))
2214 ;; This is for when they use --no-desktop with -q, or
2215 ;; don't load Desktop in their .emacs. If desktop.el
2216 ;; _is_ loaded, it will handle this switch, and we
2217 ;; won't see it by the time we get here.
2218 ((equal argi "-no-desktop")
2219 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
2221 ((string-match "^\\+[0-9]+\\'" argi)
2222 (setq line (string-to-number argi)))
2224 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
2225 (setq line (string-to-number (match-string 1 argi))
2226 column (string-to-number (match-string 2 argi))))
2228 ((setq tem (assoc orig-argi command-line-x-option-alist))
2229 ;; Ignore X-windows options and their args if not using X.
2230 (setq command-line-args-left
2231 (nthcdr (nth 1 tem) command-line-args-left)))
2233 ((setq tem (assoc orig-argi command-line-ns-option-alist))
2234 ;; Ignore NS-windows options and their args if not using NS.
2235 (setq command-line-args-left
2236 (nthcdr (nth 1 tem) command-line-args-left)))
2238 ((member argi '("-find-file" "-file" "-visit"))
2239 (setq inhibit-startup-screen t)
2240 ;; An explicit option to specify visiting a file.
2241 (setq tem (or argval (pop command-line-args-left)))
2242 (unless (stringp tem)
2243 (error "File name omitted from `%s' option" argi))
2244 (setq file-count (1+ file-count))
2245 (let ((file (expand-file-name
2246 (command-line-normalize-file-name tem)
2247 dir)))
2248 (if (= file-count 1)
2249 (setq first-file-buffer (find-file file))
2250 (find-file-other-window file)))
2251 (unless (zerop line)
2252 (goto-char (point-min))
2253 (forward-line (1- line)))
2254 (setq line 0)
2255 (unless (< column 1)
2256 (move-to-column (1- column)))
2257 (setq column 0))
2259 ;; These command lines now have no effect.
2260 ((string-match "\\`--?\\(no-\\)?\\(uni\\|multi\\)byte$" argi)
2261 (display-warning 'initialization
2262 (format "Ignoring obsolete arg %s" argi)))
2264 ((equal argi "--")
2265 (setq just-files t))
2267 ;; We have almost exhausted our options. See if the
2268 ;; user has made any other command-line options available
2269 (let ((hooks command-line-functions)
2270 (did-hook nil))
2271 (while (and hooks
2272 (not (setq did-hook (funcall (car hooks)))))
2273 (setq hooks (cdr hooks)))
2274 (if (not did-hook)
2275 ;; Presume that the argument is a file name.
2276 (progn
2277 (if (string-match "\\`-" argi)
2278 (error "Unknown option `%s'" argi))
2279 (unless initial-window-system
2280 (setq inhibit-startup-screen t))
2281 (setq file-count (1+ file-count))
2282 (let ((file
2283 (expand-file-name
2284 (command-line-normalize-file-name orig-argi)
2285 dir)))
2286 (cond ((= file-count 1)
2287 (setq first-file-buffer (find-file file)))
2288 (inhibit-startup-screen
2289 (find-file-other-window file))
2290 (t (find-file file))))
2291 (unless (zerop line)
2292 (goto-char (point-min))
2293 (forward-line (1- line)))
2294 (setq line 0)
2295 (unless (< column 1)
2296 (move-to-column (1- column)))
2297 (setq column 0))))))
2298 ;; In unusual circumstances, the execution of Lisp code due
2299 ;; to command-line options can cause the last visible frame
2300 ;; to be deleted. In this case, kill emacs to avoid an
2301 ;; abort later.
2302 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))))
2304 (when initial-buffer-choice
2305 (cond ((eq initial-buffer-choice t)
2306 (switch-to-buffer (get-buffer-create "*scratch*")))
2307 ((stringp initial-buffer-choice)
2308 (find-file initial-buffer-choice))))
2310 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2311 (and initial-scratch-message
2312 (get-buffer "*scratch*")
2313 (with-current-buffer "*scratch*"
2314 (when (zerop (buffer-size))
2315 (insert initial-scratch-message)
2316 (set-buffer-modified-p nil))))
2318 (if (or inhibit-startup-screen
2319 initial-buffer-choice
2320 noninteractive
2321 inhibit-x-resources)
2323 ;; Not displaying a startup screen. If 3 or more files
2324 ;; visited, and not all visible, show user what they all are.
2325 (and (> file-count 2)
2326 (not noninteractive)
2327 (not inhibit-startup-buffer-menu)
2328 (or (get-buffer-window first-file-buffer)
2329 (list-buffers)))
2331 ;; Display a startup screen, after some preparations.
2333 ;; If there are no switches to process, we might as well
2334 ;; run this hook now, and there may be some need to do it
2335 ;; before doing any output.
2336 (run-hooks 'emacs-startup-hook)
2337 (and term-setup-hook
2338 (run-hooks 'term-setup-hook))
2339 (setq inhibit-startup-hooks t)
2341 ;; It's important to notice the user settings before we
2342 ;; display the startup message; otherwise, the settings
2343 ;; won't take effect until the user gives the first
2344 ;; keystroke, and that's distracting.
2345 (when (fboundp 'frame-notice-user-settings)
2346 (frame-notice-user-settings))
2348 ;; If there are no switches to process, we might as well
2349 ;; run this hook now, and there may be some need to do it
2350 ;; before doing any output.
2351 (when window-setup-hook
2352 (run-hooks 'window-setup-hook)
2353 ;; Don't let the hook be run twice.
2354 (setq window-setup-hook nil))
2356 ;; ;; Do this now to avoid an annoying delay if the user
2357 ;; ;; clicks the menu bar during the sit-for.
2358 ;; (when (display-popup-menus-p)
2359 ;; (precompute-menubar-bindings))
2360 ;; (with-no-warnings
2361 ;; (setq menubar-bindings-done t))
2363 (if (> file-count 0)
2364 (display-startup-screen t)
2365 (display-startup-screen nil)))))
2367 (defun command-line-normalize-file-name (file)
2368 "Collapse multiple slashes to one, to handle non-Emacs file names."
2369 (save-match-data
2370 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2371 ;; That is significant on some systems.
2372 ;; However, /// at the beginning is supposed to mean just /, not //.
2373 (if (string-match "^///+" file)
2374 (setq file (replace-match "/" t t file)))
2375 (and (memq system-type '(ms-dos windows-nt))
2376 (string-match "^[A-Za-z]:\\(\\\\[\\\\/]\\)" file) ; C:\/ or C:\\
2377 (setq file (replace-match "/" t t file 1)))
2378 (while (string-match "//+" file 1)
2379 (setq file (replace-match "/" t t file)))
2380 file))
2382 ;;; startup.el ends here