Fix pop-to-buffer call in switch-to-buffer.
[emacs.git] / lisp / startup.el
blob6953ed25ed490e480ca39a33cd868a091eb4db74
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
45 or directory using `find-file'. If t, open the `*scratch*'
46 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 ;; FIXME: Bad name for a dynamically bound variable.
103 "List of command-line args not yet processed.
104 This is a convenience alias, so that one can write \(pop argv\)
105 inside of --eval command line arguments in order to access
106 following arguments.")
108 (defvar command-line-functions nil ;; lrs 7/31/89
109 "List of functions to process unrecognized command-line arguments.
110 Each function should access the dynamically bound variables
111 `argi' (the current argument) and `command-line-args-left' (the remaining
112 arguments). The function should return non-nil only if it recognizes and
113 processes `argi'. If it does so, it may consume successive arguments by
114 altering `command-line-args-left' to remove them.")
116 (defvar command-line-default-directory nil
117 "Default directory to use for command line arguments.
118 This is normally copied from `default-directory' when Emacs starts.")
120 ;;; This is here, rather than in x-win.el, so that we can ignore these
121 ;;; options when we are not using X.
122 (defconst command-line-x-option-alist
123 '(("-bw" 1 x-handle-numeric-switch border-width)
124 ("-d" 1 x-handle-display)
125 ("-display" 1 x-handle-display)
126 ("-name" 1 x-handle-name-switch)
127 ("-title" 1 x-handle-switch title)
128 ("-T" 1 x-handle-switch title)
129 ("-r" 0 x-handle-switch reverse t)
130 ("-rv" 0 x-handle-switch reverse t)
131 ("-reverse" 0 x-handle-switch reverse t)
132 ("-reverse-video" 0 x-handle-switch reverse t)
133 ("-fn" 1 x-handle-switch font)
134 ("-font" 1 x-handle-switch font)
135 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
136 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
137 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
138 ("-mm" 0 x-handle-initial-switch fullscreen maximized)
139 ("-ib" 1 x-handle-numeric-switch internal-border-width)
140 ("-g" 1 x-handle-geometry)
141 ("-lsp" 1 x-handle-numeric-switch line-spacing)
142 ("-geometry" 1 x-handle-geometry)
143 ("-fg" 1 x-handle-switch foreground-color)
144 ("-foreground" 1 x-handle-switch foreground-color)
145 ("-bg" 1 x-handle-switch background-color)
146 ("-background" 1 x-handle-switch background-color)
147 ("-ms" 1 x-handle-switch mouse-color)
148 ("-nbi" 0 x-handle-switch icon-type nil)
149 ("-iconic" 0 x-handle-iconic)
150 ("-xrm" 1 x-handle-xrm-switch)
151 ("-cr" 1 x-handle-switch cursor-color)
152 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
153 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
154 ("-bd" 1 x-handle-switch)
155 ("--border-width" 1 x-handle-numeric-switch border-width)
156 ("--display" 1 x-handle-display)
157 ("--name" 1 x-handle-name-switch)
158 ("--title" 1 x-handle-switch title)
159 ("--reverse-video" 0 x-handle-switch reverse t)
160 ("--font" 1 x-handle-switch font)
161 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
162 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
163 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
164 ("--maximized" 0 x-handle-initial-switch fullscreen maximized)
165 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
166 ("--geometry" 1 x-handle-geometry)
167 ("--foreground-color" 1 x-handle-switch foreground-color)
168 ("--background-color" 1 x-handle-switch background-color)
169 ("--mouse-color" 1 x-handle-switch mouse-color)
170 ("--no-bitmap-icon" 0 x-handle-no-bitmap-icon)
171 ("--iconic" 0 x-handle-iconic)
172 ("--xrm" 1 x-handle-xrm-switch)
173 ("--cursor-color" 1 x-handle-switch cursor-color)
174 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
175 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
176 ("--border-color" 1 x-handle-switch border-color)
177 ("--smid" 1 x-handle-smid)
178 ("--parent-id" 1 x-handle-parent-id))
179 "Alist of X Windows options.
180 Each element has the form
181 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
182 where NAME is the option name string, NUMARGS is the number of arguments
183 that the option accepts, HANDLER is a function to call to handle the option.
184 FRAME-PARAM (optional) is the frame parameter this option specifies,
185 and VALUE is the value which is given to that frame parameter
186 \(most options use the argument for this, so VALUE is not present).")
188 (defconst command-line-ns-option-alist
189 '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
190 ("-NXAutoLaunch" 1 ns-ignore-1-arg)
191 ("-macosx" 0 ignore)
192 ("-NSHost" 1 ns-ignore-1-arg)
193 ("-_NSMachLaunch" 1 ns-ignore-1-arg)
194 ("-MachLaunch" 1 ns-ignore-1-arg)
195 ("-NXOpen" 1 ns-ignore-1-arg)
196 ("-NSOpen" 1 ns-handle-nxopen)
197 ("-NXOpenTemp" 1 ns-ignore-1-arg)
198 ("-NSOpenTemp" 1 ns-handle-nxopentemp)
199 ("-GSFilePath" 1 ns-handle-nxopen)
200 ;;("-bw" . x-handle-numeric-switch)
201 ;;("-d" . x-handle-display)
202 ;;("-display" . x-handle-display)
203 ("-name" 1 x-handle-name-switch)
204 ("-title" 1 x-handle-switch title)
205 ("-T" 1 x-handle-switch title)
206 ("-r" 0 x-handle-switch reverse t)
207 ("-rv" 0 x-handle-switch reverse t)
208 ("-reverse" 0 x-handle-switch reverse t)
209 ("-fn" 1 x-handle-switch font)
210 ("-font" 1 x-handle-switch font)
211 ("-ib" 1 x-handle-numeric-switch internal-border-width)
212 ;;("-g" . x-handle-geometry)
213 ;;("-geometry" . x-handle-geometry)
214 ("-fg" 1 x-handle-switch foreground-color)
215 ("-foreground" 1 x-handle-switch foreground-color)
216 ("-bg" 1 x-handle-switch background-color)
217 ("-background" 1 x-handle-switch background-color)
218 ; ("-ms" 1 x-handle-switch mouse-color)
219 ("-itype" 0 x-handle-switch icon-type t)
220 ("-i" 0 x-handle-switch icon-type t)
221 ("-iconic" 0 x-handle-iconic icon-type t)
222 ;;("-xrm" . x-handle-xrm-switch)
223 ("-cr" 1 x-handle-switch cursor-color)
224 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
225 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
226 ("-bd" 1 x-handle-switch)
227 ;; ("--border-width" 1 x-handle-numeric-switch border-width)
228 ;; ("--display" 1 ns-handle-display)
229 ("--name" 1 x-handle-name-switch)
230 ("--title" 1 x-handle-switch title)
231 ("--reverse-video" 0 x-handle-switch reverse t)
232 ("--font" 1 x-handle-switch font)
233 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
234 ;; ("--geometry" 1 ns-handle-geometry)
235 ("--foreground-color" 1 x-handle-switch foreground-color)
236 ("--background-color" 1 x-handle-switch background-color)
237 ("--mouse-color" 1 x-handle-switch mouse-color)
238 ("--icon-type" 0 x-handle-switch icon-type t)
239 ("--iconic" 0 x-handle-iconic)
240 ;; ("--xrm" 1 ns-handle-xrm-switch)
241 ("--cursor-color" 1 x-handle-switch cursor-color)
242 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
243 ("--border-color" 1 x-handle-switch border-width))
244 "Alist of NS options.
245 Each element has the form
246 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
247 where NAME is the option name string, NUMARGS is the number of arguments
248 that the option accepts, HANDLER is a function to call to handle the option.
249 FRAME-PARAM (optional) is the frame parameter this option specifies,
250 and VALUE is the value which is given to that frame parameter
251 \(most options use the argument for this, so VALUE is not present).")
254 (defvar before-init-hook nil
255 "Normal hook run after handling urgent options but before loading init files.")
257 (defvar after-init-hook nil
258 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
259 There is no `condition-case' around the running of these functions;
260 therefore, if you set `debug-on-error' non-nil in `.emacs',
261 an error in one of these functions will invoke the debugger.")
263 (defvar emacs-startup-hook nil
264 "Normal hook run after loading init files and handling the command line.")
266 (defvar term-setup-hook nil
267 "Normal hook run after loading terminal-specific Lisp code.
268 It also follows `emacs-startup-hook'. This hook exists for users to set,
269 so as to override the definitions made by the terminal-specific file.
270 Emacs never sets this variable itself.")
272 (defvar inhibit-startup-hooks nil
273 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
274 This is because we already did so.")
276 (defvar keyboard-type nil
277 "The brand of keyboard you are using.
278 This variable is used to define the proper function and keypad
279 keys for use under X. It is used in a fashion analogous to the
280 environment variable TERM.")
282 (defvar window-setup-hook nil
283 "Normal hook run to initialize window system display.
284 Emacs runs this hook after processing the command line arguments and loading
285 the user's init file.")
287 (defcustom initial-major-mode 'lisp-interaction-mode
288 "Major mode command symbol to use for the initial `*scratch*' buffer."
289 :type 'function
290 :group 'initialization)
292 (defvar init-file-user nil
293 "Identity of user whose `.emacs' file is or was read.
294 The value is nil if `-q' or `--no-init-file' was specified,
295 meaning do not load any init file.
297 Otherwise, the value may be an empty string, meaning
298 use the init file for the user who originally logged in,
299 or it may be a string containing a user's name meaning
300 use that person's init file.
302 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
303 evaluates to the name of the directory where the `.emacs' file was
304 looked for.
306 Setting `init-file-user' does not prevent Emacs from loading
307 `site-start.el'. The only way to do that is to use `--no-site-file'.")
309 (defcustom site-run-file (purecopy "site-start")
310 "File containing site-wide run-time initializations.
311 This file is loaded at run-time before `~/.emacs'. It contains inits
312 that need to be in place for the entire site, but which, due to their
313 higher incidence of change, don't make sense to load into Emacs's
314 dumped image. Thus, the run-time load order is: 1. file described in
315 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
317 Don't use the `site-start.el' file for things some users may not like.
318 Put them in `default.el' instead, so that users can more easily
319 override them. Users can prevent loading `default.el' with the `-q'
320 option or by setting `inhibit-default-init' in their own init files,
321 but inhibiting `site-start.el' requires `--no-site-file', which
322 is less convenient.
324 This variable is defined for customization so as to make
325 it visible in the relevant context. However, actually customizing it
326 is not allowed, since it would not work anyway. The only way to set
327 this variable usefully is to set it while building and dumping Emacs."
328 :type '(choice (const :tag "none" nil) string)
329 :group 'initialization
330 :initialize 'custom-initialize-default
331 :set (lambda (_variable _value)
332 (error "Customizing `site-run-file' does not work")))
334 (defcustom mail-host-address nil
335 "Name of this machine, for purposes of naming users."
336 :type '(choice (const nil) string)
337 :group 'mail)
339 (defcustom user-mail-address (if command-line-processed
340 (or (getenv "EMAIL")
341 (concat (user-login-name) "@"
342 (or mail-host-address
343 (system-name))))
344 ;; Empty string means "not set yet".
346 "Full mailing address of this user.
347 This is initialized with environment variable `EMAIL' or, as a
348 fallback, using `mail-host-address'. This is done after your
349 init file is read, in case it sets `mail-host-address'."
350 :type 'string
351 :group 'mail)
353 (defcustom auto-save-list-file-prefix
354 (cond ((eq system-type 'ms-dos)
355 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
356 (concat user-emacs-directory "auto-save.list/_s"))
358 (concat user-emacs-directory "auto-save-list/.saves-")))
359 "Prefix for generating `auto-save-list-file-name'.
360 This is used after reading your `.emacs' file to initialize
361 `auto-save-list-file-name', by appending Emacs's pid and the system name,
362 if you have not already set `auto-save-list-file-name' yourself.
363 Directories in the prefix will be created if necessary.
364 Set this to nil if you want to prevent `auto-save-list-file-name'
365 from being initialized."
366 :type '(choice (const :tag "Don't record a session's auto save list" nil)
367 string)
368 :group 'auto-save)
370 (defvar emacs-basic-display nil)
372 (defvar init-file-debug nil)
374 (defvar init-file-had-error nil
375 "Non-nil if there was an error loading the user's init file.")
377 (defvar normal-top-level-add-subdirs-inode-list nil)
379 (defvar no-blinking-cursor nil)
381 (defvar default-frame-background-mode)
383 (defvar pure-space-overflow nil
384 "Non-nil if building Emacs overflowed pure space.")
386 (defvar pure-space-overflow-message (purecopy "\
387 Warning Warning!!! Pure space overflow !!!Warning Warning
388 \(See the node Pure Storage in the Lisp manual for details.)\n"))
390 (defcustom tutorial-directory
391 (file-name-as-directory (expand-file-name "tutorials" data-directory))
392 "Directory containing the Emacs TUTORIAL files."
393 :group 'installation
394 :type 'directory
395 :initialize 'custom-initialize-delay)
397 (defconst package-subdirectory-regexp
398 "\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)"
399 "Regular expression matching the name of a package subdirectory.
400 The first subexpression is the package name.
401 The second subexpression is the version string.
403 The regexp should not contain a starting \"\\`\" or a trailing
404 \"\\'\"; those are added automatically by callers.")
406 (defun normal-top-level-add-subdirs-to-load-path ()
407 "Add all subdirectories of current directory to `load-path'.
408 More precisely, this uses only the subdirectories whose names
409 start with letters or digits; it excludes any subdirectory named `RCS'
410 or `CVS', and any subdirectory that contains a file named `.nosearch'."
411 (let (dirs
412 attrs
413 (pending (list default-directory)))
414 ;; This loop does a breadth-first tree walk on DIR's subtree,
415 ;; putting each subdir into DIRS as its contents are examined.
416 (while pending
417 (push (pop pending) dirs)
418 (let* ((this-dir (car dirs))
419 (contents (directory-files this-dir))
420 (default-directory this-dir)
421 (canonicalized (if (fboundp 'untranslated-canonical-name)
422 (untranslated-canonical-name this-dir))))
423 ;; The Windows version doesn't report meaningful inode numbers, so
424 ;; use the canonicalized absolute file name of the directory instead.
425 (setq attrs (or canonicalized
426 (nthcdr 10 (file-attributes this-dir))))
427 (unless (member attrs normal-top-level-add-subdirs-inode-list)
428 (push attrs normal-top-level-add-subdirs-inode-list)
429 (dolist (file contents)
430 (and (string-match "\\`[[:alnum:]]" file)
431 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
432 (not (member file '("RCS" "CVS" "rcs" "cvs")))
433 ;; Avoid doing a `stat' when it isn't necessary because
434 ;; that can cause trouble when an NFS server is down.
435 (not (string-match "\\.elc?\\'" file))
436 (file-directory-p file)
437 (let ((expanded (expand-file-name file)))
438 (or (file-exists-p (expand-file-name ".nosearch" expanded))
439 (setq pending (nconc pending (list expanded))))))))))
440 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
442 (defun normal-top-level-add-to-load-path (dirs)
443 "This function is called from a subdirs.el file.
444 It assumes that `default-directory' is the directory in which the
445 subdirs.el file exists, and it adds to `load-path' the subdirs of
446 that directory as specified in DIRS. Normally the elements of
447 DIRS are relative."
448 (let ((tail load-path)
449 (thisdir (directory-file-name default-directory)))
450 (while (and tail
451 ;;Don't go all the way to the nil terminator.
452 (cdr tail)
453 (not (equal thisdir (car tail)))
454 (not (and (memq system-type '(ms-dos windows-nt))
455 (equal (downcase thisdir) (downcase (car tail))))))
456 (setq tail (cdr tail)))
457 ;;Splice the new section in.
458 (when tail
459 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
461 (defun normal-top-level ()
462 (if command-line-processed
463 (message "Back to top level.")
464 (setq command-line-processed t)
465 (let ((dir default-directory))
466 (with-current-buffer "*Messages*"
467 ;; Make it easy to do like "tail -f".
468 (set (make-local-variable 'window-point-insertion-type) t)
469 ;; Give *Messages* the same default-directory as *scratch*,
470 ;; just to keep things predictable.
471 (setq default-directory dir)))
472 ;; `user-full-name' is now known; reset its standard-value here.
473 (put 'user-full-name 'standard-value
474 (list (default-value 'user-full-name)))
475 ;; Look in each dir in load-path for a subdirs.el file.
476 ;; If we find one, load it, which will add the appropriate subdirs
477 ;; of that dir into load-path,
478 ;; Look for a leim-list.el file too. Loading it will register
479 ;; available input methods.
480 (let ((tail load-path) dir)
481 (while tail
482 (setq dir (car tail))
483 (let ((default-directory dir))
484 (load (expand-file-name "subdirs.el") t t t))
485 (let ((default-directory dir))
486 (load (expand-file-name "leim-list.el") t t t))
487 ;; We don't use a dolist loop and we put this "setq-cdr" command at
488 ;; the end, because the subdirs.el files may add elements to the end
489 ;; of load-path and we want to take it into account.
490 (setq tail (cdr tail))))
491 ;; If the PWD environment variable isn't accurate, delete it.
492 (let ((pwd (getenv "PWD")))
493 (and (stringp pwd)
494 ;; Use FOO/., so that if FOO is a symlink, file-attributes
495 ;; describes the directory linked to, not FOO itself.
496 (or (equal (file-attributes
497 (concat (file-name-as-directory pwd) "."))
498 (file-attributes
499 (concat (file-name-as-directory default-directory)
500 ".")))
501 (setq process-environment
502 (delete (concat "PWD=" pwd)
503 process-environment)))))
504 (setq default-directory (abbreviate-file-name default-directory))
505 (let ((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 ;; Subprocesses of Emacs do not have direct access to the terminal, so
576 ;; unless told otherwise they should only assume a dumb terminal.
577 ;; We are careful to do it late (after term-setup-hook), although the
578 ;; new multi-tty code does not use $TERM any more there anyway.
579 (setenv "TERM" "dumb")
580 ;; Remove DISPLAY from the process-environment as well. This allows
581 ;; `callproc.c' to give it a useful adaptive default which is either
582 ;; the value of the `display' frame-parameter or the DISPLAY value
583 ;; from initial-environment.
584 (let ((display (frame-parameter nil 'display)))
585 ;; Be careful which DISPLAY to remove from process-environment: follow
586 ;; the logic of `callproc.c'.
587 (if (stringp display) (setq display (concat "DISPLAY=" display))
588 (dolist (varval initial-environment)
589 (if (string-match "\\`DISPLAY=" varval)
590 (setq display varval))))
591 (when display
592 (delete display process-environment)))))
594 ;; Precompute the keyboard equivalents in the menu bar items.
595 ;; Command-line options supported by tty's:
596 (defconst tty-long-option-alist
597 '(("--name" . "-name")
598 ("--title" . "-T")
599 ("--reverse-video" . "-reverse")
600 ("--foreground-color" . "-fg")
601 ("--background-color" . "-bg")
602 ("--color" . "-color")))
604 (defconst tool-bar-images-pixel-height 24
605 "Height in pixels of images in the tool-bar.")
607 (defvar tool-bar-originally-present nil
608 "Non-nil if tool-bars are present before user and site init files are read.")
610 (defvar handle-args-function-alist '((nil . tty-handle-args))
611 "Functions for processing window-system dependent command-line arguments.
612 Window system startup files should add their own function to this
613 alist, which should parse the command line arguments. Those
614 pertaining to the window system should be processed and removed
615 from the returned command line.")
617 (defvar window-system-initialization-alist '((nil . ignore))
618 "Alist of window-system initialization functions.
619 Window-system startup files should add their own initialization
620 function to this list. The function should take no arguments,
621 and initialize the window system environment to prepare for
622 opening the first frame (e.g. open a connection to an X server).")
624 (defun tty-handle-args (args)
625 "Handle the X-like command-line arguments \"-fg\", \"-bg\", \"-name\", etc."
626 (let (rest)
627 (message "%S" args)
628 (while (and args
629 (not (equal (car args) "--")))
630 (let* ((argi (pop args))
631 (orig-argi argi)
632 argval completion)
633 ;; Check for long options with attached arguments
634 ;; and separate out the attached option argument into argval.
635 (when (string-match "^\\(--[^=]*\\)=" argi)
636 (setq argval (substring argi (match-end 0))
637 argi (match-string 1 argi)))
638 (when (string-match "^--" argi)
639 (setq completion (try-completion argi tty-long-option-alist))
640 (if (eq completion t)
641 ;; Exact match for long option.
642 (setq argi (cdr (assoc argi tty-long-option-alist)))
643 (if (stringp completion)
644 (let ((elt (assoc completion tty-long-option-alist)))
645 ;; Check for abbreviated long option.
646 (or elt
647 (error "Option `%s' is ambiguous" argi))
648 (setq argi (cdr elt)))
649 ;; Check for a short option.
650 (setq argval nil
651 argi orig-argi))))
652 (cond ((member argi '("-fg" "-foreground"))
653 (push (cons 'foreground-color (or argval (pop args)))
654 default-frame-alist))
655 ((member argi '("-bg" "-background"))
656 (push (cons 'background-color (or argval (pop args)))
657 default-frame-alist))
658 ((member argi '("-T" "-name"))
659 (unless argval (setq argval (pop args)))
660 (push (cons 'title
661 (if (stringp argval)
662 argval
663 (let ((case-fold-search t)
665 (setq argval (invocation-name))
667 ;; Change any . or * characters in name to
668 ;; hyphens, so as to emulate behavior on X.
669 (while
670 (setq i (string-match "[.*]" argval))
671 (aset argval i ?-))
672 argval)))
673 default-frame-alist))
674 ((member argi '("-r" "-rv" "-reverse"))
675 (push '(reverse . t)
676 default-frame-alist))
677 ((equal argi "-color")
678 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
679 (push (cons 'tty-color-mode
680 (cond
681 ((numberp argval) argval)
682 ((string-match "-?[0-9]+" argval)
683 (string-to-number argval))
684 (t (intern argval))))
685 default-frame-alist))
687 (push argi rest)))))
688 (nreverse rest)))
690 (declare-function x-get-resource "frame.c"
691 (attribute class &optional component subclass))
692 (declare-function tool-bar-mode "tool-bar" (&optional arg))
693 (declare-function tool-bar-setup "tool-bar")
695 (defvar server-name)
696 (defvar server-process)
698 (defun command-line ()
699 (setq before-init-time (current-time)
700 after-init-time nil
701 command-line-default-directory default-directory)
703 ;; Force recomputation, in case it was computed during the dump.
704 (setq abbreviated-home-dir nil)
706 ;; See if we should import version-control from the environment variable.
707 (let ((vc (getenv "VERSION_CONTROL")))
708 (cond ((eq vc nil)) ;don't do anything if not set
709 ((member vc '("t" "numbered"))
710 (setq version-control t))
711 ((member vc '("nil" "existing"))
712 (setq version-control nil))
713 ((member vc '("never" "simple"))
714 (setq version-control 'never))))
716 ;;! This has been commented out; I currently find the behavior when
717 ;;! split-window-keep-point is nil disturbing, but if I can get used
718 ;;! to it, then it would be better to eliminate the option.
719 ;;! ;; Choose a good default value for split-window-keep-point.
720 ;;! (setq split-window-keep-point (> baud-rate 2400))
722 ;; Set the default strings to display in mode line for
723 ;; end-of-line formats that aren't native to this platform.
724 (cond
725 ((memq system-type '(ms-dos windows-nt))
726 (setq eol-mnemonic-unix "(Unix)"
727 eol-mnemonic-mac "(Mac)"))
728 (t ; this is for Unix/GNU/Linux systems
729 (setq eol-mnemonic-dos "(DOS)"
730 eol-mnemonic-mac "(Mac)")))
732 (set-locale-environment nil)
734 ;; Convert preloaded file names in load-history to absolute.
735 (let ((simple-file-name
736 ;; Look for simple.el or simple.elc and use their directory
737 ;; as the place where all Lisp files live.
738 (locate-file "simple" load-path (get-load-suffixes)))
739 lisp-dir)
740 ;; Don't abort if simple.el cannot be found, but print a warning.
741 (if (null simple-file-name)
742 (progn
743 (princ "Warning: Could not find simple.el nor simple.elc"
744 'external-debugging-output)
745 (terpri 'external-debugging-output))
746 (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
747 (setq load-history
748 (mapcar (lambda (elt)
749 (if (and (stringp (car elt))
750 (not (file-name-absolute-p (car elt))))
751 (cons (concat lisp-dir
752 (car elt))
753 (cdr elt))
754 elt))
755 load-history))))
757 ;; Convert the arguments to Emacs internal representation.
758 (let ((args (cdr command-line-args)))
759 (while args
760 (setcar args
761 (decode-coding-string (car args) locale-coding-system t))
762 (pop args)))
764 (let ((done nil)
765 (args (cdr command-line-args))
766 display-arg)
768 ;; Figure out which user's init file to load,
769 ;; either from the environment or from the options.
770 (setq init-file-user (if noninteractive nil (user-login-name)))
771 ;; If user has not done su, use current $HOME to find .emacs.
772 (and init-file-user
773 (equal init-file-user (user-real-login-name))
774 (setq init-file-user ""))
776 ;; Process the command-line args, and delete the arguments
777 ;; processed. This is consistent with the way main in emacs.c
778 ;; does things.
779 (while (and (not done) args)
780 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
781 ("--user") ("--iconic") ("--icon-type") ("--quick")
782 ("--no-blinking-cursor") ("--basic-display")))
783 (argi (pop args))
784 (orig-argi argi)
785 argval)
786 ;; Handle --OPTION=VALUE format.
787 (when (string-match "\\`\\(--[^=]*\\)=" argi)
788 (setq argval (substring argi (match-end 0))
789 argi (match-string 1 argi)))
790 (when (string-match "\\`--." orig-argi)
791 (let ((completion (try-completion argi longopts)))
792 (cond ((eq completion t)
793 (setq argi (substring argi 1)))
794 ((stringp completion)
795 (let ((elt (assoc completion longopts)))
796 (unless elt
797 (error "Option `%s' is ambiguous" argi))
798 (setq argi (substring (car elt) 1))))
800 (setq argval nil
801 argi orig-argi)))))
802 (cond
803 ;; The --display arg is handled partly in C, partly in Lisp.
804 ;; When it shows up here, we just put it back to be handled
805 ;; by `command-line-1'.
806 ((member argi '("-d" "-display"))
807 (setq display-arg (list argi (pop args))))
808 ((member argi '("-Q" "-quick"))
809 (setq init-file-user nil
810 site-run-file nil
811 inhibit-x-resources t))
812 ((member argi '("-D" "-basic-display"))
813 (setq no-blinking-cursor t
814 emacs-basic-display t)
815 (push '(vertical-scroll-bars . nil) initial-frame-alist))
816 ((member argi '("-q" "-no-init-file"))
817 (setq init-file-user nil))
818 ((member argi '("-u" "-user"))
819 (setq init-file-user (or argval (pop args))
820 argval nil))
821 ((equal argi "-no-site-file")
822 (setq site-run-file nil))
823 ((equal argi "-debug-init")
824 (setq init-file-debug t))
825 ((equal argi "-iconic")
826 (push '(visibility . icon) initial-frame-alist))
827 ((member argi '("-nbc" "-no-blinking-cursor"))
828 (setq no-blinking-cursor t))
829 ;; Push the popped arg back on the list of arguments.
831 (push argi args)
832 (setq done t)))
833 ;; Was argval set but not used?
834 (and argval
835 (error "Option `%s' doesn't allow an argument" argi))))
837 ;; Re-attach the --display arg.
838 (and display-arg (setq args (append display-arg args)))
840 ;; Re-attach the program name to the front of the arg list.
841 (and command-line-args
842 (setcdr command-line-args args)))
844 ;; Make sure window system's init file was loaded in loadup.el if
845 ;; using a window system.
846 ;; Initialize the window-system only after processing the command-line
847 ;; args so that -Q can influence this initialization.
848 (condition-case error
849 (unless noninteractive
850 (if (and initial-window-system
851 (not (featurep
852 (intern
853 (concat (symbol-name initial-window-system) "-win")))))
854 (error "Unsupported window system `%s'" initial-window-system))
855 ;; Process window-system specific command line parameters.
856 (setq command-line-args
857 (funcall
858 (or (cdr (assq initial-window-system handle-args-function-alist))
859 (error "Unsupported window system `%s'" initial-window-system))
860 command-line-args))
861 ;; Initialize the window system. (Open connection, etc.)
862 (funcall
863 (or (cdr (assq initial-window-system window-system-initialization-alist))
864 (error "Unsupported window system `%s'" initial-window-system))))
865 ;; If there was an error, print the error message and exit.
866 (error
867 (princ
868 (if (eq (car error) 'error)
869 (apply 'concat (cdr error))
870 (if (memq 'file-error (get (car error) 'error-conditions))
871 (format "%s: %s"
872 (nth 1 error)
873 (mapconcat (lambda (obj) (prin1-to-string obj t))
874 (cdr (cdr error)) ", "))
875 (format "%s: %s"
876 (get (car error) 'error-message)
877 (mapconcat (lambda (obj) (prin1-to-string obj t))
878 (cdr error) ", "))))
879 'external-debugging-output)
880 (terpri 'external-debugging-output)
881 (setq initial-window-system nil)
882 (kill-emacs)))
884 (run-hooks 'before-init-hook)
886 ;; Under X, this creates the X frame and deletes the terminal frame.
887 (unless (daemonp)
889 ;; If X resources are available, use them to initialize the values
890 ;; of `tool-bar-mode' and `menu-bar-mode', as well as the value of
891 ;; `no-blinking-cursor' and the `cursor' face.
892 (cond
893 ((or noninteractive emacs-basic-display)
894 (setq menu-bar-mode nil
895 tool-bar-mode nil
896 no-blinking-cursor t))
897 ((memq initial-window-system '(x w32 ns))
898 (let ((no-vals '("no" "off" "false" "0")))
899 (if (member (x-get-resource "menuBar" "MenuBar") no-vals)
900 (setq menu-bar-mode nil))
901 (if (member (x-get-resource "toolBar" "ToolBar") no-vals)
902 (setq tool-bar-mode nil))
903 (if (member (x-get-resource "cursorBlink" "CursorBlink")
904 no-vals)
905 (setq no-blinking-cursor t)))
906 ;; If the cursorColor X resource exists, alter the `cursor' face
907 ;; spec, but mark it as changed outside of Customize.
908 (let ((color (x-get-resource "cursorColor" "CursorColor")))
909 (when color
910 (put 'cursor 'theme-face
911 `((changed ((t :background ,color)))))
912 (put 'cursor 'face-modified t)))))
913 (frame-initialize))
915 (when (fboundp 'x-create-frame)
916 ;; Set up the tool-bar (even in tty frames, since Emacs might open a
917 ;; graphical frame later).
918 (unless noninteractive
919 (tool-bar-setup)))
921 ;; Turn off blinking cursor if so specified in X resources. This is here
922 ;; only because all other settings of no-blinking-cursor are here.
923 (unless (or noninteractive
924 emacs-basic-display
925 (and (memq window-system '(x w32 ns))
926 (not (member (x-get-resource "cursorBlink" "CursorBlink")
927 '("off" "false")))))
928 (setq no-blinking-cursor t))
930 ;; Re-evaluate predefined variables whose initial value depends on
931 ;; the runtime context.
932 (mapc 'custom-reevaluate-setting
933 ;; Initialize them in the same order they were loaded, in case there
934 ;; are dependencies between them.
935 (prog1 (nreverse custom-delayed-init-variables)
936 (setq custom-delayed-init-variables nil)))
938 (normal-erase-is-backspace-setup-frame)
940 ;; Register default TTY colors for the case the terminal hasn't a
941 ;; terminal init file. We do this regardles of whether the terminal
942 ;; supports colors or not and regardless the current display type,
943 ;; since users can connect to color-capable terminals and also
944 ;; switch color support on or off in mid-session by setting the
945 ;; tty-color-mode frame parameter.
946 ;; Exception: the `pc' ``window system'' has only 16 fixed colors,
947 ;; and they are already set at this point by a suitable function in
948 ;; window-system-initialization-alist.
949 (or (eq initial-window-system 'pc)
950 (tty-register-default-colors))
952 ;; Record whether the tool-bar is present before the user and site
953 ;; init files are processed. frame-notice-user-settings uses this
954 ;; to determine if the tool-bar has been disabled by the init files,
955 ;; and the frame needs to be resized.
956 (when (fboundp 'frame-notice-user-settings)
957 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
958 (assq 'tool-bar-lines default-frame-alist))))
959 (setq tool-bar-originally-present
960 (and tool-bar-lines
961 (cdr tool-bar-lines)
962 (not (eq 0 (cdr tool-bar-lines)))))))
964 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
965 (old-font-list-limit font-list-limit)
966 (old-face-ignored-fonts face-ignored-fonts))
968 ;; Run the site-start library if it exists. The point of this file is
969 ;; that it is run before .emacs. There is no point in doing this after
970 ;; .emacs; that is useless.
971 ;; Note that user-init-file is nil at this point. Code that might
972 ;; be loaded from site-run-file and wants to test if -q was given
973 ;; should check init-file-user instead, since that is already set.
974 ;; See cus-edit.el for an example.
975 (if site-run-file
976 (load site-run-file t t))
978 ;; Sites should not disable this. Only individuals should disable
979 ;; the startup screen.
980 (setq inhibit-startup-screen nil)
982 ;; Warn for invalid user name.
983 (when init-file-user
984 (if (string-match "[~/:\n]" init-file-user)
985 (display-warning 'initialization
986 (format "Invalid user name %s"
987 init-file-user)
988 :error)
989 (if (file-directory-p (expand-file-name
990 ;; We don't support ~USER on MS-Windows
991 ;; and MS-DOS except for the current
992 ;; user, and always load .emacs from
993 ;; the current user's home directory
994 ;; (see below). So always check "~",
995 ;; even if invoked with "-u USER", or
996 ;; if $USER or $LOGNAME are set to
997 ;; something different.
998 (if (memq system-type '(windows-nt ms-dos))
1000 (concat "~" init-file-user))))
1002 (display-warning 'initialization
1003 (format "User %s has no home directory"
1004 init-file-user)
1005 :error))))
1007 ;; Load that user's init file, or the default one, or none.
1008 (let (debug-on-error-from-init-file
1009 debug-on-error-should-be-set
1010 (debug-on-error-initial
1011 (if (eq init-file-debug t) 'startup init-file-debug))
1012 (orig-enable-multibyte (default-value 'enable-multibyte-characters)))
1013 (let ((debug-on-error debug-on-error-initial)
1014 ;; This function actually reads the init files.
1015 (inner
1016 (function
1017 (lambda ()
1018 (if init-file-user
1019 (let ((user-init-file-1
1020 (cond
1021 ((eq system-type 'ms-dos)
1022 (concat "~" init-file-user "/_emacs"))
1023 ((not (eq system-type 'windows-nt))
1024 (concat "~" init-file-user "/.emacs"))
1025 ;; Else deal with the Windows situation
1026 ((directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
1027 ;; Prefer .emacs on Windows.
1028 "~/.emacs")
1029 ((directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
1030 ;; Also support _emacs for compatibility, but warn about it.
1031 (push '(initialization
1032 "`_emacs' init file is deprecated, please use `.emacs'")
1033 delayed-warnings-list)
1034 "~/_emacs")
1035 (t ;; But default to .emacs if _emacs does not exist.
1036 "~/.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))
1101 (cdr error) ", "))
1102 :warning)
1103 (setq init-file-had-error t))))
1105 (if (and deactivate-mark transient-mark-mode)
1106 (with-current-buffer (window-buffer)
1107 (deactivate-mark)))
1109 ;; If the user has a file of abbrevs, read it (unless -batch).
1110 (when (and (not noninteractive)
1111 (file-exists-p abbrev-file-name)
1112 (file-readable-p abbrev-file-name))
1113 (quietly-read-abbrev-file abbrev-file-name))
1115 ;; If the abbrevs came entirely from the init file or the
1116 ;; abbrevs file, they do not need saving.
1117 (setq abbrevs-changed nil)
1119 ;; If we can tell that the init file altered debug-on-error,
1120 ;; arrange to preserve the value that it set up.
1121 (or (eq debug-on-error debug-on-error-initial)
1122 (setq debug-on-error-should-be-set t
1123 debug-on-error-from-init-file debug-on-error)))
1124 (if debug-on-error-should-be-set
1125 (setq debug-on-error debug-on-error-from-init-file))
1126 (unless (or (default-value 'enable-multibyte-characters)
1127 (eq orig-enable-multibyte (default-value
1128 'enable-multibyte-characters)))
1129 ;; Init file changed to unibyte. Reset existing multibyte
1130 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1131 ;; Arguably this should only be done if they're free of
1132 ;; multibyte characters.
1133 (mapc (lambda (buffer)
1134 (with-current-buffer buffer
1135 (if enable-multibyte-characters
1136 (set-buffer-multibyte nil))))
1137 (buffer-list))
1138 ;; Also re-set the language environment in case it was
1139 ;; originally done before unibyte was set and is sensitive to
1140 ;; unibyte (display table, terminal coding system &c).
1141 (set-language-environment current-language-environment)))
1143 ;; Do this here in case the init file sets mail-host-address.
1144 (if (equal user-mail-address "")
1145 (setq user-mail-address (or (getenv "EMAIL")
1146 (concat (user-login-name) "@"
1147 (or mail-host-address
1148 (system-name))))))
1150 ;; Originally face attributes were specified via
1151 ;; `font-lock-face-attributes'. Users then changed the default
1152 ;; face attributes by setting that variable. However, we try and
1153 ;; be back-compatible and respect its value if set except for
1154 ;; faces where M-x customize has been used to save changes for the
1155 ;; face.
1156 (when (boundp 'font-lock-face-attributes)
1157 (let ((face-attributes font-lock-face-attributes))
1158 (while face-attributes
1159 (let* ((face-attribute (pop face-attributes))
1160 (face (car face-attribute)))
1161 ;; Rustle up a `defface' SPEC from a
1162 ;; `font-lock-face-attributes' entry.
1163 (unless (get face 'saved-face)
1164 (let ((foreground (nth 1 face-attribute))
1165 (background (nth 2 face-attribute))
1166 (bold-p (nth 3 face-attribute))
1167 (italic-p (nth 4 face-attribute))
1168 (underline-p (nth 5 face-attribute))
1169 face-spec)
1170 (when foreground
1171 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1172 (when background
1173 (setq face-spec (cons ':background (cons background face-spec))))
1174 (when bold-p
1175 (setq face-spec (append '(:weight bold) face-spec)))
1176 (when italic-p
1177 (setq face-spec (append '(:slant italic) face-spec)))
1178 (when underline-p
1179 (setq face-spec (append '(:underline t) face-spec)))
1180 (face-spec-set face (list (list t face-spec)) nil)))))))
1182 ;; If parameter have been changed in the init file which influence
1183 ;; face realization, clear the face cache so that new faces will
1184 ;; be realized.
1185 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1186 (eq font-list-limit old-font-list-limit)
1187 (eq face-ignored-fonts old-face-ignored-fonts))
1188 (clear-face-cache)))
1190 ;; If any package directory exists, initialize the package system.
1191 (and user-init-file
1192 package-enable-at-startup
1193 (catch 'package-dir-found
1194 (let (dirs)
1195 (if (boundp 'package-directory-list)
1196 (setq dirs package-directory-list)
1197 (dolist (f load-path)
1198 (and (stringp f)
1199 (equal (file-name-nondirectory f) "site-lisp")
1200 (push (expand-file-name "elpa" f) dirs))))
1201 (push (if (boundp 'package-user-dir)
1202 package-user-dir
1203 (locate-user-emacs-file "elpa"))
1204 dirs)
1205 (dolist (dir dirs)
1206 (when (file-directory-p dir)
1207 (dolist (subdir (directory-files dir))
1208 (when (and (file-directory-p (expand-file-name subdir dir))
1209 (string-match
1210 (concat "\\`" package-subdirectory-regexp "\\'")
1211 subdir))
1212 (throw 'package-dir-found t)))))))
1213 (package-initialize))
1215 (setq after-init-time (current-time))
1216 (run-hooks 'after-init-hook)
1218 ;; Decode all default-directory.
1219 (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
1220 (save-excursion
1221 (dolist (elt (buffer-list))
1222 (set-buffer elt)
1223 (if default-directory
1224 (setq default-directory
1225 (decode-coding-string default-directory
1226 locale-coding-system t))))
1227 (setq command-line-default-directory
1228 (decode-coding-string command-line-default-directory
1229 locale-coding-system t))))
1231 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1232 (if (get-buffer "*scratch*")
1233 (with-current-buffer "*scratch*"
1234 (if (eq major-mode 'fundamental-mode)
1235 (funcall initial-major-mode))))
1237 ;; Load library for our terminal type.
1238 ;; User init file can set term-file-prefix to nil to prevent this.
1239 (unless (or noninteractive
1240 initial-window-system)
1241 (tty-run-terminal-initialization (selected-frame)))
1243 ;; Update the out-of-memory error message based on user's key bindings
1244 ;; for save-some-buffers.
1245 (setq memory-signal-data
1246 (list 'error
1247 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1249 ;; Process the remaining args.
1250 (command-line-1 (cdr command-line-args))
1252 ;; If -batch, terminate after processing the command options.
1253 (if noninteractive (kill-emacs t))
1255 ;; In daemon mode, start the server to allow clients to connect.
1256 ;; This is done after loading the user's init file and after
1257 ;; processing all command line arguments to allow e.g. `server-name'
1258 ;; to be changed before the server starts.
1259 (let ((dn (daemonp)))
1260 (when dn
1261 (when (stringp dn) (setq server-name dn))
1262 (server-start)
1263 (if server-process
1264 (daemon-initialized)
1265 (if (stringp dn)
1266 (message
1267 "Unable to start daemon: Emacs server named %S already running"
1268 server-name)
1269 (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."))
1270 (kill-emacs 1))))
1272 ;; Run emacs-session-restore (session management) if started by
1273 ;; the session manager and we have a session manager connection.
1274 (if (and (boundp 'x-session-previous-id)
1275 (stringp x-session-previous-id))
1276 (with-no-warnings
1277 (emacs-session-restore x-session-previous-id))))
1279 (defcustom initial-scratch-message (purecopy "\
1280 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1281 ;; If you want to create a file, visit that file with C-x C-f,
1282 ;; then enter the text in that file's own buffer.
1285 "Initial message displayed in *scratch* buffer at startup.
1286 If this is nil, no message will be displayed."
1287 :type '(choice (text :tag "Message")
1288 (const :tag "none" nil))
1289 :group 'initialization)
1292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1293 ;;; Fancy splash screen
1294 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1296 (defconst fancy-startup-text
1297 `((:face (variable-pitch font-lock-comment-face)
1298 "Welcome to "
1299 :link ("GNU Emacs"
1300 ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
1301 "Browse http://www.gnu.org/software/emacs/")
1302 ", one component of the "
1303 :link
1304 ,(lambda ()
1305 (if (eq system-type 'gnu/linux)
1306 `("GNU/Linux"
1307 ,(lambda (_button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1308 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1309 `("GNU" ,(lambda (_button) (describe-gnu-project))
1310 "Display info on the GNU project")))
1311 " operating system.\n\n"
1312 :face variable-pitch
1313 :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
1314 "\tLearn basic keystroke commands"
1315 ,(lambda ()
1316 (let* ((en "TUTORIAL")
1317 (tut (or (get-language-info current-language-environment
1318 'tutorial)
1319 en))
1320 (title (with-temp-buffer
1321 (insert-file-contents
1322 (expand-file-name tut tutorial-directory)
1323 nil 0 256)
1324 (search-forward ".")
1325 (buffer-substring (point-min) (1- (point))))))
1326 ;; If there is a specific tutorial for the current language
1327 ;; environment and it is not English, append its title.
1328 (if (string= en tut)
1330 (concat " (" title ")"))))
1331 "\n"
1332 :link ("Emacs Guided Tour"
1333 ,(lambda (_button)
1334 (browse-url "http://www.gnu.org/software/emacs/tour/"))
1335 "Browse http://www.gnu.org/software/emacs/tour/")
1336 "\tOverview of Emacs features at gnu.org\n"
1337 :link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual)))
1338 "\tView the Emacs manual using Info\n"
1339 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
1340 "\tGNU Emacs comes with "
1341 :face (variable-pitch (:slant oblique))
1342 "ABSOLUTELY NO WARRANTY\n"
1343 :face variable-pitch
1344 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
1345 "\tConditions for redistributing and changing Emacs\n"
1346 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
1347 "\tPurchasing printed copies of manuals\n"
1348 "\n"))
1349 "A list of texts to show in the middle part of splash screens.
1350 Each element in the list should be a list of strings or pairs
1351 `:face FACE', like `fancy-splash-insert' accepts them.")
1353 (defconst fancy-about-text
1354 `((:face (variable-pitch font-lock-comment-face)
1355 "This is "
1356 :link ("GNU Emacs"
1357 ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
1358 "Browse http://www.gnu.org/software/emacs/")
1359 ", one component of the "
1360 :link
1361 ,(lambda ()
1362 (if (eq system-type 'gnu/linux)
1363 `("GNU/Linux"
1364 ,(lambda (_button)
1365 (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1366 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1367 `("GNU" ,(lambda (_button) (describe-gnu-project))
1368 "Display info on the GNU project.")))
1369 " operating system.\n"
1370 :face (variable-pitch font-lock-builtin-face)
1371 "\n"
1372 ,(lambda () (emacs-version))
1373 "\n"
1374 :face (variable-pitch (:height 0.8))
1375 ,(lambda () emacs-copyright)
1376 "\n\n"
1377 :face variable-pitch
1378 :link ("Authors"
1379 ,(lambda (_button)
1380 (view-file (expand-file-name "AUTHORS" data-directory))
1381 (goto-char (point-min))))
1382 "\tMany people have contributed code included in GNU Emacs\n"
1383 :link ("Contributing"
1384 ,(lambda (_button)
1385 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1386 (goto-char (point-min))))
1387 "\tHow to contribute improvements to Emacs\n"
1388 "\n"
1389 :link ("GNU and Freedom" ,(lambda (_button) (describe-gnu-project)))
1390 "\tWhy we developed GNU Emacs, and the GNU operating system\n"
1391 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
1392 "\tGNU Emacs comes with "
1393 :face (variable-pitch (:slant oblique))
1394 "ABSOLUTELY NO WARRANTY\n"
1395 :face variable-pitch
1396 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
1397 "\tConditions for redistributing and changing Emacs\n"
1398 :link ("Getting New Versions" ,(lambda (_button) (describe-distribution)))
1399 "\tHow to obtain the latest version of Emacs\n"
1400 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
1401 "\tBuying printed manuals from the FSF\n"
1402 "\n"
1403 :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
1404 "\tLearn basic Emacs keystroke commands"
1405 ,(lambda ()
1406 (let* ((en "TUTORIAL")
1407 (tut (or (get-language-info current-language-environment
1408 'tutorial)
1409 en))
1410 (title (with-temp-buffer
1411 (insert-file-contents
1412 (expand-file-name tut tutorial-directory)
1413 nil 0 256)
1414 (search-forward ".")
1415 (buffer-substring (point-min) (1- (point))))))
1416 ;; If there is a specific tutorial for the current language
1417 ;; environment and it is not English, append its title.
1418 (if (string= en tut)
1420 (concat " (" title ")"))))
1421 "\n"
1422 :link ("Emacs Guided Tour"
1423 ,(lambda (_button)
1424 (browse-url "http://www.gnu.org/software/emacs/tour/"))
1425 "Browse http://www.gnu.org/software/emacs/tour/")
1426 "\tSee an overview of Emacs features at gnu.org"))
1427 "A list of texts to show in the middle part of the About screen.
1428 Each element in the list should be a list of strings or pairs
1429 `:face FACE', like `fancy-splash-insert' accepts them.")
1432 (defgroup fancy-splash-screen ()
1433 "Fancy splash screen when Emacs starts."
1434 :version "21.1"
1435 :group 'initialization)
1437 (defcustom fancy-splash-image nil
1438 "The image to show in the splash screens, or nil for defaults."
1439 :group 'fancy-splash-screen
1440 :type '(choice (const :tag "Default" nil)
1441 (file :tag "File")))
1444 (defvar splash-screen-keymap
1445 (let ((map (make-sparse-keymap)))
1446 (suppress-keymap map)
1447 (set-keymap-parent map button-buffer-map)
1448 (define-key map "\C-?" 'scroll-down)
1449 (define-key map " " 'scroll-up)
1450 (define-key map "q" 'exit-splash-screen)
1451 map)
1452 "Keymap for splash screen buffer.")
1454 ;; These are temporary storage areas for the splash screen display.
1456 (defun fancy-splash-insert (&rest args)
1457 "Insert text into the current buffer, with faces.
1458 Arguments from ARGS should be either strings; functions called
1459 with no args that return a string; pairs `:face FACE', where FACE
1460 is a face specification usable with `put-text-property'; or pairs
1461 `:link LINK' where LINK is a list of arguments to pass to
1462 `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which
1463 specifies the button's label, `action' property and help-echo string.
1464 FACE and LINK can also be functions, which are evaluated to obtain
1465 a face or button specification."
1466 (let ((current-face nil))
1467 (while args
1468 (cond ((eq (car args) :face)
1469 (setq args (cdr args) current-face (car args))
1470 (if (functionp current-face)
1471 (setq current-face (funcall current-face))))
1472 ((eq (car args) :link)
1473 (setq args (cdr args))
1474 (let ((spec (car args)))
1475 (if (functionp spec)
1476 (setq spec (funcall spec)))
1477 (insert-button (car spec)
1478 'face (list 'link current-face)
1479 'action (cadr spec)
1480 'help-echo (concat "mouse-2, RET: "
1481 (or (nth 2 spec)
1482 "Follow this link"))
1483 'follow-link t)))
1484 (t (insert (propertize (let ((it (car args)))
1485 (if (functionp it)
1486 (funcall it)
1487 it))
1488 'face current-face
1489 'help-echo (startup-echo-area-message)))))
1490 (setq args (cdr args)))))
1492 (declare-function image-size "image.c" (spec &optional pixels frame))
1494 (defun fancy-splash-head ()
1495 "Insert the head part of the splash screen into the current buffer."
1496 (let* ((image-file (cond ((stringp fancy-splash-image)
1497 fancy-splash-image)
1498 ((display-color-p)
1499 (cond ((<= (display-planes) 8)
1500 (if (image-type-available-p 'xpm)
1501 "splash.xpm"
1502 "splash.pbm"))
1503 ((image-type-available-p 'svg)
1504 "splash.svg")
1505 ((image-type-available-p 'png)
1506 "splash.png")
1507 ((image-type-available-p 'xpm)
1508 "splash.xpm")
1509 (t "splash.pbm")))
1510 (t "splash.pbm")))
1511 (img (create-image image-file))
1512 (image-width (and img (car (image-size img))))
1513 (window-width (window-width (selected-window))))
1514 (when img
1515 (when (> window-width image-width)
1516 ;; Center the image in the window.
1517 (insert (propertize " " 'display
1518 `(space :align-to (+ center (-0.5 . ,img)))))
1520 ;; Change the color of the XPM version of the splash image
1521 ;; so that it is visible with a dark frame background.
1522 (when (and (memq 'xpm img)
1523 (eq (frame-parameter nil 'background-mode) 'dark))
1524 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1526 ;; Insert the image with a help-echo and a link.
1527 (make-button (prog1 (point) (insert-image img)) (point)
1528 'face 'default
1529 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
1530 'action (lambda (_button) (browse-url "http://www.gnu.org/"))
1531 'follow-link t)
1532 (insert "\n\n")))))
1534 (defun fancy-startup-tail (&optional concise)
1535 "Insert the tail part of the splash screen into the current buffer."
1536 (unless concise
1537 (fancy-splash-insert
1538 :face 'variable-pitch
1539 "\nTo start... "
1540 :link `("Open a File"
1541 ,(lambda (_button) (call-interactively 'find-file))
1542 "Specify a new file's name, to edit the file")
1544 :link `("Open Home Directory"
1545 ,(lambda (_button) (dired "~"))
1546 "Open your home directory, to operate on its files")
1548 :link `("Customize Startup"
1549 ,(lambda (_button) (customize-group 'initialization))
1550 "Change initialization settings including this screen")
1551 "\n"))
1552 (fancy-splash-insert
1553 :face 'variable-pitch "To quit a partially entered command, type "
1554 :face 'default "Control-g"
1555 :face 'variable-pitch ".\n")
1556 (fancy-splash-insert :face `(variable-pitch font-lock-builtin-face)
1557 "\nThis is "
1558 (emacs-version)
1559 "\n"
1560 :face '(variable-pitch (:height 0.8))
1561 emacs-copyright
1562 "\n")
1563 (and auto-save-list-file-prefix
1564 ;; Don't signal an error if the
1565 ;; directory for auto-save-list files
1566 ;; does not yet exist.
1567 (file-directory-p (file-name-directory
1568 auto-save-list-file-prefix))
1569 (directory-files
1570 (file-name-directory auto-save-list-file-prefix)
1572 (concat "\\`"
1573 (regexp-quote (file-name-nondirectory
1574 auto-save-list-file-prefix)))
1576 (fancy-splash-insert :face '(variable-pitch font-lock-comment-face)
1577 "\nIf an Emacs session crashed recently, "
1578 "type "
1579 :face '(fixed-pitch font-lock-comment-face)
1580 "Meta-x recover-session RET"
1581 :face '(variable-pitch font-lock-comment-face)
1582 "\nto recover"
1583 " the files you were editing."))
1585 (when concise
1586 (fancy-splash-insert
1587 :face 'variable-pitch "\n"
1588 :link `("Dismiss this startup screen"
1589 ,(lambda (_button)
1590 (when startup-screen-inhibit-startup-screen
1591 (customize-set-variable 'inhibit-startup-screen t)
1592 (customize-mark-to-save 'inhibit-startup-screen)
1593 (custom-save-all))
1594 (let ((w (get-buffer-window "*GNU Emacs*")))
1595 (and w (not (one-window-p)) (delete-window w)))
1596 (kill-buffer "*GNU Emacs*")))
1597 " ")
1598 (when (or user-init-file custom-file)
1599 (let ((checked (create-image "checked.xpm"
1600 nil nil :ascent 'center))
1601 (unchecked (create-image "unchecked.xpm"
1602 nil nil :ascent 'center)))
1603 (insert-button
1605 :on-glyph checked
1606 :off-glyph unchecked
1607 'checked nil 'display unchecked 'follow-link t
1608 'action (lambda (button)
1609 (if (overlay-get button 'checked)
1610 (progn (overlay-put button 'checked nil)
1611 (overlay-put button 'display
1612 (overlay-get button :off-glyph))
1613 (setq startup-screen-inhibit-startup-screen
1614 nil))
1615 (overlay-put button 'checked t)
1616 (overlay-put button 'display
1617 (overlay-get button :on-glyph))
1618 (setq startup-screen-inhibit-startup-screen t)))))
1619 (fancy-splash-insert :face '(variable-pitch (:height 0.9))
1620 " Never show it again."))))
1622 (defun exit-splash-screen ()
1623 "Stop displaying the splash screen buffer."
1624 (interactive)
1625 (quit-window t))
1627 (defun fancy-startup-screen (&optional concise)
1628 "Display fancy startup screen.
1629 If CONCISE is non-nil, display a concise version of the
1630 splash screen in another window."
1631 (let ((splash-buffer (get-buffer-create "*GNU Emacs*")))
1632 (with-current-buffer splash-buffer
1633 (let ((inhibit-read-only t))
1634 (erase-buffer)
1635 (setq default-directory command-line-default-directory)
1636 (make-local-variable 'startup-screen-inhibit-startup-screen)
1637 (if pure-space-overflow
1638 (insert pure-space-overflow-message))
1639 (unless concise
1640 (fancy-splash-head))
1641 (dolist (text fancy-startup-text)
1642 (apply #'fancy-splash-insert text)
1643 (insert "\n"))
1644 (skip-chars-backward "\n")
1645 (delete-region (point) (point-max))
1646 (insert "\n")
1647 (fancy-startup-tail concise))
1648 (use-local-map splash-screen-keymap)
1649 (setq tab-width 22
1650 buffer-read-only t)
1651 (set-buffer-modified-p nil)
1652 (if (and view-read-only (not view-mode))
1653 (view-mode-enter nil 'kill-buffer))
1654 (goto-char (point-min))
1655 (forward-line (if concise 2 4)))
1656 (if concise
1657 (progn
1658 (display-buffer splash-buffer)
1659 ;; If the splash screen is in a split window, fit it.
1660 (let ((window (get-buffer-window splash-buffer t)))
1661 (or (null window)
1662 (eq window (selected-window))
1663 (eq window (next-window window))
1664 (fit-window-to-buffer window))))
1665 (switch-to-buffer splash-buffer))))
1667 (defun fancy-about-screen ()
1668 "Display fancy About screen."
1669 (let ((frame (fancy-splash-frame)))
1670 (save-selected-window
1671 (select-frame frame)
1672 (switch-to-buffer "*About GNU Emacs*")
1673 (setq buffer-undo-list t)
1674 (let ((inhibit-read-only t))
1675 (erase-buffer)
1676 (if pure-space-overflow
1677 (insert pure-space-overflow-message))
1678 (fancy-splash-head)
1679 (dolist (text fancy-about-text)
1680 (apply #'fancy-splash-insert text)
1681 (insert "\n"))
1682 (set-buffer-modified-p nil)
1683 (goto-char (point-min))
1684 (force-mode-line-update))
1685 (use-local-map splash-screen-keymap)
1686 (setq tab-width 22)
1687 (message "%s" (startup-echo-area-message))
1688 (setq buffer-read-only t)
1689 (goto-char (point-min))
1690 (forward-line 3))))
1692 (defun fancy-splash-frame ()
1693 "Return the frame to use for the fancy splash screen.
1694 Returning non-nil does not mean we should necessarily
1695 use the fancy splash screen, but if we do use it,
1696 we put it on this frame."
1697 (let (chosen-frame)
1698 (dolist (frame (append (frame-list) (list (selected-frame))))
1699 (if (and (frame-visible-p frame)
1700 (not (window-minibuffer-p (frame-selected-window frame))))
1701 (setq chosen-frame frame)))
1702 chosen-frame))
1704 (defun use-fancy-splash-screens-p ()
1705 "Return t if fancy splash screens should be used."
1706 (when (and (display-graphic-p)
1707 (or (and (display-color-p)
1708 (image-type-available-p 'xpm))
1709 (image-type-available-p 'pbm)))
1710 (let ((frame (fancy-splash-frame)))
1711 (when frame
1712 (let* ((img (create-image (or fancy-splash-image
1713 (if (and (display-color-p)
1714 (image-type-available-p 'xpm))
1715 "splash.xpm" "splash.pbm"))))
1716 (image-height (and img (cdr (image-size img nil frame))))
1717 ;; We test frame-height so that, if the frame is split
1718 ;; by displaying a warning, that doesn't cause the normal
1719 ;; splash screen to be used.
1720 (frame-height (1- (frame-height frame))))
1721 (> frame-height (+ image-height 19)))))))
1724 (defun normal-splash-screen (&optional startup concise)
1725 "Display non-graphic splash screen.
1726 If optional argument STARTUP is non-nil, display the startup screen
1727 after Emacs starts. If STARTUP is nil, display the About screen.
1728 If CONCISE is non-nil, display a concise version of the
1729 splash screen in another window."
1730 (let ((splash-buffer (get-buffer-create "*About GNU Emacs*")))
1731 (with-current-buffer splash-buffer
1732 (setq buffer-read-only nil)
1733 (erase-buffer)
1734 (setq default-directory command-line-default-directory)
1735 (set (make-local-variable 'tab-width) 8)
1737 (if pure-space-overflow
1738 (insert pure-space-overflow-message))
1740 ;; The convention for this piece of code is that
1741 ;; each piece of output starts with one or two newlines
1742 ;; and does not end with any newlines.
1743 (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs"))
1744 (insert
1745 (if (eq system-type 'gnu/linux)
1746 ", one component of the GNU/Linux operating system.\n"
1747 ", a part of the GNU operating system.\n"))
1749 (if startup
1750 (if (display-mouse-p)
1751 ;; The user can use the mouse to activate menus
1752 ;; so give help in terms of menu items.
1753 (normal-mouse-startup-screen)
1755 ;; No mouse menus, so give help using kbd commands.
1756 (normal-no-mouse-startup-screen))
1758 (normal-about-screen))
1760 ;; The rest of the startup screen is the same on all
1761 ;; kinds of terminals.
1763 ;; Give information on recovering, if there was a crash.
1764 (and startup
1765 auto-save-list-file-prefix
1766 ;; Don't signal an error if the
1767 ;; directory for auto-save-list files
1768 ;; does not yet exist.
1769 (file-directory-p (file-name-directory
1770 auto-save-list-file-prefix))
1771 (directory-files
1772 (file-name-directory auto-save-list-file-prefix)
1774 (concat "\\`"
1775 (regexp-quote (file-name-nondirectory
1776 auto-save-list-file-prefix)))
1778 (insert "\n\nIf an Emacs session crashed recently, "
1779 "type Meta-x recover-session RET\nto recover"
1780 " the files you were editing.\n"))
1782 (use-local-map splash-screen-keymap)
1784 ;; Display the input that we set up in the buffer.
1785 (set-buffer-modified-p nil)
1786 (setq buffer-read-only t)
1787 (if (and view-read-only (not view-mode))
1788 (view-mode-enter nil 'kill-buffer))
1789 (if startup (rename-buffer "*GNU Emacs*" t))
1790 (goto-char (point-min)))
1791 (if concise
1792 (display-buffer splash-buffer)
1793 (switch-to-buffer splash-buffer))))
1795 (defun normal-mouse-startup-screen ()
1796 ;; The user can use the mouse to activate menus
1797 ;; so give help in terms of menu items.
1798 (insert "\
1799 To follow a link, click Mouse-1 on it, or move to it and type RET.
1800 To quit a partially entered command, type Control-g.\n")
1802 (insert "\nImportant Help menu items:\n")
1803 (insert-button "Emacs Tutorial"
1804 'action (lambda (_button) (help-with-tutorial))
1805 'follow-link t)
1806 (insert "\t\tLearn basic Emacs keystroke commands\n")
1807 (insert-button "Read the Emacs Manual"
1808 'action (lambda (_button) (info-emacs-manual))
1809 'follow-link t)
1810 (insert "\tView the Emacs manual using Info\n")
1811 (insert-button "\(Non)Warranty"
1812 'action (lambda (_button) (describe-no-warranty))
1813 'follow-link t)
1814 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1815 (insert-button "Copying Conditions"
1816 'action (lambda (_button) (describe-copying))
1817 'follow-link t)
1818 (insert "\tConditions for redistributing and changing Emacs\n")
1819 (insert-button "More Manuals / Ordering Manuals"
1820 'action (lambda (_button) (view-order-manuals))
1821 'follow-link t)
1822 (insert " How to order printed manuals from the FSF\n")
1824 (insert "\nUseful tasks:\n")
1825 (insert-button "Visit New File"
1826 'action (lambda (_button) (call-interactively 'find-file))
1827 'follow-link t)
1828 (insert "\t\tSpecify a new file's name, to edit the file\n")
1829 (insert-button "Open Home Directory"
1830 'action (lambda (_button) (dired "~"))
1831 'follow-link t)
1832 (insert "\tOpen your home directory, to operate on its files\n")
1833 (insert-button "Customize Startup"
1834 'action (lambda (_button) (customize-group 'initialization))
1835 'follow-link t)
1836 (insert "\tChange initialization settings including this screen\n")
1838 (insert "\n" (emacs-version)
1839 "\n" emacs-copyright))
1841 ;; No mouse menus, so give help using kbd commands.
1842 (defun normal-no-mouse-startup-screen ()
1844 ;; If keys have their default meanings,
1845 ;; use precomputed string to save lots of time.
1846 (let* ((c-h-accessible
1847 ;; If normal-erase-is-backspace is used on a tty, there's
1848 ;; no way to invoke C-h and you have to use F1 instead.
1849 (or (not (char-table-p keyboard-translate-table))
1850 (eq (aref keyboard-translate-table ?\C-h) ?\C-h)))
1851 (minor-mode-overriding-map-alist
1852 (cons (cons (not c-h-accessible)
1853 ;; If C-h can't be invoked, temporarily disable its
1854 ;; binding, so where-is uses alternative bindings.
1855 (let ((map (make-sparse-keymap)))
1856 (define-key map [?\C-h] 'undefined)
1857 map))
1858 minor-mode-overriding-map-alist)))
1860 (insert (format "\nGet help\t %s\n"
1861 (let ((where (where-is-internal 'help-command nil t)))
1862 (cond
1863 ((equal where [?\C-h])
1864 "C-h (Hold down CTRL and press h)")
1865 (where (key-description where))
1866 (t "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]\n"))
1875 (insert-button "Emacs tutorial"
1876 'action (lambda (_button) (help-with-tutorial))
1877 'follow-link t)
1878 (insert (substitute-command-keys
1879 "\t \\[help-with-tutorial]\tUndo changes\t \\[undo]\n"))
1880 (insert-button "Buy manuals"
1881 'action (lambda (_button) (view-order-manuals))
1882 'follow-link t)
1883 (insert (substitute-command-keys
1884 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
1886 ;; Say how to use the menu bar with the keyboard.
1887 (insert "\n")
1888 (insert-button "Activate menubar"
1889 'action (lambda (_button) (tmm-menubar))
1890 'follow-link t)
1891 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1892 (eq (key-binding [f10]) 'tmm-menubar))
1893 (insert " F10 or ESC ` or M-`")
1894 (insert (substitute-command-keys " \\[tmm-menubar]")))
1896 ;; Many users seem to have problems with these.
1897 (insert "
1898 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1899 If you have no Meta key, you may instead type ESC followed by the character.)")
1901 ;; Insert links to useful tasks
1902 (insert "\nUseful tasks:\n")
1904 (insert-button "Visit New File"
1905 'action (lambda (_button) (call-interactively 'find-file))
1906 'follow-link t)
1907 (insert "\t\t\t")
1908 (insert-button "Open Home Directory"
1909 'action (lambda (_button) (dired "~"))
1910 'follow-link t)
1911 (insert "\n")
1913 (insert-button "Customize Startup"
1914 'action (lambda (_button) (customize-group 'initialization))
1915 'follow-link t)
1916 (insert "\t\t")
1917 (insert-button "Open *scratch* buffer"
1918 'action (lambda (_button) (switch-to-buffer
1919 (get-buffer-create "*scratch*")))
1920 'follow-link t)
1921 (insert "\n")
1922 (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
1924 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1925 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1926 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1927 (progn
1928 (insert
1930 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1931 (insert-button "full details"
1932 'action (lambda (_button) (describe-no-warranty))
1933 'follow-link t)
1934 (insert ".
1935 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1936 of Emacs and modify it; type C-h C-c to see ")
1937 (insert-button "the conditions"
1938 'action (lambda (_button) (describe-copying))
1939 'follow-link t)
1940 (insert ".
1941 Type C-h C-d for information on ")
1942 (insert-button "getting the latest version"
1943 'action (lambda (_button) (describe-distribution))
1944 'follow-link t)
1945 (insert "."))
1946 (insert (substitute-command-keys
1948 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1949 (insert-button "full details"
1950 'action (lambda (_button) (describe-no-warranty))
1951 'follow-link t)
1952 (insert (substitute-command-keys ".
1953 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1954 of Emacs and modify it; type \\[describe-copying] to see "))
1955 (insert-button "the conditions"
1956 'action (lambda (_button) (describe-copying))
1957 'follow-link t)
1958 (insert (substitute-command-keys".
1959 Type \\[describe-distribution] for information on "))
1960 (insert-button "getting the latest version"
1961 'action (lambda (_button) (describe-distribution))
1962 'follow-link t)
1963 (insert ".")))
1965 (defun normal-about-screen ()
1966 (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n")
1968 (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n")
1970 (insert-button "Authors"
1971 'action
1972 (lambda (_button)
1973 (view-file (expand-file-name "AUTHORS" data-directory))
1974 (goto-char (point-min)))
1975 'follow-link t)
1976 (insert "\t\tMany people have contributed code included in GNU Emacs\n")
1978 (insert-button "Contributing"
1979 'action
1980 (lambda (_button)
1981 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1982 (goto-char (point-min)))
1983 'follow-link t)
1984 (insert "\tHow to contribute improvements to Emacs\n\n")
1986 (insert-button "GNU and Freedom"
1987 'action (lambda (_button) (describe-gnu-project))
1988 'follow-link t)
1989 (insert "\t\tWhy we developed GNU Emacs and the GNU system\n")
1991 (insert-button "Absence of Warranty"
1992 'action (lambda (_button) (describe-no-warranty))
1993 'follow-link t)
1994 (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1996 (insert-button "Copying Conditions"
1997 'action (lambda (_button) (describe-copying))
1998 'follow-link t)
1999 (insert "\tConditions for redistributing and changing Emacs\n")
2001 (insert-button "Getting New Versions"
2002 'action (lambda (_button) (describe-distribution))
2003 'follow-link t)
2004 (insert "\tHow to get the latest version of GNU Emacs\n")
2006 (insert-button "More Manuals / Ordering Manuals"
2007 'action (lambda (_button) (view-order-manuals))
2008 'follow-link t)
2009 (insert "\tBuying printed manuals from the FSF\n"))
2011 (defun startup-echo-area-message ()
2012 (cond ((daemonp)
2013 "Starting Emacs daemon.")
2014 ((eq (key-binding "\C-h\C-a") 'about-emacs)
2015 "For information about GNU Emacs and the GNU system, type C-h C-a.")
2017 (substitute-command-keys
2018 "For information about GNU Emacs and the GNU system, type \
2019 \\[about-emacs]."))))
2021 (defun display-startup-echo-area-message ()
2022 (let ((resize-mini-windows t))
2023 (or noninteractive ;(input-pending-p) init-file-had-error
2024 ;; t if the init file says to inhibit the echo area startup message.
2025 (and inhibit-startup-echo-area-message
2026 user-init-file
2027 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
2028 (equal inhibit-startup-echo-area-message
2029 (if (equal init-file-user "")
2030 (user-login-name)
2031 init-file-user)))
2032 ;; Wasn't set with custom; see if .emacs has a setq.
2033 (condition-case nil
2034 (with-temp-buffer
2035 (insert-file-contents user-init-file)
2036 (re-search-forward
2037 (concat
2038 "([ \t\n]*setq[ \t\n]+"
2039 "inhibit-startup-echo-area-message[ \t\n]+"
2040 (regexp-quote
2041 (prin1-to-string
2042 (if (equal init-file-user "")
2043 (user-login-name)
2044 init-file-user)))
2045 "[ \t\n]*)")
2046 nil t))
2047 (error nil))))
2048 (message "%s" (startup-echo-area-message)))))
2050 (defun display-startup-screen (&optional concise)
2051 "Display startup screen according to display.
2052 A fancy display is used on graphic displays, normal otherwise.
2054 If CONCISE is non-nil, display a concise version of the startup
2055 screen."
2056 ;; Prevent recursive calls from server-process-filter.
2057 (if (not (get-buffer "*GNU Emacs*"))
2058 (if (use-fancy-splash-screens-p)
2059 (fancy-startup-screen concise)
2060 (normal-splash-screen t concise))))
2062 (defun display-about-screen ()
2063 "Display the *About GNU Emacs* buffer.
2064 A fancy display is used on graphic displays, normal otherwise."
2065 (interactive)
2066 (if (use-fancy-splash-screens-p)
2067 (fancy-about-screen)
2068 (normal-splash-screen nil)))
2070 (defalias 'about-emacs 'display-about-screen)
2071 (defalias 'display-splash-screen 'display-startup-screen)
2073 (defun command-line-1 (args-left)
2074 (display-startup-echo-area-message)
2075 (when (and pure-space-overflow
2076 (not noninteractive))
2077 (display-warning
2078 'initialization
2079 "Building Emacs overflowed pure space.\
2080 (See the node Pure Storage in the Lisp manual for details.)"
2081 :warning))
2083 (let ((file-count 0)
2084 (command-line-args-left args-left)
2085 first-file-buffer)
2086 (when command-line-args-left
2087 ;; We have command args; process them.
2088 (let ((dir command-line-default-directory)
2090 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
2091 ;; if foo is intended to be found in DIR.
2093 ;; ;; The directories listed in --directory/-L options will *appear*
2094 ;; ;; at the front of `load-path' in the order they appear on the
2095 ;; ;; command-line. We cannot do this by *placing* them at the front
2096 ;; ;; in the order they appear, so we need this variable to hold them,
2097 ;; ;; temporarily.
2098 ;; extra-load-path
2100 ;; To DTRT we keep track of the splice point and modify `load-path'
2101 ;; straight away upon any --directory/-L option.
2102 splice
2103 just-files ;; t if this follows the magic -- option.
2104 ;; This includes our standard options' long versions
2105 ;; and long versions of what's on command-switch-alist.
2106 (longopts
2107 (append '("--funcall" "--load" "--insert" "--kill"
2108 "--directory" "--eval" "--execute" "--no-splash"
2109 "--find-file" "--visit" "--file" "--no-desktop")
2110 (mapcar (lambda (elt) (concat "-" (car elt)))
2111 command-switch-alist)))
2112 (line 0)
2113 (column 0))
2115 ;; Add the long X options to longopts.
2116 (dolist (tem command-line-x-option-alist)
2117 (if (string-match "^--" (car tem))
2118 (push (car tem) longopts)))
2120 ;; Add the long NS options to longopts.
2121 (dolist (tem command-line-ns-option-alist)
2122 (if (string-match "^--" (car tem))
2123 (push (list (car tem)) longopts)))
2125 ;; Loop, processing options.
2126 (while command-line-args-left
2127 (let* ((argi (car command-line-args-left))
2128 (orig-argi argi)
2129 argval completion)
2130 (setq command-line-args-left (cdr command-line-args-left))
2132 ;; Do preliminary decoding of the option.
2133 (if just-files
2134 ;; After --, don't look for options; treat all args as files.
2135 (setq argi "")
2136 ;; Convert long options to ordinary options
2137 ;; and separate out an attached option argument into argval.
2138 (when (string-match "\\`\\(--[^=]*\\)=" argi)
2139 (setq argval (substring argi (match-end 0))
2140 argi (match-string 1 argi)))
2141 (when (string-match "\\`--?[^-]" orig-argi)
2142 (setq completion (try-completion argi longopts))
2143 (if (eq completion t)
2144 (setq argi (substring argi 1))
2145 (if (stringp completion)
2146 (let ((elt (member completion longopts)))
2147 (or elt
2148 (error "Option `%s' is ambiguous" argi))
2149 (setq argi (substring (car elt) 1)))
2150 (setq argval nil
2151 argi orig-argi)))))
2153 ;; Execute the option.
2154 (cond ((setq tem (assoc argi command-switch-alist))
2155 (if argval
2156 (let ((command-line-args-left
2157 (cons argval command-line-args-left)))
2158 (funcall (cdr tem) argi))
2159 (funcall (cdr tem) argi)))
2161 ((equal argi "-no-splash")
2162 (setq inhibit-startup-screen t))
2164 ((member argi '("-f" ; what the manual claims
2165 "-funcall"
2166 "-e")) ; what the source used to say
2167 (setq inhibit-startup-screen t)
2168 (setq tem (intern (or argval (pop command-line-args-left))))
2169 (if (commandp tem)
2170 (command-execute tem)
2171 (funcall tem)))
2173 ((member argi '("-eval" "-execute"))
2174 (setq inhibit-startup-screen t)
2175 (eval (read (or argval (pop command-line-args-left)))))
2177 ((member argi '("-L" "-directory"))
2178 (setq tem (expand-file-name
2179 (command-line-normalize-file-name
2180 (or argval (pop command-line-args-left)))))
2181 (cond (splice (setcdr splice (cons tem (cdr splice)))
2182 (setq splice (cdr splice)))
2183 (t (setq load-path (cons tem load-path)
2184 splice load-path))))
2186 ((member argi '("-l" "-load"))
2187 (let* ((file (command-line-normalize-file-name
2188 (or argval (pop command-line-args-left))))
2189 ;; Take file from default dir if it exists there;
2190 ;; otherwise let `load' search for it.
2191 (file-ex (expand-file-name file)))
2192 (when (file-exists-p file-ex)
2193 (setq file file-ex))
2194 (load file nil t)))
2196 ;; This is used to handle -script. It's not clear
2197 ;; we need to document it (it is totally internal).
2198 ((member argi '("-scriptload"))
2199 (let* ((file (command-line-normalize-file-name
2200 (or argval (pop command-line-args-left))))
2201 ;; Take file from default dir.
2202 (file-ex (expand-file-name file)))
2203 (load file-ex nil t t)))
2205 ((equal argi "-insert")
2206 (setq inhibit-startup-screen t)
2207 (setq tem (or argval (pop command-line-args-left)))
2208 (or (stringp tem)
2209 (error "File name omitted from `-insert' option"))
2210 (insert-file-contents (command-line-normalize-file-name tem)))
2212 ((equal argi "-kill")
2213 (kill-emacs t))
2215 ;; This is for when they use --no-desktop with -q, or
2216 ;; don't load Desktop in their .emacs. If desktop.el
2217 ;; _is_ loaded, it will handle this switch, and we
2218 ;; won't see it by the time we get here.
2219 ((equal argi "-no-desktop")
2220 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
2222 ((string-match "^\\+[0-9]+\\'" argi)
2223 (setq line (string-to-number argi)))
2225 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
2226 (setq line (string-to-number (match-string 1 argi))
2227 column (string-to-number (match-string 2 argi))))
2229 ((setq tem (assoc orig-argi command-line-x-option-alist))
2230 ;; Ignore X-windows options and their args if not using X.
2231 (setq command-line-args-left
2232 (nthcdr (nth 1 tem) command-line-args-left)))
2234 ((setq tem (assoc orig-argi command-line-ns-option-alist))
2235 ;; Ignore NS-windows options and their args if not using NS.
2236 (setq command-line-args-left
2237 (nthcdr (nth 1 tem) command-line-args-left)))
2239 ((member argi '("-find-file" "-file" "-visit"))
2240 (setq inhibit-startup-screen t)
2241 ;; An explicit option to specify visiting a file.
2242 (setq tem (or argval (pop command-line-args-left)))
2243 (unless (stringp tem)
2244 (error "File name omitted from `%s' option" argi))
2245 (setq file-count (1+ file-count))
2246 (let ((file (expand-file-name
2247 (command-line-normalize-file-name tem)
2248 dir)))
2249 (if (= file-count 1)
2250 (setq first-file-buffer (find-file file))
2251 (find-file-other-window file)))
2252 (unless (zerop line)
2253 (goto-char (point-min))
2254 (forward-line (1- line)))
2255 (setq line 0)
2256 (unless (< column 1)
2257 (move-to-column (1- column)))
2258 (setq column 0))
2260 ;; These command lines now have no effect.
2261 ((string-match "\\`--?\\(no-\\)?\\(uni\\|multi\\)byte$" argi)
2262 (display-warning 'initialization
2263 (format "Ignoring obsolete arg %s" argi)))
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 inhibit-x-resources)
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 (and (memq system-type '(ms-dos windows-nt))
2377 (string-match "^[A-Za-z]:\\(\\\\[\\\\/]\\)" file) ; C:\/ or C:\\
2378 (setq file (replace-match "/" t t file 1)))
2379 (while (string-match "//+" file 1)
2380 (setq file (replace-match "/" t t file)))
2381 file))
2383 ;;; startup.el ends here