(Fforward_comment): Revert the reversion.
[emacs.git] / lisp / startup.el
blobd41c812565f87adc142c7e716f582b1470481247
1 ;;; startup.el --- process Emacs shell arguments
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 ;; 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: internal
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 2, or (at your option)
14 ;; 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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; This file parses the command line and gets Emacs running. Options
29 ;; on the command line are handled in precedence order. For priorities
30 ;; see the structure standard_args in the emacs.c file.
32 ;;; Code:
34 (setq top-level '(normal-top-level))
36 (defvar command-line-processed nil
37 "Non-nil once command line has been processed.")
39 (defgroup initialization nil
40 "Emacs start-up procedure."
41 :group 'internal)
43 (defcustom inhibit-splash-screen nil
44 "Non-nil inhibits the startup screen.
45 It also inhibits display of the initial message in the *scratch* buffer.
47 This is for use in your personal init file, once you are familiar
48 with the contents of the startup screen."
49 :type 'boolean
50 :group 'initialization)
52 (defvaralias 'inhibit-startup-message 'inhibit-splash-screen)
54 (defcustom inhibit-startup-echo-area-message nil
55 "*Non-nil inhibits the initial startup echo area message.
56 Setting this variable takes effect
57 only if you do it with the customization buffer
58 or if your `.emacs' file contains a line of this form:
59 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
60 If your `.emacs' file is byte-compiled, use the following form instead:
61 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
62 Thus, someone else using a copy of your `.emacs' file will see
63 the startup message unless he personally acts to inhibit it."
64 :type '(choice (const :tag "Don't inhibit")
65 (string :tag "Enter your user name, to inhibit"))
66 :group 'initialization)
68 (defcustom inhibit-default-init nil
69 "*Non-nil inhibits loading the `default' library."
70 :type 'boolean
71 :group 'initialization)
73 (defcustom inhibit-startup-buffer-menu nil
74 "*Non-nil inhibits display of buffer list when more than 2 files are loaded."
75 :type 'boolean
76 :group 'initialization)
78 (defvar command-switch-alist nil
79 "Alist of command-line switches.
80 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
81 HANDLER-FUNCTION receives the switch string as its sole argument;
82 the remaining command-line args are in the variable `command-line-args-left'.")
84 (defvar command-line-args-left nil
85 "List of command-line args not yet processed.")
87 (defvar command-line-functions nil ;; lrs 7/31/89
88 "List of functions to process unrecognized command-line arguments.
89 Each function should access the dynamically bound variables
90 `argi' (the current argument) and `command-line-args-left' (the remaining
91 arguments). The function should return non-nil only if it recognizes and
92 processes `argi'. If it does so, it may consume successive arguments by
93 altering `command-line-args-left' to remove them.")
95 (defvar command-line-default-directory nil
96 "Default directory to use for command line arguments.
97 This is normally copied from `default-directory' when Emacs starts.")
99 ;;; This is here, rather than in x-win.el, so that we can ignore these
100 ;;; options when we are not using X.
101 (defconst command-line-x-option-alist
102 '(("-bw" 1 x-handle-numeric-switch border-width)
103 ("-d" 1 x-handle-display)
104 ("-display" 1 x-handle-display)
105 ("-name" 1 x-handle-name-switch)
106 ("-title" 1 x-handle-switch title)
107 ("-T" 1 x-handle-switch title)
108 ("-r" 0 x-handle-switch reverse t)
109 ("-rv" 0 x-handle-switch reverse t)
110 ("-reverse" 0 x-handle-switch reverse t)
111 ("-reverse-video" 0 x-handle-switch reverse t)
112 ("-fn" 1 x-handle-switch font)
113 ("-font" 1 x-handle-switch font)
114 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
115 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
116 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
117 ("-ib" 1 x-handle-numeric-switch internal-border-width)
118 ("-g" 1 x-handle-geometry)
119 ("-lsp" 1 x-handle-numeric-switch line-spacing)
120 ("-geometry" 1 x-handle-geometry)
121 ("-fg" 1 x-handle-switch foreground-color)
122 ("-foreground" 1 x-handle-switch foreground-color)
123 ("-bg" 1 x-handle-switch background-color)
124 ("-background" 1 x-handle-switch background-color)
125 ("-ms" 1 x-handle-switch mouse-color)
126 ("-nbi" 0 x-handle-switch icon-type nil)
127 ("-iconic" 0 x-handle-iconic)
128 ("-xrm" 1 x-handle-xrm-switch)
129 ("-cr" 1 x-handle-switch cursor-color)
130 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
131 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
132 ("-bd" 1 x-handle-switch)
133 ("--border-width" 1 x-handle-numeric-switch border-width)
134 ("--display" 1 x-handle-display)
135 ("--name" 1 x-handle-name-switch)
136 ("--title" 1 x-handle-switch title)
137 ("--reverse-video" 0 x-handle-switch reverse t)
138 ("--font" 1 x-handle-switch font)
139 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
140 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
141 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
142 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
143 ("--geometry" 1 x-handle-geometry)
144 ("--foreground-color" 1 x-handle-switch foreground-color)
145 ("--background-color" 1 x-handle-switch background-color)
146 ("--mouse-color" 1 x-handle-switch mouse-color)
147 ("--no-bitmap-icon" 0 x-handle-switch icon-type nil)
148 ("--iconic" 0 x-handle-iconic)
149 ("--xrm" 1 x-handle-xrm-switch)
150 ("--cursor-color" 1 x-handle-switch cursor-color)
151 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
152 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
153 ("--border-color" 1 x-handle-switch border-color)
154 ("--smid" 1 x-handle-smid))
155 "Alist of X Windows options.
156 Each element has the form
157 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
158 where NAME is the option name string, NUMARGS is the number of arguments
159 that the option accepts, HANDLER is a function to call to handle the option.
160 FRAME-PARAM (optional) is the frame parameter this option specifies,
161 and VALUE is the value which is given to that frame parameter
162 \(most options use the argument for this, so VALUE is not present).")
164 (defvar before-init-hook nil
165 "Normal hook run after handling urgent options but before loading init files.")
167 (defvar after-init-hook nil
168 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
169 There is no `condition-case' around the running of these functions;
170 therefore, if you set `debug-on-error' non-nil in `.emacs',
171 an error in one of these functions will invoke the debugger.")
173 (defvar emacs-startup-hook nil
174 "Normal hook run after loading init files and handling the command line.")
176 (defvar term-setup-hook nil
177 "Normal hook run after loading terminal-specific Lisp code.
178 It also follows `emacs-startup-hook'. This hook exists for users to set,
179 so as to override the definitions made by the terminal-specific file.
180 Emacs never sets this variable itself.")
182 (defvar inhibit-startup-hooks nil
183 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
184 This is because we already did so.")
186 (defvar keyboard-type nil
187 "The brand of keyboard you are using.
188 This variable is used to define the proper function and keypad
189 keys for use under X. It is used in a fashion analogous to the
190 environment variable TERM.")
192 (defvar window-setup-hook nil
193 "Normal hook run to initialize window system display.
194 Emacs runs this hook after processing the command line arguments and loading
195 the user's init file.")
197 (defcustom initial-major-mode 'lisp-interaction-mode
198 "Major mode command symbol to use for the initial *scratch* buffer."
199 :type 'function
200 :group 'initialization)
202 (defvar init-file-user nil
203 "Identity of user whose `.emacs' file is or was read.
204 The value is nil if `-q' or `--no-init-file' was specified,
205 meaning do not load any init file.
207 Otherwise, the value may be an empty string, meaning
208 use the init file for the user who originally logged in,
209 or it may be a string containing a user's name meaning
210 use that person's init file.
212 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
213 evaluates to the name of the directory where the `.emacs' file was
214 looked for.
216 Setting `init-file-user' does not prevent Emacs from loading
217 `site-start.el'. The only way to do that is to use `--no-site-file'.")
219 (defcustom site-run-file "site-start"
220 "File containing site-wide run-time initializations.
221 This file is loaded at run-time before `~/.emacs'. It contains inits
222 that need to be in place for the entire site, but which, due to their
223 higher incidence of change, don't make sense to load into Emacs's
224 dumped image. Thus, the run-time load order is: 1. file described in
225 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
227 Don't use the `site-start.el' file for things some users may not like.
228 Put them in `default.el' instead, so that users can more easily
229 override them. Users can prevent loading `default.el' with the `-q'
230 option or by setting `inhibit-default-init' in their own init files,
231 but inhibiting `site-start.el' requires `--no-site-file', which
232 is less convenient.
234 This variable is defined for customization so as to make
235 it visible in the relevant context. However, actually customizing it
236 is not allowed, since it would not work anyway. The only way to set
237 this variable usefully is to set it while building and dumping Emacs."
238 :type '(choice (const :tag "none" nil) string)
239 :group 'initialization
240 :initialize 'custom-initialize-default
241 :set '(lambda (variable value)
242 (error "Customizing `site-run-file' does not work")))
244 (defcustom mail-host-address nil
245 "*Name of this machine, for purposes of naming users."
246 :type '(choice (const nil) string)
247 :group 'mail)
249 (defcustom user-mail-address (if command-line-processed
250 (concat (user-login-name) "@"
251 (or mail-host-address
252 (system-name)))
253 ;; Empty string means "not set yet".
255 "*Full mailing address of this user.
256 This is initialized based on `mail-host-address',
257 after your init file is read, in case it sets `mail-host-address'."
258 :type 'string
259 :group 'mail)
261 (defcustom auto-save-list-file-prefix
262 (cond ((eq system-type 'ms-dos)
263 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
264 "~/_emacs.d/auto-save.list/_s")
266 "~/.emacs.d/auto-save-list/.saves-"))
267 "Prefix for generating `auto-save-list-file-name'.
268 This is used after reading your `.emacs' file to initialize
269 `auto-save-list-file-name', by appending Emacs's pid and the system name,
270 if you have not already set `auto-save-list-file-name' yourself.
271 Directories in the prefix will be created if necessary.
272 Set this to nil if you want to prevent `auto-save-list-file-name'
273 from being initialized."
274 :type '(choice (const :tag "Don't record a session's auto save list" nil)
275 string)
276 :group 'auto-save)
278 (defvar emacs-quick-startup nil)
280 (defvar emacs-basic-display nil)
282 (defvar init-file-debug nil)
284 (defvar init-file-had-error nil)
286 (defvar normal-top-level-add-subdirs-inode-list nil)
288 (defvar no-blinking-cursor nil)
290 (defvar default-frame-background-mode)
292 (defvar pure-space-overflow nil
293 "Non-nil if building Emacs overflowed pure space.")
295 (defun normal-top-level-add-subdirs-to-load-path ()
296 "Add all subdirectories of current directory to `load-path'.
297 More precisely, this uses only the subdirectories whose names
298 start with letters or digits; it excludes any subdirectory named `RCS'
299 or `CVS', and any subdirectory that contains a file named `.nosearch'."
300 (let (dirs
301 attrs
302 (pending (list default-directory)))
303 ;; This loop does a breadth-first tree walk on DIR's subtree,
304 ;; putting each subdir into DIRS as its contents are examined.
305 (while pending
306 (push (pop pending) dirs)
307 (let* ((this-dir (car dirs))
308 (contents (directory-files this-dir))
309 (default-directory this-dir)
310 (canonicalized (if (fboundp 'untranslated-canonical-name)
311 (untranslated-canonical-name this-dir))))
312 ;; The Windows version doesn't report meaningful inode
313 ;; numbers, so use the canonicalized absolute file name of the
314 ;; directory instead.
315 (setq attrs (or canonicalized
316 (nthcdr 10 (file-attributes this-dir))))
317 (unless (member attrs normal-top-level-add-subdirs-inode-list)
318 (push attrs normal-top-level-add-subdirs-inode-list)
319 (dolist (file contents)
320 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
321 (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs"))
322 (when (and (string-match "\\`[[:alnum:]]" file)
323 ;; Avoid doing a `stat' when it isn't necessary
324 ;; because that can cause trouble when an NFS server
325 ;; is down.
326 (not (string-match "\\.elc?\\'" file))
327 (file-directory-p file))
328 (let ((expanded (expand-file-name file)))
329 (unless (file-exists-p (expand-file-name ".nosearch"
330 expanded))
331 (setq pending (nconc pending (list expanded)))))))))))
332 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
334 ;; This function is called from a subdirs.el file.
335 ;; It assumes that default-directory is the directory
336 ;; in which the subdirs.el file exists,
337 ;; and it adds to load-path the subdirs of that directory
338 ;; as specified in DIRS. Normally the elements of DIRS are relative.
339 (defun normal-top-level-add-to-load-path (dirs)
340 (let ((tail load-path)
341 (thisdir (directory-file-name default-directory)))
342 (while (and tail
343 ;;Don't go all the way to the nil terminator.
344 (cdr tail)
345 (not (equal thisdir (car tail)))
346 (not (and (memq system-type '(ms-dos windows-nt))
347 (equal (downcase thisdir) (downcase (car tail))))))
348 (setq tail (cdr tail)))
349 ;;Splice the new section in.
350 (when tail
351 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
353 (defun normal-top-level ()
354 (if command-line-processed
355 (message "Back to top level.")
356 (setq command-line-processed t)
357 ;; Give *Messages* the same default-directory as *scratch*,
358 ;; just to keep things predictable.
359 (let ((dir default-directory))
360 (with-current-buffer "*Messages*"
361 (setq default-directory dir)))
362 ;; `user-full-name' is now known; reset its standard-value here.
363 (put 'user-full-name 'standard-value
364 (list (default-value 'user-full-name)))
365 ;; For root, preserve owner and group when editing files.
366 (if (equal (user-uid) 0)
367 (setq backup-by-copying-when-mismatch t))
368 ;; Look in each dir in load-path for a subdirs.el file.
369 ;; If we find one, load it, which will add the appropriate subdirs
370 ;; of that dir into load-path,
371 ;; Look for a leim-list.el file too. Loading it will register
372 ;; available input methods.
373 (let ((tail load-path) dir)
374 (while tail
375 (setq dir (car tail))
376 (let ((default-directory dir))
377 (load (expand-file-name "subdirs.el") t t t))
378 (let ((default-directory dir))
379 (load (expand-file-name "leim-list.el") t t t))
380 ;; We don't use a dolist loop and we put this "setq-cdr" command at
381 ;; the end, because the subdirs.el files may add elements to the end
382 ;; of load-path and we want to take it into account.
383 (setq tail (cdr tail))))
384 (unless (eq system-type 'vax-vms)
385 ;; If the PWD environment variable isn't accurate, delete it.
386 (let ((pwd (getenv "PWD")))
387 (and (stringp pwd)
388 ;; Use FOO/., so that if FOO is a symlink, file-attributes
389 ;; describes the directory linked to, not FOO itself.
390 (or (equal (file-attributes
391 (concat (file-name-as-directory pwd) "."))
392 (file-attributes
393 (concat (file-name-as-directory default-directory)
394 ".")))
395 (setq process-environment
396 (delete (concat "PWD=" pwd)
397 process-environment))))))
398 (setq default-directory (abbreviate-file-name default-directory))
399 (let ((menubar-bindings-done nil))
400 (unwind-protect
401 (command-line)
402 ;; Do this again, in case .emacs defined more abbreviations.
403 (setq default-directory (abbreviate-file-name default-directory))
404 ;; Specify the file for recording all the auto save files of this session.
405 ;; This is used by recover-session.
406 (or auto-save-list-file-name
407 (and auto-save-list-file-prefix
408 (setq auto-save-list-file-name
409 ;; Under MS-DOS our PID is almost always reused between
410 ;; Emacs invocations. We need something more unique.
411 (cond ((eq system-type 'ms-dos)
412 ;; We are going to access the auto-save
413 ;; directory, so make sure it exists.
414 (make-directory
415 (file-name-directory auto-save-list-file-prefix)
417 (concat
418 (make-temp-name
419 (expand-file-name
420 auto-save-list-file-prefix))
421 "~"))
423 (expand-file-name
424 (format "%s%d-%s~"
425 auto-save-list-file-prefix
426 (emacs-pid)
427 (system-name))))))))
428 (unless inhibit-startup-hooks
429 (run-hooks 'emacs-startup-hook)
430 (and term-setup-hook
431 (run-hooks 'term-setup-hook)))
433 ;; Don't do this if we failed to create the initial frame,
434 ;; for instance due to a dense colormap.
435 (when (or frame-initial-frame
436 ;; If frame-initial-frame has no meaning, do this anyway.
437 (not (and window-system
438 (not noninteractive)
439 (not (eq window-system 'pc)))))
440 ;; Modify the initial frame based on what .emacs puts into
441 ;; ...-frame-alist.
442 (if (fboundp 'frame-notice-user-settings)
443 (frame-notice-user-settings))
444 (if (fboundp 'frame-set-background-mode)
445 ;; Set the faces for the initial background mode even if
446 ;; frame-notice-user-settings didn't (such as on a tty).
447 ;; frame-set-background-mode is idempotent, so it won't
448 ;; cause any harm if it's already been done.
449 (let ((frame (selected-frame))
450 term)
451 (when (and (null window-system)
452 ;; Don't override default set by files in lisp/term.
453 (null default-frame-background-mode)
454 (let ((bg (frame-parameter frame 'background-color)))
455 (or (null bg)
456 (member bg '(unspecified "unspecified-bg"
457 "unspecified-fg")))))
459 (setq term (getenv "TERM"))
460 ;; Some files in lisp/term do a better job with the
461 ;; background mode, but we leave this here anyway, in
462 ;; case they remove those files.
463 (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
464 term)
465 (setq default-frame-background-mode 'light)))
466 (frame-set-background-mode (selected-frame)))))
468 ;; Now we know the user's default font, so add it to the menu.
469 (if (fboundp 'font-menu-add-default)
470 (font-menu-add-default))
471 (and window-setup-hook
472 (run-hooks 'window-setup-hook))
473 (or menubar-bindings-done
474 (if (display-popup-menus-p)
475 (precompute-menubar-bindings)))))))
477 ;; Precompute the keyboard equivalents in the menu bar items.
478 (defun precompute-menubar-bindings ()
479 (let ((submap (lookup-key global-map [menu-bar])))
480 (while submap
481 (and (consp (car submap))
482 (symbolp (car (car submap)))
483 (stringp (car-safe (cdr (car submap))))
484 (keymapp (cdr (cdr (car submap))))
485 (progn
486 (x-popup-menu nil (cdr (cdr (car submap))))
487 (if purify-flag
488 (garbage-collect))))
489 (setq submap (cdr submap))))
490 (setq define-key-rebound-commands t))
492 ;; Command-line options supported by tty's:
493 (defconst tty-long-option-alist
494 '(("--name" . "-name")
495 ("--title" . "-T")
496 ("--reverse-video" . "-reverse")
497 ("--foreground-color" . "-fg")
498 ("--background-color" . "-bg")
499 ("--color" . "-color")))
501 (defconst tool-bar-images-pixel-height 24
502 "Height in pixels of images in the tool bar.")
504 (defvar tool-bar-originally-present nil
505 "Non-nil if tool-bars are present before user and site init files are read.")
507 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
508 (defun tty-handle-args (args)
509 (let (rest)
510 (message "%s" args)
511 (while (and args
512 (not (equal (car args) "--")))
513 (let* ((argi (pop args))
514 (orig-argi argi)
515 argval completion)
516 ;; Check for long options with attached arguments
517 ;; and separate out the attached option argument into argval.
518 (when (string-match "^\\(--[^=]*\\)=" argi)
519 (setq argval (substring argi (match-end 0))
520 argi (match-string 1 argi)))
521 (when (string-match "^--" argi)
522 (setq completion (try-completion argi tty-long-option-alist))
523 (if (eq completion t)
524 ;; Exact match for long option.
525 (setq argi (cdr (assoc argi tty-long-option-alist)))
526 (if (stringp completion)
527 (let ((elt (assoc completion tty-long-option-alist)))
528 ;; Check for abbreviated long option.
529 (or elt
530 (error "Option `%s' is ambiguous" argi))
531 (setq argi (cdr elt)))
532 ;; Check for a short option.
533 (setq argval nil
534 argi orig-argi))))
535 (cond ((member argi '("-fg" "-foreground"))
536 (push (cons 'foreground-color (or argval (pop args)))
537 default-frame-alist))
538 ((member argi '("-bg" "-background"))
539 (push (cons 'background-color (or argval (pop args)))
540 default-frame-alist))
541 ((member argi '("-T" "-name"))
542 (unless argval (setq argval (pop args)))
543 (push (cons 'title
544 (if (stringp argval)
545 argval
546 (let ((case-fold-search t)
548 (setq argval (invocation-name))
550 ;; Change any . or * characters in name to
551 ;; hyphens, so as to emulate behavior on X.
552 (while
553 (setq i (string-match "[.*]" argval))
554 (aset argval i ?-))
555 argval)))
556 default-frame-alist))
557 ((member argi '("-r" "-rv" "-reverse"))
558 (push '(reverse . t)
559 default-frame-alist))
560 ((equal argi "-color")
561 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
562 (push (cons 'tty-color-mode
563 (cond
564 ((numberp argval) argval)
565 ((string-match "-?[0-9]+" argval)
566 (string-to-number argval))
567 (t (intern argval))))
568 default-frame-alist))
570 (push argi rest)))))
571 (nreverse rest)))
573 (defun command-line ()
574 (setq command-line-default-directory default-directory)
576 ;; Choose a reasonable location for temporary files.
577 (custom-reevaluate-setting 'temporary-file-directory)
578 (custom-reevaluate-setting 'small-temporary-file-directory)
579 (custom-reevaluate-setting 'auto-save-file-name-transforms)
581 ;; See if we should import version-control from the environment variable.
582 (let ((vc (getenv "VERSION_CONTROL")))
583 (cond ((eq vc nil)) ;don't do anything if not set
584 ((member vc '("t" "numbered"))
585 (setq version-control t))
586 ((member vc '("nil" "existing"))
587 (setq version-control nil))
588 ((member vc '("never" "simple"))
589 (setq version-control 'never))))
591 ;;! This has been commented out; I currently find the behavior when
592 ;;! split-window-keep-point is nil disturbing, but if I can get used
593 ;;! to it, then it would be better to eliminate the option.
594 ;;! ;; Choose a good default value for split-window-keep-point.
595 ;;! (setq split-window-keep-point (> baud-rate 2400))
597 ;; Set the default strings to display in mode line for
598 ;; end-of-line formats that aren't native to this platform.
599 (cond
600 ((memq system-type '(ms-dos windows-nt emx))
601 (setq eol-mnemonic-unix "(Unix)"
602 eol-mnemonic-mac "(Mac)"))
603 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
604 ;; abbreviated strings `/' and `:' set in coding.c for them.
605 ((eq system-type 'macos)
606 (setq eol-mnemonic-dos "(DOS)"))
607 (t ; this is for Unix/GNU/Linux systems
608 (setq eol-mnemonic-dos "(DOS)"
609 eol-mnemonic-mac "(Mac)")))
611 ;; Read window system's init file if using a window system.
612 (condition-case error
613 (if (and window-system (not noninteractive))
614 (load (concat term-file-prefix
615 (symbol-name window-system)
616 "-win")
617 ;; Every window system should have a startup file;
618 ;; barf if we can't find it.
619 nil t))
620 ;; If we can't read it, print the error message and exit.
621 (error
622 (princ
623 (if (eq (car error) 'error)
624 (apply 'concat (cdr error))
625 (if (memq 'file-error (get (car error) 'error-conditions))
626 (format "%s: %s"
627 (nth 1 error)
628 (mapconcat (lambda (obj) (prin1-to-string obj t))
629 (cdr (cdr error)) ", "))
630 (format "%s: %s"
631 (get (car error) 'error-message)
632 (mapconcat (lambda (obj) (prin1-to-string obj t))
633 (cdr error) ", "))))
634 'external-debugging-output)
635 (terpri 'external-debugging-output)
636 (setq window-system nil)
637 (kill-emacs)))
639 ;; Windowed displays do this inside their *-win.el.
640 (unless (or (display-graphic-p) noninteractive)
641 (setq command-line-args (tty-handle-args command-line-args)))
643 (set-locale-environment nil)
645 ;; Convert preloaded file names to absolute.
646 (let ((lisp-dir
647 (file-truename
648 (file-name-directory
649 (locate-file "simple" load-path
650 (get-load-suffixes))))))
652 (setq load-history
653 (mapcar (lambda (elt)
654 (if (and (stringp (car elt))
655 (not (file-name-absolute-p (car elt))))
656 (cons (concat lisp-dir
657 (car elt))
658 (cdr elt))
659 elt))
660 load-history)))
662 ;; Convert the arguments to Emacs internal representation.
663 (let ((args (cdr command-line-args)))
664 (while args
665 (setcar args
666 (decode-coding-string (car args) locale-coding-system t))
667 (pop args)))
669 (let ((done nil)
670 (args (cdr command-line-args)))
672 ;; Figure out which user's init file to load,
673 ;; either from the environment or from the options.
674 (setq init-file-user (if noninteractive nil (user-login-name)))
675 ;; If user has not done su, use current $HOME to find .emacs.
676 (and init-file-user
677 (equal init-file-user (user-real-login-name))
678 (setq init-file-user ""))
680 ;; Process the command-line args, and delete the arguments
681 ;; processed. This is consistent with the way main in emacs.c
682 ;; does things.
683 (while (and (not done) args)
684 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
685 ("--user") ("--iconic") ("--icon-type") ("--quick")
686 ("--no-blinking-cursor") ("--basic-display")))
687 (argi (pop args))
688 (orig-argi argi)
689 argval)
690 ;; Handle --OPTION=VALUE format.
691 (when (string-match "^\\(--[^=]*\\)=" argi)
692 (setq argval (substring argi (match-end 0))
693 argi (match-string 1 argi)))
694 (unless (equal argi "--")
695 (let ((completion (try-completion argi longopts)))
696 (if (eq completion t)
697 (setq argi (substring argi 1))
698 (if (stringp completion)
699 (let ((elt (assoc completion longopts)))
700 (or elt
701 (error "Option `%s' is ambiguous" argi))
702 (setq argi (substring (car elt) 1)))
703 (setq argval nil
704 argi orig-argi)))))
705 (cond
706 ((member argi '("-Q" "-quick"))
707 (setq init-file-user nil
708 site-run-file nil
709 emacs-quick-startup t))
710 ((member argi '("-D" "-basic-display"))
711 (setq no-blinking-cursor t
712 emacs-basic-display t)
713 (push '(vertical-scroll-bars . nil) initial-frame-alist))
714 ((member argi '("-q" "-no-init-file"))
715 (setq init-file-user nil))
716 ((member argi '("-u" "-user"))
717 (setq init-file-user (or argval (pop args))
718 argval nil))
719 ((equal argi "-no-site-file")
720 (setq site-run-file nil))
721 ((equal argi "-debug-init")
722 (setq init-file-debug t))
723 ((equal argi "-iconic")
724 (push '(visibility . icon) initial-frame-alist))
725 ((member argi '("-icon-type" "-i" "-itype"))
726 (push '(icon-type . t) default-frame-alist))
727 ((member argi '("-nbc" "-no-blinking-cursor"))
728 (setq no-blinking-cursor t))
729 ;; Push the popped arg back on the list of arguments.
731 (push argi args)
732 (setq done t)))
733 ;; Was argval set but not used?
734 (and argval
735 (error "Option `%s' doesn't allow an argument" argi))))
737 ;; Re-attach the program name to the front of the arg list.
738 (and command-line-args
739 (setcdr command-line-args args)))
741 (run-hooks 'before-init-hook)
743 ;; Under X Window, this creates the X frame and deletes the terminal frame.
744 (when (fboundp 'frame-initialize)
745 (frame-initialize))
747 ;; Turn off blinking cursor if so specified in X resources. This is here
748 ;; only because all other settings of no-blinking-cursor are here.
749 (unless (or noninteractive
750 emacs-basic-display
751 (and (memq window-system '(x w32 mac))
752 (not (member (x-get-resource "cursorBlink" "CursorBlink")
753 '("off" "false")))))
754 (setq no-blinking-cursor t))
756 ;; If frame was created with a menu bar, set menu-bar-mode on.
757 (unless (or noninteractive
758 emacs-basic-display
759 (and (memq window-system '(x w32))
760 (<= (frame-parameter nil 'menu-bar-lines) 0)))
761 (menu-bar-mode 1))
763 ;; If frame was created with a tool bar, switch tool-bar-mode on.
764 (unless (or noninteractive
765 emacs-basic-display
766 (not (display-graphic-p))
767 (<= (frame-parameter nil 'tool-bar-lines) 0))
768 (tool-bar-mode 1))
770 ;; Can't do this init in defcustom because the relevant variables
771 ;; are not set.
772 (custom-reevaluate-setting 'blink-cursor-mode)
773 (custom-reevaluate-setting 'normal-erase-is-backspace)
774 (custom-reevaluate-setting 'tooltip-mode)
775 (custom-reevaluate-setting 'global-font-lock-mode)
776 (custom-reevaluate-setting 'mouse-wheel-down-event)
777 (custom-reevaluate-setting 'mouse-wheel-up-event)
778 (custom-reevaluate-setting 'file-name-shadow-mode)
779 (custom-reevaluate-setting 'send-mail-function)
781 ;; Register default TTY colors for the case the terminal hasn't a
782 ;; terminal init file.
783 (unless (memq window-system '(x w32 mac))
784 ;; We do this regardles of whether the terminal supports colors
785 ;; or not, since they can switch that support on or off in
786 ;; mid-session by setting the tty-color-mode frame parameter.
787 (tty-register-default-colors))
789 ;; Record whether the tool-bar is present before the user and site
790 ;; init files are processed. frame-notice-user-settings uses this
791 ;; to determine if the tool-bar has been disabled by the init files,
792 ;; and the frame needs to be resized.
793 (when (fboundp 'frame-notice-user-settings)
794 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
795 (assq 'tool-bar-lines default-frame-alist))))
796 (setq tool-bar-originally-present
797 (and tool-bar-lines
798 (cdr tool-bar-lines)
799 (not (eq 0 (cdr tool-bar-lines)))))))
801 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
802 (old-font-list-limit font-list-limit)
803 (old-face-ignored-fonts face-ignored-fonts))
805 ;; Run the site-start library if it exists. The point of this file is
806 ;; that it is run before .emacs. There is no point in doing this after
807 ;; .emacs; that is useless.
808 (if site-run-file
809 (load site-run-file t t))
811 ;; Sites should not disable this. Only individuals should disable
812 ;; the startup message.
813 (setq inhibit-startup-message nil)
815 ;; Warn for invalid user name.
816 (when init-file-user
817 (if (string-match "[~/:\n]" init-file-user)
818 (display-warning 'initialization
819 (format "Invalid user name %s"
820 init-file-user)
821 :error)
822 (if (file-directory-p (expand-file-name
823 ;; We don't support ~USER on MS-Windows except
824 ;; for the current user, and always load .emacs
825 ;; from the current user's home directory (see
826 ;; below). So always check "~", even if invoked
827 ;; with "-u USER", or if $USER or $LOGNAME are
828 ;; set to something different.
829 (if (eq system-type 'windows-nt)
831 (concat "~" init-file-user))))
833 (display-warning 'initialization
834 (format "User %s has no home directory"
835 init-file-user)
836 :error))))
838 ;; Load that user's init file, or the default one, or none.
839 (let (debug-on-error-from-init-file
840 debug-on-error-should-be-set
841 (debug-on-error-initial
842 (if (eq init-file-debug t) 'startup init-file-debug))
843 (orig-enable-multibyte default-enable-multibyte-characters))
844 (let ((debug-on-error debug-on-error-initial)
845 ;; This function actually reads the init files.
846 (inner
847 (function
848 (lambda ()
849 (if init-file-user
850 (let ((user-init-file-1
851 (cond
852 ((eq system-type 'ms-dos)
853 (concat "~" init-file-user "/_emacs"))
854 ((eq system-type 'windows-nt)
855 ;; Prefer .emacs on Windows.
856 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
857 "~/.emacs"
858 ;; Also support _emacs for compatibility.
859 (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
860 "~/_emacs"
861 ;; But default to .emacs if _emacs does not exist.
862 "~/.emacs")))
863 ((eq system-type 'vax-vms)
864 "sys$login:.emacs")
866 (concat "~" init-file-user "/.emacs")))))
867 ;; This tells `load' to store the file name found
868 ;; into user-init-file.
869 (setq user-init-file t)
870 (load user-init-file-1 t t)
872 (when (eq user-init-file t)
873 ;; If we did not find ~/.emacs, try
874 ;; ~/.emacs.d/init.el.
875 (let ((otherfile
876 (expand-file-name
877 "init"
878 (file-name-as-directory
879 (concat "~" init-file-user "/.emacs.d")))))
880 (load otherfile t t)
882 ;; If we did not find the user's init file,
883 ;; set user-init-file conclusively.
884 ;; Don't let it be set from default.el.
885 (when (eq user-init-file t)
886 (setq user-init-file user-init-file-1))))
888 ;; If we loaded a compiled file, set
889 ;; `user-init-file' to the source version if that
890 ;; exists.
891 (when (and user-init-file
892 (equal (file-name-extension user-init-file)
893 "elc"))
894 (let* ((source (file-name-sans-extension user-init-file))
895 (alt (concat source ".el")))
896 (setq source (cond ((file-exists-p alt) alt)
897 ((file-exists-p source) source)
898 (t nil)))
899 (when source
900 (when (file-newer-than-file-p source user-init-file)
901 (message "Warning: %s is newer than %s"
902 source user-init-file)
903 (sit-for 1))
904 (setq user-init-file source))))
906 (unless inhibit-default-init
907 (let ((inhibit-startup-message nil))
908 ;; Users are supposed to be told their rights.
909 ;; (Plus how to get help and how to undo.)
910 ;; Don't you dare turn this off for anyone
911 ;; except yourself.
912 (load "default" t t)))))))))
913 (if init-file-debug
914 ;; Do this without a condition-case if the user wants to debug.
915 (funcall inner)
916 (condition-case error
917 (progn
918 (funcall inner)
919 (setq init-file-had-error nil))
920 (error
921 (let ((message-log-max nil))
922 (save-excursion
923 (set-buffer (get-buffer-create "*Messages*"))
924 (insert "\n\n"
925 (format "An error has occurred while loading `%s':\n\n"
926 user-init-file)
927 (format "%s%s%s"
928 (get (car error) 'error-message)
929 (if (cdr error) ": " "")
930 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
931 "\n\n"
932 "To ensure normal operation, you should investigate and remove the\n"
933 "cause of the error in your initialization file. Start Emacs with\n"
934 "the `--debug-init' option to view a complete error backtrace.\n\n"))
935 (message "Error in init file: %s%s%s"
936 (get (car error) 'error-message)
937 (if (cdr error) ": " "")
938 (mapconcat 'prin1-to-string (cdr error) ", "))
939 (let ((pop-up-windows nil))
940 (pop-to-buffer "*Messages*"))
941 (setq init-file-had-error t)))))
943 (if (and deactivate-mark transient-mark-mode)
944 (with-current-buffer (window-buffer)
945 (deactivate-mark)))
947 ;; If the user has a file of abbrevs, read it.
948 (if (file-exists-p abbrev-file-name)
949 (quietly-read-abbrev-file abbrev-file-name))
951 ;; If the abbrevs came entirely from the init file or the
952 ;; abbrevs file, they do not need saving.
953 (setq abbrevs-changed nil)
955 ;; If we can tell that the init file altered debug-on-error,
956 ;; arrange to preserve the value that it set up.
957 (or (eq debug-on-error debug-on-error-initial)
958 (setq debug-on-error-should-be-set t
959 debug-on-error-from-init-file debug-on-error)))
960 (if debug-on-error-should-be-set
961 (setq debug-on-error debug-on-error-from-init-file))
962 (unless (or default-enable-multibyte-characters
963 (eq orig-enable-multibyte default-enable-multibyte-characters))
964 ;; Init file changed to unibyte. Reset existing multibyte
965 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
966 ;; Arguably this should only be done if they're free of
967 ;; multibyte characters.
968 (mapcar (lambda (buffer)
969 (with-current-buffer buffer
970 (if enable-multibyte-characters
971 (set-buffer-multibyte nil))))
972 (buffer-list))
973 ;; Also re-set the language environment in case it was
974 ;; originally done before unibyte was set and is sensitive to
975 ;; unibyte (display table, terminal coding system &c).
976 (set-language-environment current-language-environment)))
978 ;; Do this here in case the init file sets mail-host-address.
979 (if (equal user-mail-address "")
980 (setq user-mail-address (concat (user-login-name) "@"
981 (or mail-host-address
982 (system-name)))))
984 ;; Originally face attributes were specified via
985 ;; `font-lock-face-attributes'. Users then changed the default
986 ;; face attributes by setting that variable. However, we try and
987 ;; be back-compatible and respect its value if set except for
988 ;; faces where M-x customize has been used to save changes for the
989 ;; face.
990 (when (boundp 'font-lock-face-attributes)
991 (let ((face-attributes font-lock-face-attributes))
992 (while face-attributes
993 (let* ((face-attribute (pop face-attributes))
994 (face (car face-attribute)))
995 ;; Rustle up a `defface' SPEC from a
996 ;; `font-lock-face-attributes' entry.
997 (unless (get face 'saved-face)
998 (let ((foreground (nth 1 face-attribute))
999 (background (nth 2 face-attribute))
1000 (bold-p (nth 3 face-attribute))
1001 (italic-p (nth 4 face-attribute))
1002 (underline-p (nth 5 face-attribute))
1003 face-spec)
1004 (when foreground
1005 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1006 (when background
1007 (setq face-spec (cons ':background (cons background face-spec))))
1008 (when bold-p
1009 (setq face-spec (append '(:weight bold) face-spec)))
1010 (when italic-p
1011 (setq face-spec (append '(:slant italic) face-spec)))
1012 (when underline-p
1013 (setq face-spec (append '(:underline t) face-spec)))
1014 (face-spec-set face (list (list t face-spec)) nil)))))))
1016 ;; If parameter have been changed in the init file which influence
1017 ;; face realization, clear the face cache so that new faces will
1018 ;; be realized.
1019 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1020 (eq font-list-limit old-font-list-limit)
1021 (eq face-ignored-fonts old-face-ignored-fonts))
1022 (clear-face-cache)))
1024 (run-hooks 'after-init-hook)
1026 ;; Decode all default-directory.
1027 (if (and default-enable-multibyte-characters locale-coding-system)
1028 (save-excursion
1029 (dolist (elt (buffer-list))
1030 (set-buffer elt)
1031 (if default-directory
1032 (setq default-directory
1033 (decode-coding-string default-directory
1034 locale-coding-system t))))
1035 (setq command-line-default-directory
1036 (decode-coding-string command-line-default-directory
1037 locale-coding-system t))))
1039 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1040 (if (get-buffer "*scratch*")
1041 (with-current-buffer "*scratch*"
1042 (if (eq major-mode 'fundamental-mode)
1043 (funcall initial-major-mode))))
1045 ;; Load library for our terminal type.
1046 ;; User init file can set term-file-prefix to nil to prevent this.
1047 (unless (or noninteractive
1048 window-system
1049 (null term-file-prefix))
1050 (let* ((TERM (getenv "TERM"))
1051 (term TERM)
1052 hyphend)
1053 (while (and term
1054 (not (load (concat term-file-prefix term) t t)))
1055 ;; Strip off last hyphen and what follows, then try again
1056 (setq term
1057 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1058 (substring term 0 hyphend)
1059 nil)))
1060 (setq term TERM)
1061 ;; The terminal file has been loaded, now call the terminal specific
1062 ;; initialization function.
1063 (while term
1064 (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
1065 (if (not (fboundp term-init-func))
1066 ;; Strip off last hyphen and what follows, then try again
1067 (setq term
1068 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1069 (substring term 0 hyphend)
1070 nil))
1071 (setq term nil)
1072 (funcall term-init-func))))))
1074 ;; Update the out-of-memory error message based on user's key bindings
1075 ;; for save-some-buffers.
1076 (setq memory-signal-data
1077 (list 'error
1078 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1080 ;; Process the remaining args.
1081 (command-line-1 (cdr command-line-args))
1083 ;; If -batch, terminate after processing the command options.
1084 (if noninteractive (kill-emacs t))
1086 ;; Run emacs-session-restore (session management) if started by
1087 ;; the session manager and we have a session manager connection.
1088 (if (and (boundp 'x-session-previous-id)
1089 (stringp x-session-previous-id))
1090 (with-no-warnings
1091 (emacs-session-restore x-session-previous-id))))
1093 (defcustom initial-scratch-message (purecopy "\
1094 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1095 ;; If you want to create a file, visit that file with C-x C-f,
1096 ;; then enter the text in that file's own buffer.
1099 "Initial message displayed in *scratch* buffer at startup.
1100 If this is nil, no message will be displayed.
1101 If `inhibit-splash-screen' is non-nil, then no message is displayed,
1102 regardless of the value of this variable."
1103 :type '(choice (text :tag "Message")
1104 (const :tag "none" nil))
1105 :group 'initialization)
1108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1109 ;;; Fancy splash screen
1110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1112 (defvar fancy-splash-text
1113 '((:face variable-pitch
1114 "You can do basic editing with the menu bar and scroll bar \
1115 using the mouse.\n\n"
1116 :face (variable-pitch :weight bold)
1117 "Important Help menu items:\n"
1118 :face variable-pitch
1119 (lambda ()
1120 (let* ((en "TUTORIAL")
1121 (tut (or (get-language-info current-language-environment
1122 'tutorial)
1123 en))
1124 (title (with-temp-buffer
1125 (insert-file-contents
1126 (expand-file-name tut data-directory)
1127 nil 0 256)
1128 (search-forward ".")
1129 (buffer-substring (point-min) (1- (point))))))
1130 ;; If there is a specific tutorial for the current language
1131 ;; environment and it is not English, append its title.
1132 (concat
1133 "Emacs Tutorial\tLearn how to use Emacs efficiently"
1134 (if (string= en tut)
1136 (concat " (" title ")"))
1137 "\n")))
1138 :face variable-pitch "\
1139 Emacs FAQ\tFrequently asked questions and answers
1140 Read the Emacs Manual\tView the Emacs manual using Info
1141 \(Non)Warranty\tGNU Emacs comes with "
1142 :face (variable-pitch :slant oblique)
1143 "ABSOLUTELY NO WARRANTY\n"
1144 :face variable-pitch
1146 Copying Conditions\tConditions for redistributing and changing Emacs
1147 Getting New Versions\tHow to obtain the latest version of Emacs
1148 More Manuals / Ordering Manuals Buying printed manuals from the FSF\n")
1149 (:face variable-pitch
1150 "You can do basic editing with the menu bar and scroll bar \
1151 using the mouse.\n\n"
1152 :face (variable-pitch :weight bold)
1153 "Useful File menu items:\n"
1154 :face variable-pitch "\
1155 Exit Emacs\t(Or type Control-x followed by Control-c)
1156 Recover Crashed Session\tRecover files you were editing before a crash
1163 "A list of texts to show in the middle part of splash screens.
1164 Each element in the list should be a list of strings or pairs
1165 `:face FACE', like `fancy-splash-insert' accepts them.")
1168 (defgroup fancy-splash-screen ()
1169 "Fancy splash screen when Emacs starts."
1170 :version "21.1"
1171 :group 'initialization)
1174 (defcustom fancy-splash-delay 7
1175 "*Delay in seconds between splash screens."
1176 :group 'fancy-splash-screen
1177 :type 'integer)
1180 (defcustom fancy-splash-max-time 30
1181 "*Show splash screens for at most this number of seconds.
1182 Values less than twice `fancy-splash-delay' are ignored."
1183 :group 'fancy-splash-screen
1184 :type 'integer)
1187 (defcustom fancy-splash-image nil
1188 "*The image to show in the splash screens, or nil for defaults."
1189 :group 'fancy-splash-screen
1190 :type '(choice (const :tag "Default" nil)
1191 (file :tag "File")))
1194 ;; These are temporary storage areas for the splash screen display.
1196 (defvar fancy-current-text nil)
1197 (defvar fancy-splash-help-echo nil)
1198 (defvar fancy-splash-stop-time nil)
1199 (defvar fancy-splash-outer-buffer nil)
1201 (defun fancy-splash-insert (&rest args)
1202 "Insert text into the current buffer, with faces.
1203 Arguments from ARGS should be either strings, functions called
1204 with no args that return a string, or pairs `:face FACE',
1205 where FACE is a valid face specification, as it can be used with
1206 `put-text-property'."
1207 (let ((current-face nil))
1208 (while args
1209 (if (eq (car args) :face)
1210 (setq args (cdr args) current-face (car args))
1211 (insert (propertize (let ((it (car args)))
1212 (if (functionp it)
1213 (funcall it)
1214 it))
1215 'face current-face
1216 'help-echo fancy-splash-help-echo)))
1217 (setq args (cdr args)))))
1220 (defun fancy-splash-head ()
1221 "Insert the head part of the splash screen into the current buffer."
1222 (let* ((image-file (cond ((stringp fancy-splash-image)
1223 fancy-splash-image)
1224 ((and (display-color-p)
1225 (image-type-available-p 'xpm))
1226 (if (and (fboundp 'x-display-planes)
1227 (= (funcall 'x-display-planes) 8))
1228 "splash8.xpm"
1229 "splash.xpm"))
1230 (t "splash.pbm")))
1231 (img (create-image image-file))
1232 (image-width (and img (car (image-size img))))
1233 (window-width (window-width (selected-window))))
1234 (when img
1235 (when (> window-width image-width)
1236 ;; Center the image in the window.
1237 (insert (propertize " " 'display
1238 `(space :align-to (+ center (-0.5 . ,img)))))
1240 ;; Change the color of the XPM version of the splash image
1241 ;; so that it is visible with a dark frame background.
1242 (when (and (memq 'xpm img)
1243 (eq (frame-parameter nil 'background-mode) 'dark))
1244 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1246 ;; Insert the image with a help-echo and a keymap.
1247 (let ((map (make-sparse-keymap))
1248 (help-echo "mouse-2: browse http://www.gnu.org/"))
1249 (define-key map [mouse-2]
1250 (lambda ()
1251 (interactive)
1252 (browse-url "http://www.gnu.org/")
1253 (throw 'exit nil)))
1254 (define-key map [down-mouse-2] 'ignore)
1255 (define-key map [up-mouse-2] 'ignore)
1256 (insert-image img (propertize "xxx" 'help-echo help-echo
1257 'keymap map)))
1258 (insert "\n"))))
1259 (fancy-splash-insert
1260 :face '(variable-pitch :foreground "red")
1261 (if (eq system-type 'gnu/linux)
1262 "GNU Emacs is one component of the GNU/Linux operating system."
1263 "GNU Emacs is one component of the GNU operating system."))
1264 (insert "\n")
1265 (unless (equal (buffer-name fancy-splash-outer-buffer) "*scratch*")
1266 (fancy-splash-insert :face 'variable-pitch
1267 (substitute-command-keys
1268 "Type \\[recenter] to begin editing your file.\n"))))
1271 (defun fancy-splash-tail ()
1272 "Insert the tail part of the splash screen into the current buffer."
1273 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1274 "cyan" "darkblue")))
1275 (fancy-splash-insert :face `(variable-pitch :foreground ,fg)
1276 "\nThis is "
1277 (emacs-version)
1278 "\n"
1279 :face '(variable-pitch :height 0.5)
1280 "Copyright (C) 2006 Free Software Foundation, Inc.")
1281 (and auto-save-list-file-prefix
1282 ;; Don't signal an error if the
1283 ;; directory for auto-save-list files
1284 ;; does not yet exist.
1285 (file-directory-p (file-name-directory
1286 auto-save-list-file-prefix))
1287 (directory-files
1288 (file-name-directory auto-save-list-file-prefix)
1290 (concat "\\`"
1291 (regexp-quote (file-name-nondirectory
1292 auto-save-list-file-prefix)))
1294 (fancy-splash-insert :face '(variable-pitch :foreground "red")
1295 "\n\nIf an Emacs session crashed recently, "
1296 "type M-x recover-session RET\nto recover"
1297 " the files you were editing."))))
1299 (defun fancy-splash-screens-1 (buffer)
1300 "Timer function displaying a splash screen."
1301 (when (> (float-time) fancy-splash-stop-time)
1302 (throw 'stop-splashing nil))
1303 (unless fancy-current-text
1304 (setq fancy-current-text fancy-splash-text))
1305 (let ((text (car fancy-current-text)))
1306 (set-buffer buffer)
1307 (erase-buffer)
1308 (if pure-space-overflow
1309 (insert "\
1310 Warning Warning!!! Pure space overflow !!!Warning Warning
1311 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1312 (fancy-splash-head)
1313 (apply #'fancy-splash-insert text)
1314 (fancy-splash-tail)
1315 (unless (current-message)
1316 (message fancy-splash-help-echo))
1317 (set-buffer-modified-p nil)
1318 (goto-char (point-min))
1319 (force-mode-line-update)
1320 (setq fancy-current-text (cdr fancy-current-text))))
1323 (defun fancy-splash-default-action ()
1324 "Stop displaying the splash screen buffer.
1325 This is an internal function used to turn off the splash screen after
1326 the user caused an input event by hitting a key or clicking with the
1327 mouse."
1328 (interactive)
1329 (if (and (memq 'down (event-modifiers last-command-event))
1330 (eq (posn-window (event-start last-command-event))
1331 (selected-window)))
1332 ;; This is a mouse-down event in the spash screen window.
1333 ;; Ignore it and consume the corresponding mouse-up event.
1334 (read-event)
1335 (push last-command-event unread-command-events))
1336 (throw 'exit nil))
1339 (defun fancy-splash-screens ()
1340 "Display fancy splash screens when Emacs starts."
1341 (setq fancy-splash-help-echo (startup-echo-area-message))
1342 (let ((old-hourglass display-hourglass)
1343 (fancy-splash-outer-buffer (current-buffer))
1344 splash-buffer
1345 (old-minor-mode-map-alist minor-mode-map-alist)
1346 (old-emulation-mode-map-alists emulation-mode-map-alists)
1347 (frame (fancy-splash-frame))
1348 timer)
1349 (save-selected-window
1350 (select-frame frame)
1351 (switch-to-buffer "GNU Emacs")
1352 (setq tab-width 20)
1353 (setq splash-buffer (current-buffer))
1354 (catch 'stop-splashing
1355 (unwind-protect
1356 (let ((map (make-sparse-keymap)))
1357 (use-local-map map)
1358 (define-key map [switch-frame] 'ignore)
1359 (define-key map [t] 'fancy-splash-default-action)
1360 (define-key map [mouse-movement] 'ignore)
1361 (define-key map [mode-line t] 'ignore)
1362 (setq cursor-type nil
1363 display-hourglass nil
1364 minor-mode-map-alist nil
1365 emulation-mode-map-alists nil
1366 buffer-undo-list t
1367 mode-line-format (propertize "---- %b %-"
1368 'face 'mode-line-buffer-id)
1369 fancy-splash-stop-time (+ (float-time)
1370 fancy-splash-max-time)
1371 timer (run-with-timer 0 fancy-splash-delay
1372 #'fancy-splash-screens-1
1373 splash-buffer))
1374 (recursive-edit))
1375 (cancel-timer timer)
1376 (setq display-hourglass old-hourglass
1377 minor-mode-map-alist old-minor-mode-map-alist
1378 emulation-mode-map-alists old-emulation-mode-map-alists)
1379 (kill-buffer splash-buffer))))))
1381 (defun fancy-splash-frame ()
1382 "Return the frame to use for the fancy splash screen.
1383 Returning non-nil does not mean we should necessarily
1384 use the fancy splash screen, but if we do use it,
1385 we put it on this frame."
1386 (let (chosen-frame)
1387 (dolist (frame (append (frame-list) (list (selected-frame))))
1388 (if (and (frame-visible-p frame)
1389 (not (window-minibuffer-p (frame-selected-window frame))))
1390 (setq chosen-frame frame)))
1391 chosen-frame))
1393 (defun use-fancy-splash-screens-p ()
1394 "Return t if fancy splash screens should be used."
1395 (when (and (display-graphic-p)
1396 (or (and (display-color-p)
1397 (image-type-available-p 'xpm))
1398 (image-type-available-p 'pbm)))
1399 (let ((frame (fancy-splash-frame)))
1400 (when frame
1401 (let* ((img (create-image (or fancy-splash-image
1402 (if (and (display-color-p)
1403 (image-type-available-p 'xpm))
1404 "splash.xpm" "splash.pbm"))))
1405 (image-height (and img (cdr (image-size img))))
1406 (window-height (1- (window-height (frame-selected-window frame)))))
1407 (> window-height (+ image-height 19)))))))
1410 (defun normal-splash-screen ()
1411 "Display splash screen when Emacs starts."
1412 (let ((prev-buffer (current-buffer)))
1413 (unwind-protect
1414 (with-current-buffer (get-buffer-create "GNU Emacs")
1415 (set (make-local-variable 'tab-width) 8)
1416 (set (make-local-variable 'mode-line-format)
1417 (propertize "---- %b %-" 'face 'mode-line-buffer-id))
1419 (if pure-space-overflow
1420 (insert "\
1421 Warning Warning!!! Pure space overflow !!!Warning Warning
1422 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1424 ;; The convention for this piece of code is that
1425 ;; each piece of output starts with one or two newlines
1426 ;; and does not end with any newlines.
1427 (insert "Welcome to GNU Emacs")
1428 (insert
1429 (if (eq system-type 'gnu/linux)
1430 ", one component of the GNU/Linux operating system.\n"
1431 ", a part of the GNU operating system.\n"))
1433 (unless (equal (buffer-name prev-buffer) "*scratch*")
1434 (insert (substitute-command-keys
1435 "\nType \\[recenter] to begin editing your file.\n")))
1437 (if (display-mouse-p)
1438 ;; The user can use the mouse to activate menus
1439 ;; so give help in terms of menu items.
1440 (progn
1441 (insert "\
1442 You can do basic editing with the menu bar and scroll bar using the mouse.
1444 Useful File menu items:
1445 Exit Emacs (or type Control-x followed by Control-c)
1446 Recover Crashed Session Recover files you were editing before a crash
1448 Important Help menu items:
1449 Emacs Tutorial Learn how to use Emacs efficiently
1450 Emacs FAQ Frequently asked questions and answers
1451 Read the Emacs Manual View the Emacs manual using Info
1452 \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY
1453 Copying Conditions Conditions for redistributing and changing Emacs
1454 Getting New Versions How to obtain the latest version of Emacs
1455 More Manuals / Ordering Manuals How to order printed manuals from the FSF
1457 (insert "\n\n" (emacs-version)
1459 Copyright (C) 2006 Free Software Foundation, Inc."))
1461 ;; No mouse menus, so give help using kbd commands.
1463 ;; If keys have their default meanings,
1464 ;; use precomputed string to save lots of time.
1465 (if (and (eq (key-binding "\C-h") 'help-command)
1466 (eq (key-binding "\C-xu") 'advertised-undo)
1467 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
1468 (eq (key-binding "\C-ht") 'help-with-tutorial)
1469 (eq (key-binding "\C-hi") 'info)
1470 (eq (key-binding "\C-hr") 'info-emacs-manual)
1471 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
1472 (insert "
1473 Get help C-h (Hold down CTRL and press h)
1474 Emacs manual C-h r
1475 Emacs tutorial C-h t Undo changes C-x u
1476 Buy manuals C-h C-m Exit Emacs C-x C-c
1477 Browse manuals C-h i")
1479 (insert (substitute-command-keys
1480 (format "\n
1481 Get help %s
1482 Emacs manual \\[info-emacs-manual]
1483 Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
1484 Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs]
1485 Browse manuals \\[info]"
1486 (let ((where (where-is-internal
1487 'help-command nil t)))
1488 (if where
1489 (key-description where)
1490 "M-x help"))))))
1492 ;; Say how to use the menu bar with the keyboard.
1493 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1494 (eq (key-binding [f10]) 'tmm-menubar))
1495 (insert "
1496 Activate menubar F10 or ESC ` or M-`")
1497 (insert (substitute-command-keys "
1498 Activate menubar \\[tmm-menubar]")))
1500 ;; Many users seem to have problems with these.
1501 (insert "
1502 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1503 If you have no Meta key, you may instead type ESC followed by the character.)")
1505 (insert "\n\n" (emacs-version)
1507 Copyright (C) 2006 Free Software Foundation, Inc.")
1509 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1510 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1511 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1512 (insert
1514 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
1515 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1516 of Emacs and modify it; type C-h C-c to see the conditions.
1517 Type C-h C-d for information on getting the latest version.")
1518 (insert (substitute-command-keys
1520 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
1521 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1522 of Emacs and modify it; type \\[describe-copying] to see the conditions.
1523 Type \\[describe-distribution] for information on getting the latest version."))))
1525 ;; The rest of the startup screen is the same on all
1526 ;; kinds of terminals.
1528 ;; Give information on recovering, if there was a crash.
1529 (and auto-save-list-file-prefix
1530 ;; Don't signal an error if the
1531 ;; directory for auto-save-list files
1532 ;; does not yet exist.
1533 (file-directory-p (file-name-directory
1534 auto-save-list-file-prefix))
1535 (directory-files
1536 (file-name-directory auto-save-list-file-prefix)
1538 (concat "\\`"
1539 (regexp-quote (file-name-nondirectory
1540 auto-save-list-file-prefix)))
1542 (insert "\n\nIf an Emacs session crashed recently, "
1543 "type M-x recover-session RET\nto recover"
1544 " the files you were editing."))
1546 ;; Display the input that we set up in the buffer.
1547 (set-buffer-modified-p nil)
1548 (goto-char (point-min))
1549 (if (or (window-minibuffer-p)
1550 (window-dedicated-p (selected-window)))
1551 ;; There's no point is using pop-to-buffer since creating
1552 ;; a new frame will generate enough events that the
1553 ;; subsequent `sit-for' will immediately return anyway.
1554 nil ;; (pop-to-buffer (current-buffer))
1555 (save-window-excursion
1556 (switch-to-buffer (current-buffer))
1557 (sit-for 120))))
1558 ;; Unwind ... ensure splash buffer is killed
1559 (kill-buffer "GNU Emacs"))))
1562 (defun startup-echo-area-message ()
1563 (if (eq (key-binding "\C-h\C-p") 'describe-project)
1564 "For information about the GNU Project and its goals, type C-h C-p."
1565 (substitute-command-keys
1566 "For information about the GNU Project and its goals, type \
1567 \\[describe-project].")))
1570 (defun display-startup-echo-area-message ()
1571 (let ((resize-mini-windows t))
1572 (message "%s" (startup-echo-area-message))))
1575 (defun display-splash-screen ()
1576 "Display splash screen according to display.
1577 Fancy splash screens are used on graphic displays,
1578 normal otherwise."
1579 (interactive)
1580 (if (use-fancy-splash-screens-p)
1581 (fancy-splash-screens)
1582 (normal-splash-screen)))
1585 (defun command-line-1 (command-line-args-left)
1586 (or noninteractive (input-pending-p) init-file-had-error
1587 ;; t if the init file says to inhibit the echo area startup message.
1588 (and inhibit-startup-echo-area-message
1589 user-init-file
1590 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1591 (equal inhibit-startup-echo-area-message
1592 (if (equal init-file-user "")
1593 (user-login-name)
1594 init-file-user)))
1595 ;; Wasn't set with custom; see if .emacs has a setq.
1596 (let ((buffer (get-buffer-create " *temp*")))
1597 (prog1
1598 (condition-case nil
1599 (save-excursion
1600 (set-buffer buffer)
1601 (insert-file-contents user-init-file)
1602 (re-search-forward
1603 (concat
1604 "([ \t\n]*setq[ \t\n]+"
1605 "inhibit-startup-echo-area-message[ \t\n]+"
1606 (regexp-quote
1607 (prin1-to-string
1608 (if (equal init-file-user "")
1609 (user-login-name)
1610 init-file-user)))
1611 "[ \t\n]*)")
1612 nil t))
1613 (error nil))
1614 (kill-buffer buffer)))))
1615 ;; display-splash-screen at the end of command-line-1 calls
1616 ;; use-fancy-splash-screens-p. This can cause image.el to be
1617 ;; loaded, putting "Loading image... done" in the echo area.
1618 ;; This hides startup-echo-area-message. So
1619 ;; use-fancy-splash-screens-p is called here simply to get the
1620 ;; loading of image.el (if needed) out of the way before
1621 ;; display-startup-echo-area-message runs.
1622 (progn
1623 (use-fancy-splash-screens-p)
1624 (display-startup-echo-area-message)))
1626 ;; Delay 2 seconds after an init file error message
1627 ;; was displayed, so user can read it.
1628 (when init-file-had-error
1629 (sit-for 2))
1631 (when (and pure-space-overflow
1632 (not noninteractive))
1633 (display-warning
1634 'initialization
1635 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
1636 :warning))
1638 (when command-line-args-left
1639 ;; We have command args; process them.
1640 (let ((dir command-line-default-directory)
1641 (file-count 0)
1642 first-file-buffer
1644 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
1645 ;; if foo is intended to be found in DIR.
1647 ;; ;; The directories listed in --directory/-L options will *appear*
1648 ;; ;; at the front of `load-path' in the order they appear on the
1649 ;; ;; command-line. We cannot do this by *placing* them at the front
1650 ;; ;; in the order they appear, so we need this variable to hold them,
1651 ;; ;; temporarily.
1652 ;; extra-load-path
1654 ;; To DTRT we keep track of the splice point and modify `load-path'
1655 ;; straight away upon any --directory/-L option.
1656 splice
1657 just-files ;; t if this follows the magic -- option.
1658 ;; This includes our standard options' long versions
1659 ;; and long versions of what's on command-switch-alist.
1660 (longopts
1661 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1662 ("--directory") ("--eval") ("--execute") ("--no-splash")
1663 ("--find-file") ("--visit") ("--file") ("--no-desktop"))
1664 (mapcar (lambda (elt)
1665 (list (concat "-" (car elt))))
1666 command-switch-alist)))
1667 (line 0)
1668 (column 0))
1670 ;; Add the long X options to longopts.
1671 (dolist (tem command-line-x-option-alist)
1672 (if (string-match "^--" (car tem))
1673 (push (list (car tem)) longopts)))
1675 ;; Loop, processing options.
1676 (while command-line-args-left
1677 (let* ((argi (car command-line-args-left))
1678 (orig-argi argi)
1679 argval completion)
1680 (setq command-line-args-left (cdr command-line-args-left))
1682 ;; Do preliminary decoding of the option.
1683 (if just-files
1684 ;; After --, don't look for options; treat all args as files.
1685 (setq argi "")
1686 ;; Convert long options to ordinary options
1687 ;; and separate out an attached option argument into argval.
1688 (when (string-match "^\\(--[^=]*\\)=" argi)
1689 (setq argval (substring argi (match-end 0))
1690 argi (match-string 1 argi)))
1691 (if (equal argi "--")
1692 (setq completion nil)
1693 (setq completion (try-completion argi longopts)))
1694 (if (eq completion t)
1695 (setq argi (substring argi 1))
1696 (if (stringp completion)
1697 (let ((elt (assoc completion longopts)))
1698 (or elt
1699 (error "Option `%s' is ambiguous" argi))
1700 (setq argi (substring (car elt) 1)))
1701 (setq argval nil
1702 argi orig-argi))))
1704 ;; Execute the option.
1705 (cond ((setq tem (assoc argi command-switch-alist))
1706 (if argval
1707 (let ((command-line-args-left
1708 (cons argval command-line-args-left)))
1709 (funcall (cdr tem) argi))
1710 (funcall (cdr tem) argi)))
1712 ((equal argi "-no-splash")
1713 (setq inhibit-startup-message t))
1715 ((member argi '("-f" ; what the manual claims
1716 "-funcall"
1717 "-e")) ; what the source used to say
1718 (setq tem (intern (or argval (pop command-line-args-left))))
1719 (if (commandp tem)
1720 (command-execute tem)
1721 (funcall tem)))
1723 ((member argi '("-eval" "-execute"))
1724 (eval (read (or argval (pop command-line-args-left)))))
1726 ((member argi '("-L" "-directory"))
1727 (setq tem (expand-file-name
1728 (command-line-normalize-file-name
1729 (or argval (pop command-line-args-left)))))
1730 (cond (splice (setcdr splice (cons tem (cdr splice)))
1731 (setq splice (cdr splice)))
1732 (t (setq load-path (cons tem load-path)
1733 splice load-path))))
1735 ((member argi '("-l" "-load"))
1736 (let* ((file (command-line-normalize-file-name
1737 (or argval (pop command-line-args-left))))
1738 ;; Take file from default dir if it exists there;
1739 ;; otherwise let `load' search for it.
1740 (file-ex (expand-file-name file)))
1741 (when (file-exists-p file-ex)
1742 (setq file file-ex))
1743 (load file nil t)))
1745 ;; This is used to handle -script. It's not clear
1746 ;; we need to document it.
1747 ((member argi '("-scriptload"))
1748 (let* ((file (command-line-normalize-file-name
1749 (or argval (pop command-line-args-left))))
1750 ;; Take file from default dir.
1751 (file-ex (expand-file-name file)))
1752 (load file-ex nil t t)))
1754 ((equal argi "-insert")
1755 (setq tem (or argval (pop command-line-args-left)))
1756 (or (stringp tem)
1757 (error "File name omitted from `-insert' option"))
1758 (insert-file-contents (command-line-normalize-file-name tem)))
1760 ((equal argi "-kill")
1761 (kill-emacs t))
1763 ;; This is for when they use --no-desktop with -q, or
1764 ;; don't load Desktop in their .emacs. If desktop.el
1765 ;; _is_ loaded, it will handle this switch, and we
1766 ;; won't see it by the time we get here.
1767 ((equal argi "-no-desktop")
1768 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
1770 ((string-match "^\\+[0-9]+\\'" argi)
1771 (setq line (string-to-number argi)))
1773 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
1774 (setq line (string-to-number (match-string 1 argi))
1775 column (string-to-number (match-string 2 argi))))
1777 ((setq tem (assoc argi command-line-x-option-alist))
1778 ;; Ignore X-windows options and their args if not using X.
1779 (setq command-line-args-left
1780 (nthcdr (nth 1 tem) command-line-args-left)))
1782 ((member argi '("-find-file" "-file" "-visit"))
1783 ;; An explicit option to specify visiting a file.
1784 (setq tem (or argval (pop command-line-args-left)))
1785 (unless (stringp tem)
1786 (error "File name omitted from `%s' option" argi))
1787 (setq file-count (1+ file-count))
1788 (let ((file (expand-file-name
1789 (command-line-normalize-file-name tem) dir)))
1790 (if (= file-count 1)
1791 (setq first-file-buffer (find-file file))
1792 (find-file-other-window file)))
1793 (or (zerop line)
1794 (goto-line line))
1795 (setq line 0)
1796 (unless (< column 1)
1797 (move-to-column (1- column)))
1798 (setq column 0))
1800 ((equal argi "--")
1801 (setq just-files t))
1803 ;; We have almost exhausted our options. See if the
1804 ;; user has made any other command-line options available
1805 (let ((hooks command-line-functions) ;; lrs 7/31/89
1806 (did-hook nil))
1807 (while (and hooks
1808 (not (setq did-hook (funcall (car hooks)))))
1809 (setq hooks (cdr hooks)))
1810 (if (not did-hook)
1811 ;; Presume that the argument is a file name.
1812 (progn
1813 (if (string-match "\\`-" argi)
1814 (error "Unknown option `%s'" argi))
1815 (setq file-count (1+ file-count))
1816 (let ((file
1817 (expand-file-name
1818 (command-line-normalize-file-name orig-argi)
1819 dir)))
1820 (if (= file-count 1)
1821 (setq first-file-buffer (find-file file))
1822 (find-file-other-window file)))
1823 (or (zerop line)
1824 (goto-line line))
1825 (setq line 0)
1826 (unless (< column 1)
1827 (move-to-column (1- column)))
1828 (setq column 0))))))))
1830 ;; If 3 or more files visited, and not all visible,
1831 ;; show user what they all are. But leave the last one current.
1832 (and (> file-count 2)
1833 (not noninteractive)
1834 (not inhibit-startup-buffer-menu)
1835 (or (get-buffer-window first-file-buffer)
1836 (list-buffers)))))
1838 ;; Maybe display a startup screen.
1839 (unless (or inhibit-startup-message
1840 noninteractive
1841 emacs-quick-startup)
1842 ;; Display a startup screen, after some preparations.
1844 ;; If there are no switches to process, we might as well
1845 ;; run this hook now, and there may be some need to do it
1846 ;; before doing any output.
1847 (run-hooks 'emacs-startup-hook)
1848 (and term-setup-hook
1849 (run-hooks 'term-setup-hook))
1850 (setq inhibit-startup-hooks t)
1852 ;; It's important to notice the user settings before we
1853 ;; display the startup message; otherwise, the settings
1854 ;; won't take effect until the user gives the first
1855 ;; keystroke, and that's distracting.
1856 (when (fboundp 'frame-notice-user-settings)
1857 (frame-notice-user-settings))
1859 ;; If there are no switches to process, we might as well
1860 ;; run this hook now, and there may be some need to do it
1861 ;; before doing any output.
1862 (when window-setup-hook
1863 (run-hooks 'window-setup-hook)
1864 ;; Don't let the hook be run twice.
1865 (setq window-setup-hook nil))
1867 ;; Do this now to avoid an annoying delay if the user
1868 ;; clicks the menu bar during the sit-for.
1869 (when (display-popup-menus-p)
1870 (precompute-menubar-bindings))
1871 (with-no-warnings
1872 (setq menubar-bindings-done t))
1874 ;; If *scratch* is selected and it is empty, insert an
1875 ;; initial message saying not to create a file there.
1876 (when (and initial-scratch-message
1877 (equal (buffer-name) "*scratch*")
1878 (= 0 (buffer-size)))
1879 (insert initial-scratch-message)
1880 (set-buffer-modified-p nil))
1882 ;; If user typed input during all that work,
1883 ;; abort the startup screen. Otherwise, display it now.
1884 (unless (input-pending-p)
1885 (display-splash-screen))))
1888 (defun command-line-normalize-file-name (file)
1889 "Collapse multiple slashes to one, to handle non-Emacs file names."
1890 (save-match-data
1891 ;; Use arg 1 so that we don't collapse // at the start of the file name.
1892 ;; That is significant on some systems.
1893 ;; However, /// at the beginning is supposed to mean just /, not //.
1894 (if (string-match "^///+" file)
1895 (setq file (replace-match "/" t t file)))
1896 (while (string-match "//+" file 1)
1897 (setq file (replace-match "/" t t file)))
1898 file))
1900 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
1901 ;;; startup.el ends here