1 ;;; startup.el --- process Emacs shell arguments
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
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, or (at your option)
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.
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.
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."
43 (defcustom initial-buffer-choice nil
44 "Buffer to show after starting Emacs.
45 If the value is nil and `inhibit-splash-screen' is nil, show the
46 startup screen. If the value is string, visit the specified file or
47 directory using `find-file'. If t, open the `*scratch*' buffer."
49 (const :tag "Splash screen" nil)
50 (directory :tag "Directory" :value "~/")
51 (file :tag "File" :value "~/file.txt")
52 (const :tag "Lisp scratch buffer" t))
54 :group 'initialization)
56 (defcustom inhibit-splash-screen nil
57 "Non-nil inhibits the startup screen.
58 It also inhibits display of the initial message in the `*scratch*' buffer.
60 This is for use in your personal init file (but NOT site-start.el), once
61 you are familiar with the contents of the startup screen."
63 :group 'initialization)
65 (defvaralias 'inhibit-startup-message 'inhibit-splash-screen)
67 (defcustom inhibit-startup-echo-area-message nil
68 "*Non-nil inhibits the initial startup echo area message.
69 Setting this variable takes effect
70 only if you do it with the customization buffer
71 or if your `.emacs' file contains a line of this form:
72 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
73 If your `.emacs' file is byte-compiled, use the following form instead:
74 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
75 Thus, someone else using a copy of your `.emacs' file will see
76 the startup message unless he personally acts to inhibit it."
77 :type '(choice (const :tag "Don't inhibit")
78 (string :tag "Enter your user name, to inhibit"))
79 :group 'initialization)
81 (defcustom inhibit-default-init nil
82 "*Non-nil inhibits loading the `default' library."
84 :group 'initialization)
86 (defcustom inhibit-startup-buffer-menu nil
87 "*Non-nil inhibits display of buffer list when more than 2 files are loaded."
89 :group 'initialization)
91 (defvar command-switch-alist nil
92 "Alist of command-line switches.
93 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
94 HANDLER-FUNCTION receives the switch string as its sole argument;
95 the remaining command-line args are in the variable `command-line-args-left'.")
97 (defvar command-line-args-left nil
98 "List of command-line args not yet processed.")
100 (defvar command-line-functions nil ;; lrs 7/31/89
101 "List of functions to process unrecognized command-line arguments.
102 Each function should access the dynamically bound variables
103 `argi' (the current argument) and `command-line-args-left' (the remaining
104 arguments). The function should return non-nil only if it recognizes and
105 processes `argi'. If it does so, it may consume successive arguments by
106 altering `command-line-args-left' to remove them.")
108 (defvar command-line-default-directory nil
109 "Default directory to use for command line arguments.
110 This is normally copied from `default-directory' when Emacs starts.")
112 ;;; This is here, rather than in x-win.el, so that we can ignore these
113 ;;; options when we are not using X.
114 (defconst command-line-x-option-alist
115 '(("-bw" 1 x-handle-numeric-switch border-width)
116 ("-d" 1 x-handle-display)
117 ("-display" 1 x-handle-display)
118 ("-name" 1 x-handle-name-switch)
119 ("-title" 1 x-handle-switch title)
120 ("-T" 1 x-handle-switch title)
121 ("-r" 0 x-handle-switch reverse t)
122 ("-rv" 0 x-handle-switch reverse t)
123 ("-reverse" 0 x-handle-switch reverse t)
124 ("-reverse-video" 0 x-handle-switch reverse t)
125 ("-fn" 1 x-handle-switch font)
126 ("-font" 1 x-handle-switch font)
127 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
128 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
129 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
130 ("-ib" 1 x-handle-numeric-switch internal-border-width)
131 ("-g" 1 x-handle-geometry)
132 ("-lsp" 1 x-handle-numeric-switch line-spacing)
133 ("-geometry" 1 x-handle-geometry)
134 ("-fg" 1 x-handle-switch foreground-color)
135 ("-foreground" 1 x-handle-switch foreground-color)
136 ("-bg" 1 x-handle-switch background-color)
137 ("-background" 1 x-handle-switch background-color)
138 ("-ms" 1 x-handle-switch mouse-color)
139 ("-nbi" 0 x-handle-switch icon-type nil)
140 ("-iconic" 0 x-handle-iconic)
141 ("-xrm" 1 x-handle-xrm-switch)
142 ("-cr" 1 x-handle-switch cursor-color)
143 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
144 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
145 ("-bd" 1 x-handle-switch)
146 ("--border-width" 1 x-handle-numeric-switch border-width)
147 ("--display" 1 x-handle-display)
148 ("--name" 1 x-handle-name-switch)
149 ("--title" 1 x-handle-switch title)
150 ("--reverse-video" 0 x-handle-switch reverse t)
151 ("--font" 1 x-handle-switch font)
152 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
153 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
154 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
155 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
156 ("--geometry" 1 x-handle-geometry)
157 ("--foreground-color" 1 x-handle-switch foreground-color)
158 ("--background-color" 1 x-handle-switch background-color)
159 ("--mouse-color" 1 x-handle-switch mouse-color)
160 ("--no-bitmap-icon" 0 x-handle-no-bitmap-icon)
161 ("--iconic" 0 x-handle-iconic)
162 ("--xrm" 1 x-handle-xrm-switch)
163 ("--cursor-color" 1 x-handle-switch cursor-color)
164 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
165 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
166 ("--border-color" 1 x-handle-switch border-color)
167 ("--smid" 1 x-handle-smid))
168 "Alist of X Windows options.
169 Each element has the form
170 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
171 where NAME is the option name string, NUMARGS is the number of arguments
172 that the option accepts, HANDLER is a function to call to handle the option.
173 FRAME-PARAM (optional) is the frame parameter this option specifies,
174 and VALUE is the value which is given to that frame parameter
175 \(most options use the argument for this, so VALUE is not present).")
177 (defvar before-init-hook nil
178 "Normal hook run after handling urgent options but before loading init files.")
180 (defvar after-init-hook nil
181 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
182 There is no `condition-case' around the running of these functions;
183 therefore, if you set `debug-on-error' non-nil in `.emacs',
184 an error in one of these functions will invoke the debugger.")
186 (defvar emacs-startup-hook nil
187 "Normal hook run after loading init files and handling the command line.")
189 (defvar term-setup-hook nil
190 "Normal hook run after loading terminal-specific Lisp code.
191 It also follows `emacs-startup-hook'. This hook exists for users to set,
192 so as to override the definitions made by the terminal-specific file.
193 Emacs never sets this variable itself.")
195 (defvar inhibit-startup-hooks nil
196 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
197 This is because we already did so.")
199 (defvar keyboard-type nil
200 "The brand of keyboard you are using.
201 This variable is used to define the proper function and keypad
202 keys for use under X. It is used in a fashion analogous to the
203 environment variable TERM.")
205 (defvar window-setup-hook nil
206 "Normal hook run to initialize window system display.
207 Emacs runs this hook after processing the command line arguments and loading
208 the user's init file.")
210 (defcustom initial-major-mode 'lisp-interaction-mode
211 "Major mode command symbol to use for the initial `*scratch*' buffer."
213 :group 'initialization)
215 (defvar init-file-user nil
216 "Identity of user whose `.emacs' file is or was read.
217 The value is nil if `-q' or `--no-init-file' was specified,
218 meaning do not load any init file.
220 Otherwise, the value may be an empty string, meaning
221 use the init file for the user who originally logged in,
222 or it may be a string containing a user's name meaning
223 use that person's init file.
225 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
226 evaluates to the name of the directory where the `.emacs' file was
229 Setting `init-file-user' does not prevent Emacs from loading
230 `site-start.el'. The only way to do that is to use `--no-site-file'.")
232 (defcustom site-run-file "site-start"
233 "File containing site-wide run-time initializations.
234 This file is loaded at run-time before `~/.emacs'. It contains inits
235 that need to be in place for the entire site, but which, due to their
236 higher incidence of change, don't make sense to load into Emacs's
237 dumped image. Thus, the run-time load order is: 1. file described in
238 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
240 Don't use the `site-start.el' file for things some users may not like.
241 Put them in `default.el' instead, so that users can more easily
242 override them. Users can prevent loading `default.el' with the `-q'
243 option or by setting `inhibit-default-init' in their own init files,
244 but inhibiting `site-start.el' requires `--no-site-file', which
247 This variable is defined for customization so as to make
248 it visible in the relevant context. However, actually customizing it
249 is not allowed, since it would not work anyway. The only way to set
250 this variable usefully is to set it while building and dumping Emacs."
251 :type '(choice (const :tag "none" nil) string)
252 :group 'initialization
253 :initialize 'custom-initialize-default
254 :set '(lambda (variable value)
255 (error "Customizing `site-run-file' does not work")))
257 (defcustom mail-host-address nil
258 "*Name of this machine, for purposes of naming users."
259 :type '(choice (const nil) string)
262 (defcustom user-mail-address (if command-line-processed
264 (concat (user-login-name) "@"
265 (or mail-host-address
267 ;; Empty string means "not set yet".
269 "*Full mailing address of this user.
270 This is initialized with environment variable `EMAIL' or, as a
271 fallback, using `mail-host-address'. This is done after your
272 init file is read, in case it sets `mail-host-address'."
276 (defcustom auto-save-list-file-prefix
277 (cond ((eq system-type 'ms-dos)
278 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
279 (concat user-emacs-directory "auto-save.list/_s"))
281 (concat user-emacs-directory "auto-save-list/.saves-")))
282 "Prefix for generating `auto-save-list-file-name'.
283 This is used after reading your `.emacs' file to initialize
284 `auto-save-list-file-name', by appending Emacs's pid and the system name,
285 if you have not already set `auto-save-list-file-name' yourself.
286 Directories in the prefix will be created if necessary.
287 Set this to nil if you want to prevent `auto-save-list-file-name'
288 from being initialized."
289 :type '(choice (const :tag "Don't record a session's auto save list" nil)
293 (defvar emacs-quick-startup nil)
295 (defvar emacs-basic-display nil)
297 (defvar init-file-debug nil)
299 (defvar init-file-had-error nil
300 "Non-nil if there was an error loading the user's init file.")
302 (defvar normal-top-level-add-subdirs-inode-list nil)
304 (defvar no-blinking-cursor nil)
306 (defvar default-frame-background-mode)
308 (defvar pure-space-overflow nil
309 "Non-nil if building Emacs overflowed pure space.")
311 (defvar tutorial-directory nil
312 "Directory containing the Emacs TUTORIAL files.")
314 ;; Get correct value in a dumped, installed Emacs.
316 (setq tutorial-directory (file-name-as-directory
317 (expand-file-name "tutorials" data-directory))))
319 (defun normal-top-level-add-subdirs-to-load-path ()
320 "Add all subdirectories of current directory to `load-path'.
321 More precisely, this uses only the subdirectories whose names
322 start with letters or digits; it excludes any subdirectory named `RCS'
323 or `CVS', and any subdirectory that contains a file named `.nosearch'."
326 (pending (list default-directory)))
327 ;; This loop does a breadth-first tree walk on DIR's subtree,
328 ;; putting each subdir into DIRS as its contents are examined.
330 (push (pop pending) dirs)
331 (let* ((this-dir (car dirs))
332 (contents (directory-files this-dir))
333 (default-directory this-dir)
334 (canonicalized (if (fboundp 'untranslated-canonical-name)
335 (untranslated-canonical-name this-dir))))
336 ;; The Windows version doesn't report meaningful inode
337 ;; numbers, so use the canonicalized absolute file name of the
338 ;; directory instead.
339 (setq attrs (or canonicalized
340 (nthcdr 10 (file-attributes this-dir))))
341 (unless (member attrs normal-top-level-add-subdirs-inode-list)
342 (push attrs normal-top-level-add-subdirs-inode-list)
343 (dolist (file contents)
344 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
345 (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs"))
346 (when (and (string-match "\\`[[:alnum:]]" file)
347 ;; Avoid doing a `stat' when it isn't necessary
348 ;; because that can cause trouble when an NFS server
350 (not (string-match "\\.elc?\\'" file))
351 (file-directory-p file))
352 (let ((expanded (expand-file-name file)))
353 (unless (file-exists-p (expand-file-name ".nosearch"
355 (setq pending (nconc pending (list expanded)))))))))))
356 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
358 ;; This function is called from a subdirs.el file.
359 ;; It assumes that default-directory is the directory
360 ;; in which the subdirs.el file exists,
361 ;; and it adds to load-path the subdirs of that directory
362 ;; as specified in DIRS. Normally the elements of DIRS are relative.
363 (defun normal-top-level-add-to-load-path (dirs)
364 (let ((tail load-path)
365 (thisdir (directory-file-name default-directory)))
367 ;;Don't go all the way to the nil terminator.
369 (not (equal thisdir (car tail)))
370 (not (and (memq system-type '(ms-dos windows-nt))
371 (equal (downcase thisdir) (downcase (car tail))))))
372 (setq tail (cdr tail)))
373 ;;Splice the new section in.
375 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
377 (defun normal-top-level ()
378 (if command-line-processed
379 (message "Back to top level.")
380 (setq command-line-processed t)
381 ;; Give *Messages* the same default-directory as *scratch*,
382 ;; just to keep things predictable.
383 (let ((dir default-directory))
384 (with-current-buffer "*Messages*"
385 (setq default-directory dir)))
386 ;; `user-full-name' is now known; reset its standard-value here.
387 (put 'user-full-name 'standard-value
388 (list (default-value 'user-full-name)))
389 ;; For root, preserve owner and group when editing files.
390 (if (equal (user-uid) 0)
391 (setq backup-by-copying-when-mismatch t))
392 ;; Look in each dir in load-path for a subdirs.el file.
393 ;; If we find one, load it, which will add the appropriate subdirs
394 ;; of that dir into load-path,
395 ;; Look for a leim-list.el file too. Loading it will register
396 ;; available input methods.
397 (let ((tail load-path) dir)
399 (setq dir (car tail))
400 (let ((default-directory dir))
401 (load (expand-file-name "subdirs.el") t t t))
402 (let ((default-directory dir))
403 (load (expand-file-name "leim-list.el") t t t))
404 ;; We don't use a dolist loop and we put this "setq-cdr" command at
405 ;; the end, because the subdirs.el files may add elements to the end
406 ;; of load-path and we want to take it into account.
407 (setq tail (cdr tail))))
408 (unless (eq system-type 'vax-vms)
409 ;; If the PWD environment variable isn't accurate, delete it.
410 (let ((pwd (getenv "PWD")))
412 ;; Use FOO/., so that if FOO is a symlink, file-attributes
413 ;; describes the directory linked to, not FOO itself.
414 (or (equal (file-attributes
415 (concat (file-name-as-directory pwd) "."))
417 (concat (file-name-as-directory default-directory)
419 (setq process-environment
420 (delete (concat "PWD=" pwd)
421 process-environment))))))
422 (setq default-directory (abbreviate-file-name default-directory))
423 (let ((menubar-bindings-done nil))
426 ;; Do this again, in case .emacs defined more abbreviations.
427 (setq default-directory (abbreviate-file-name default-directory))
428 ;; Specify the file for recording all the auto save files of this session.
429 ;; This is used by recover-session.
430 (or auto-save-list-file-name
431 (and auto-save-list-file-prefix
432 (setq auto-save-list-file-name
433 ;; Under MS-DOS our PID is almost always reused between
434 ;; Emacs invocations. We need something more unique.
435 (cond ((eq system-type 'ms-dos)
436 ;; We are going to access the auto-save
437 ;; directory, so make sure it exists.
439 (file-name-directory auto-save-list-file-prefix)
444 auto-save-list-file-prefix))
449 auto-save-list-file-prefix
452 (unless inhibit-startup-hooks
453 (run-hooks 'emacs-startup-hook)
455 (run-hooks 'term-setup-hook)))
457 ;; Don't do this if we failed to create the initial frame,
458 ;; for instance due to a dense colormap.
459 (when (or frame-initial-frame
460 ;; If frame-initial-frame has no meaning, do this anyway.
461 (not (and window-system
463 (not (eq window-system 'pc)))))
464 ;; Modify the initial frame based on what .emacs puts into
466 (if (fboundp 'frame-notice-user-settings)
467 (frame-notice-user-settings))
468 (if (fboundp 'frame-set-background-mode)
469 ;; Set the faces for the initial background mode even if
470 ;; frame-notice-user-settings didn't (such as on a tty).
471 ;; frame-set-background-mode is idempotent, so it won't
472 ;; cause any harm if it's already been done.
473 (let ((frame (selected-frame))
475 (when (and (null window-system)
476 ;; Don't override default set by files in lisp/term.
477 (null default-frame-background-mode)
478 (let ((bg (frame-parameter frame 'background-color)))
480 (member bg '(unspecified "unspecified-bg"
481 "unspecified-fg")))))
483 (setq term (getenv "TERM"))
484 ;; Some files in lisp/term do a better job with the
485 ;; background mode, but we leave this here anyway, in
486 ;; case they remove those files.
487 (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
489 (setq default-frame-background-mode 'light)))
490 (frame-set-background-mode (selected-frame)))))
492 ;; Now we know the user's default font, so add it to the menu.
493 (if (fboundp 'font-menu-add-default)
494 (font-menu-add-default))
495 (and window-setup-hook
496 (run-hooks 'window-setup-hook))
497 (or menubar-bindings-done
498 (if (display-popup-menus-p)
499 (precompute-menubar-bindings)))))))
501 ;; Precompute the keyboard equivalents in the menu bar items.
502 (defun precompute-menubar-bindings ()
503 (let ((submap (lookup-key global-map [menu-bar])))
505 (and (consp (car submap))
506 (symbolp (car (car submap)))
507 (stringp (car-safe (cdr (car submap))))
508 (keymapp (cdr (cdr (car submap))))
510 (x-popup-menu nil (cdr (cdr (car submap))))
513 (setq submap (cdr submap))))
514 (setq define-key-rebound-commands t))
516 ;; Command-line options supported by tty's:
517 (defconst tty-long-option-alist
518 '(("--name" . "-name")
520 ("--reverse-video" . "-reverse")
521 ("--foreground-color" . "-fg")
522 ("--background-color" . "-bg")
523 ("--color" . "-color")))
525 (defconst tool-bar-images-pixel-height 24
526 "Height in pixels of images in the tool bar.")
528 (defvar tool-bar-originally-present nil
529 "Non-nil if tool-bars are present before user and site init files are read.")
531 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
532 (defun tty-handle-args (args)
536 (not (equal (car args) "--")))
537 (let* ((argi (pop args))
540 ;; Check for long options with attached arguments
541 ;; and separate out the attached option argument into argval.
542 (when (string-match "^\\(--[^=]*\\)=" argi)
543 (setq argval (substring argi (match-end 0))
544 argi (match-string 1 argi)))
545 (when (string-match "^--" argi)
546 (setq completion (try-completion argi tty-long-option-alist))
547 (if (eq completion t)
548 ;; Exact match for long option.
549 (setq argi (cdr (assoc argi tty-long-option-alist)))
550 (if (stringp completion)
551 (let ((elt (assoc completion tty-long-option-alist)))
552 ;; Check for abbreviated long option.
554 (error "Option `%s' is ambiguous" argi))
555 (setq argi (cdr elt)))
556 ;; Check for a short option.
559 (cond ((member argi '("-fg" "-foreground"))
560 (push (cons 'foreground-color (or argval (pop args)))
561 default-frame-alist))
562 ((member argi '("-bg" "-background"))
563 (push (cons 'background-color (or argval (pop args)))
564 default-frame-alist))
565 ((member argi '("-T" "-name"))
566 (unless argval (setq argval (pop args)))
570 (let ((case-fold-search t)
572 (setq argval (invocation-name))
574 ;; Change any . or * characters in name to
575 ;; hyphens, so as to emulate behavior on X.
577 (setq i (string-match "[.*]" argval))
580 default-frame-alist))
581 ((member argi '("-r" "-rv" "-reverse"))
583 default-frame-alist))
584 ((equal argi "-color")
585 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
586 (push (cons 'tty-color-mode
588 ((numberp argval) argval)
589 ((string-match "-?[0-9]+" argval)
590 (string-to-number argval))
591 (t (intern argval))))
592 default-frame-alist))
597 (defun command-line ()
598 (setq command-line-default-directory default-directory)
600 ;; Choose a reasonable location for temporary files.
601 (custom-reevaluate-setting 'temporary-file-directory)
602 (custom-reevaluate-setting 'small-temporary-file-directory)
603 (custom-reevaluate-setting 'auto-save-file-name-transforms)
605 ;; See if we should import version-control from the environment variable.
606 (let ((vc (getenv "VERSION_CONTROL")))
607 (cond ((eq vc nil)) ;don't do anything if not set
608 ((member vc '("t" "numbered"))
609 (setq version-control t))
610 ((member vc '("nil" "existing"))
611 (setq version-control nil))
612 ((member vc '("never" "simple"))
613 (setq version-control 'never))))
615 ;;! This has been commented out; I currently find the behavior when
616 ;;! split-window-keep-point is nil disturbing, but if I can get used
617 ;;! to it, then it would be better to eliminate the option.
618 ;;! ;; Choose a good default value for split-window-keep-point.
619 ;;! (setq split-window-keep-point (> baud-rate 2400))
621 ;; Set the default strings to display in mode line for
622 ;; end-of-line formats that aren't native to this platform.
624 ((memq system-type '(ms-dos windows-nt emx))
625 (setq eol-mnemonic-unix "(Unix)"
626 eol-mnemonic-mac "(Mac)"))
627 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
628 ;; abbreviated strings `/' and `:' set in coding.c for them.
629 ((eq system-type 'macos)
630 (setq eol-mnemonic-dos "(DOS)"))
631 (t ; this is for Unix/GNU/Linux systems
632 (setq eol-mnemonic-dos "(DOS)"
633 eol-mnemonic-mac "(Mac)")))
635 ;; Read window system's init file if using a window system.
636 (condition-case error
637 (if (and window-system (not noninteractive))
638 (load (concat term-file-prefix
639 (symbol-name window-system)
641 ;; Every window system should have a startup file;
642 ;; barf if we can't find it.
644 ;; If we can't read it, print the error message and exit.
647 (if (eq (car error) 'error)
648 (apply 'concat (cdr error))
649 (if (memq 'file-error (get (car error) 'error-conditions))
652 (mapconcat (lambda (obj) (prin1-to-string obj t))
653 (cdr (cdr error)) ", "))
655 (get (car error) 'error-message)
656 (mapconcat (lambda (obj) (prin1-to-string obj t))
658 'external-debugging-output)
659 (terpri 'external-debugging-output)
660 (setq window-system nil)
663 ;; Windowed displays do this inside their *-win.el.
664 (unless (or (display-graphic-p) noninteractive)
665 (setq command-line-args (tty-handle-args command-line-args)))
667 (set-locale-environment nil)
669 ;; Convert preloaded file names in load-history to absolute.
670 (let ((simple-file-name
671 ;; Look for simple.el or simple.elc and use their directory
672 ;; as the place where all Lisp files live.
673 (locate-file "simple" load-path (get-load-suffixes)))
675 ;; Don't abort if simple.el cannot be found, but print a warning.
676 (if (null simple-file-name)
678 (princ "Warning: Could not find simple.el nor simple.elc"
679 'external-debugging-output)
680 (terpri 'external-debugging-output))
681 (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
683 (mapcar (lambda (elt)
684 (if (and (stringp (car elt))
685 (not (file-name-absolute-p (car elt))))
686 (cons (concat lisp-dir
692 ;; Convert the arguments to Emacs internal representation.
693 (let ((args (cdr command-line-args)))
696 (decode-coding-string (car args) locale-coding-system t))
700 (args (cdr command-line-args)))
702 ;; Figure out which user's init file to load,
703 ;; either from the environment or from the options.
704 (setq init-file-user (if noninteractive nil (user-login-name)))
705 ;; If user has not done su, use current $HOME to find .emacs.
707 (equal init-file-user (user-real-login-name))
708 (setq init-file-user ""))
710 ;; Process the command-line args, and delete the arguments
711 ;; processed. This is consistent with the way main in emacs.c
713 (while (and (not done) args)
714 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
715 ("--user") ("--iconic") ("--icon-type") ("--quick")
716 ("--no-blinking-cursor") ("--basic-display")))
720 ;; Handle --OPTION=VALUE format.
721 (when (string-match "^\\(--[^=]*\\)=" argi)
722 (setq argval (substring argi (match-end 0))
723 argi (match-string 1 argi)))
724 (unless (equal argi "--")
725 (let ((completion (try-completion argi longopts)))
726 (if (eq completion t)
727 (setq argi (substring argi 1))
728 (if (stringp completion)
729 (let ((elt (assoc completion longopts)))
731 (error "Option `%s' is ambiguous" argi))
732 (setq argi (substring (car elt) 1)))
736 ((member argi '("-Q" "-quick"))
737 (setq init-file-user nil
739 emacs-quick-startup t))
740 ((member argi '("-D" "-basic-display"))
741 (setq no-blinking-cursor t
742 emacs-basic-display t)
743 (push '(vertical-scroll-bars . nil) initial-frame-alist))
744 ((member argi '("-q" "-no-init-file"))
745 (setq init-file-user nil))
746 ((member argi '("-u" "-user"))
747 (setq init-file-user (or argval (pop args))
749 ((equal argi "-no-site-file")
750 (setq site-run-file nil))
751 ((equal argi "-debug-init")
752 (setq init-file-debug t))
753 ((equal argi "-iconic")
754 (push '(visibility . icon) initial-frame-alist))
755 ((member argi '("-icon-type" "-i" "-itype"))
756 (push '(icon-type . t) default-frame-alist))
757 ((member argi '("-nbc" "-no-blinking-cursor"))
758 (setq no-blinking-cursor t))
759 ;; Push the popped arg back on the list of arguments.
763 ;; Was argval set but not used?
765 (error "Option `%s' doesn't allow an argument" argi))))
767 ;; Re-attach the program name to the front of the arg list.
768 (and command-line-args
769 (setcdr command-line-args args)))
771 (run-hooks 'before-init-hook)
773 ;; Under X Window, this creates the X frame and deletes the terminal frame.
774 (when (fboundp 'frame-initialize)
777 ;; Turn off blinking cursor if so specified in X resources. This is here
778 ;; only because all other settings of no-blinking-cursor are here.
779 (unless (or noninteractive
781 (and (memq window-system '(x w32 mac))
782 (not (member (x-get-resource "cursorBlink" "CursorBlink")
784 (setq no-blinking-cursor t))
786 ;; If frame was created with a menu bar, set menu-bar-mode on.
787 (unless (or noninteractive
789 (and (memq window-system '(x w32))
790 (<= (frame-parameter nil 'menu-bar-lines) 0)))
793 ;; If frame was created with a tool bar, switch tool-bar-mode on.
794 (unless (or noninteractive
796 (not (display-graphic-p))
797 (<= (frame-parameter nil 'tool-bar-lines) 0))
800 ;; Can't do this init in defcustom because the relevant variables
802 (custom-reevaluate-setting 'blink-cursor-mode)
803 (custom-reevaluate-setting 'normal-erase-is-backspace)
804 (custom-reevaluate-setting 'tooltip-mode)
805 (custom-reevaluate-setting 'global-font-lock-mode)
806 (custom-reevaluate-setting 'mouse-wheel-down-event)
807 (custom-reevaluate-setting 'mouse-wheel-up-event)
808 (custom-reevaluate-setting 'file-name-shadow-mode)
809 (custom-reevaluate-setting 'send-mail-function)
810 (custom-reevaluate-setting 'focus-follows-mouse)
812 ;; Register default TTY colors for the case the terminal hasn't a
813 ;; terminal init file.
814 (unless (memq window-system '(x w32 mac))
815 ;; We do this regardles of whether the terminal supports colors
816 ;; or not, since they can switch that support on or off in
817 ;; mid-session by setting the tty-color-mode frame parameter.
818 (tty-register-default-colors))
820 ;; Record whether the tool-bar is present before the user and site
821 ;; init files are processed. frame-notice-user-settings uses this
822 ;; to determine if the tool-bar has been disabled by the init files,
823 ;; and the frame needs to be resized.
824 (when (fboundp 'frame-notice-user-settings)
825 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
826 (assq 'tool-bar-lines default-frame-alist))))
827 (setq tool-bar-originally-present
830 (not (eq 0 (cdr tool-bar-lines)))))))
832 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
833 (old-font-list-limit font-list-limit)
834 (old-face-ignored-fonts face-ignored-fonts))
836 ;; Run the site-start library if it exists. The point of this file is
837 ;; that it is run before .emacs. There is no point in doing this after
838 ;; .emacs; that is useless.
840 (load site-run-file t t))
842 ;; Sites should not disable this. Only individuals should disable
843 ;; the startup message.
844 (setq inhibit-startup-message nil)
846 ;; Warn for invalid user name.
848 (if (string-match "[~/:\n]" init-file-user)
849 (display-warning 'initialization
850 (format "Invalid user name %s"
853 (if (file-directory-p (expand-file-name
854 ;; We don't support ~USER on MS-Windows except
855 ;; for the current user, and always load .emacs
856 ;; from the current user's home directory (see
857 ;; below). So always check "~", even if invoked
858 ;; with "-u USER", or if $USER or $LOGNAME are
859 ;; set to something different.
860 (if (eq system-type 'windows-nt)
862 (concat "~" init-file-user))))
864 (display-warning 'initialization
865 (format "User %s has no home directory"
869 ;; Load that user's init file, or the default one, or none.
870 (let (debug-on-error-from-init-file
871 debug-on-error-should-be-set
872 (debug-on-error-initial
873 (if (eq init-file-debug t) 'startup init-file-debug))
874 (orig-enable-multibyte default-enable-multibyte-characters))
875 (let ((debug-on-error debug-on-error-initial)
876 ;; This function actually reads the init files.
881 (let ((user-init-file-1
883 ((eq system-type 'ms-dos)
884 (concat "~" init-file-user "/_emacs"))
885 ((eq system-type 'windows-nt)
886 ;; Prefer .emacs on Windows.
887 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
889 ;; Also support _emacs for compatibility.
890 (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
892 ;; But default to .emacs if _emacs does not exist.
894 ((eq system-type 'vax-vms)
897 (concat "~" init-file-user "/.emacs")))))
898 ;; This tells `load' to store the file name found
899 ;; into user-init-file.
900 (setq user-init-file t)
901 (load user-init-file-1 t t)
903 (when (eq user-init-file t)
904 ;; If we did not find ~/.emacs, try
905 ;; ~/.emacs.d/init.el.
909 (file-name-as-directory
910 (concat "~" init-file-user "/.emacs.d")))))
913 ;; If we did not find the user's init file,
914 ;; set user-init-file conclusively.
915 ;; Don't let it be set from default.el.
916 (when (eq user-init-file t)
917 (setq user-init-file user-init-file-1))))
919 ;; If we loaded a compiled file, set
920 ;; `user-init-file' to the source version if that
922 (when (and user-init-file
923 (equal (file-name-extension user-init-file)
925 (let* ((source (file-name-sans-extension user-init-file))
926 (alt (concat source ".el")))
927 (setq source (cond ((file-exists-p alt) alt)
928 ((file-exists-p source) source)
931 (when (file-newer-than-file-p source user-init-file)
932 (message "Warning: %s is newer than %s"
933 source user-init-file)
935 (setq user-init-file source))))
937 (unless inhibit-default-init
938 (let ((inhibit-startup-message nil))
939 ;; Users are supposed to be told their rights.
940 ;; (Plus how to get help and how to undo.)
941 ;; Don't you dare turn this off for anyone
943 (load "default" t t)))))))))
945 ;; Do this without a condition-case if the user wants to debug.
947 (condition-case error
950 (setq init-file-had-error nil))
952 (let ((message-log-max nil))
954 (set-buffer (get-buffer-create "*Messages*"))
956 (format "An error has occurred while loading `%s':\n\n"
959 (get (car error) 'error-message)
960 (if (cdr error) ": " "")
961 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
963 "To ensure normal operation, you should investigate and remove the\n"
964 "cause of the error in your initialization file. Start Emacs with\n"
965 "the `--debug-init' option to view a complete error backtrace.\n\n"))
966 (message "Error in init file: %s%s%s"
967 (get (car error) 'error-message)
968 (if (cdr error) ": " "")
969 (mapconcat 'prin1-to-string (cdr error) ", "))
970 (let ((pop-up-windows nil))
971 (pop-to-buffer "*Messages*"))
972 (setq init-file-had-error t)))))
974 (if (and deactivate-mark transient-mark-mode)
975 (with-current-buffer (window-buffer)
978 ;; If the user has a file of abbrevs, read it.
979 ;; FIXME: after the 22.0 release this should be changed so
980 ;; that it does not read the abbrev file when -batch is used
981 ;; on the command line.
982 (when (and (file-exists-p abbrev-file-name)
983 (file-readable-p abbrev-file-name))
984 (quietly-read-abbrev-file abbrev-file-name))
986 ;; If the abbrevs came entirely from the init file or the
987 ;; abbrevs file, they do not need saving.
988 (setq abbrevs-changed nil)
990 ;; If we can tell that the init file altered debug-on-error,
991 ;; arrange to preserve the value that it set up.
992 (or (eq debug-on-error debug-on-error-initial)
993 (setq debug-on-error-should-be-set t
994 debug-on-error-from-init-file debug-on-error)))
995 (if debug-on-error-should-be-set
996 (setq debug-on-error debug-on-error-from-init-file))
997 (unless (or default-enable-multibyte-characters
998 (eq orig-enable-multibyte default-enable-multibyte-characters))
999 ;; Init file changed to unibyte. Reset existing multibyte
1000 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1001 ;; Arguably this should only be done if they're free of
1002 ;; multibyte characters.
1003 (mapcar (lambda (buffer)
1004 (with-current-buffer buffer
1005 (if enable-multibyte-characters
1006 (set-buffer-multibyte nil))))
1008 ;; Also re-set the language environment in case it was
1009 ;; originally done before unibyte was set and is sensitive to
1010 ;; unibyte (display table, terminal coding system &c).
1011 (set-language-environment current-language-environment)))
1013 ;; Do this here in case the init file sets mail-host-address.
1014 (if (equal user-mail-address "")
1015 (setq user-mail-address (or (getenv "EMAIL")
1016 (concat (user-login-name) "@"
1017 (or mail-host-address
1020 ;; Originally face attributes were specified via
1021 ;; `font-lock-face-attributes'. Users then changed the default
1022 ;; face attributes by setting that variable. However, we try and
1023 ;; be back-compatible and respect its value if set except for
1024 ;; faces where M-x customize has been used to save changes for the
1026 (when (boundp 'font-lock-face-attributes)
1027 (let ((face-attributes font-lock-face-attributes))
1028 (while face-attributes
1029 (let* ((face-attribute (pop face-attributes))
1030 (face (car face-attribute)))
1031 ;; Rustle up a `defface' SPEC from a
1032 ;; `font-lock-face-attributes' entry.
1033 (unless (get face 'saved-face)
1034 (let ((foreground (nth 1 face-attribute))
1035 (background (nth 2 face-attribute))
1036 (bold-p (nth 3 face-attribute))
1037 (italic-p (nth 4 face-attribute))
1038 (underline-p (nth 5 face-attribute))
1041 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1043 (setq face-spec (cons ':background (cons background face-spec))))
1045 (setq face-spec (append '(:weight bold) face-spec)))
1047 (setq face-spec (append '(:slant italic) face-spec)))
1049 (setq face-spec (append '(:underline t) face-spec)))
1050 (face-spec-set face (list (list t face-spec)) nil)))))))
1052 ;; If parameter have been changed in the init file which influence
1053 ;; face realization, clear the face cache so that new faces will
1055 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1056 (eq font-list-limit old-font-list-limit)
1057 (eq face-ignored-fonts old-face-ignored-fonts))
1058 (clear-face-cache)))
1060 (run-hooks 'after-init-hook)
1062 ;; Decode all default-directory.
1063 (if (and default-enable-multibyte-characters locale-coding-system)
1065 (dolist (elt (buffer-list))
1067 (if default-directory
1068 (setq default-directory
1069 (decode-coding-string default-directory
1070 locale-coding-system t))))
1071 (setq command-line-default-directory
1072 (decode-coding-string command-line-default-directory
1073 locale-coding-system t))))
1075 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1076 (if (get-buffer "*scratch*")
1077 (with-current-buffer "*scratch*"
1078 (if (eq major-mode 'fundamental-mode)
1079 (funcall initial-major-mode))))
1081 ;; Load library for our terminal type.
1082 ;; User init file can set term-file-prefix to nil to prevent this.
1083 (unless (or noninteractive
1085 (null term-file-prefix))
1086 (let* ((TERM (getenv "TERM"))
1090 (not (load (concat term-file-prefix term) t t)))
1091 ;; Strip off last hyphen and what follows, then try again
1093 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1094 (substring term 0 hyphend)
1097 ;; The terminal file has been loaded, now call the terminal specific
1098 ;; initialization function.
1100 (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
1101 (if (not (fboundp term-init-func))
1102 ;; Strip off last hyphen and what follows, then try again
1104 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1105 (substring term 0 hyphend)
1108 (funcall term-init-func))))))
1110 ;; Update the out-of-memory error message based on user's key bindings
1111 ;; for save-some-buffers.
1112 (setq memory-signal-data
1114 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1116 ;; Process the remaining args.
1117 (command-line-1 (cdr command-line-args))
1119 ;; If -batch, terminate after processing the command options.
1120 (if noninteractive (kill-emacs t))
1122 ;; Run emacs-session-restore (session management) if started by
1123 ;; the session manager and we have a session manager connection.
1124 (if (and (boundp 'x-session-previous-id)
1125 (stringp x-session-previous-id))
1127 (emacs-session-restore x-session-previous-id))))
1129 (defcustom initial-scratch-message (purecopy "\
1130 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1131 ;; If you want to create a file, visit that file with C-x C-f,
1132 ;; then enter the text in that file's own buffer.
1135 "Initial message displayed in *scratch* buffer at startup.
1136 If this is nil, no message will be displayed.
1137 If `inhibit-splash-screen' is non-nil, then no message is displayed,
1138 regardless of the value of this variable."
1139 :type '(choice (text :tag "Message")
1140 (const :tag "none" nil))
1141 :group 'initialization)
1144 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1145 ;;; Fancy splash screen
1146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1148 (defvar fancy-splash-text
1149 '((:face (variable-pitch :weight bold)
1150 "Important Help menu items:\n"
1151 :face variable-pitch
1152 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1153 "\tLearn how to use Emacs efficiently"
1155 (let* ((en "TUTORIAL")
1156 (tut (or (get-language-info current-language-environment
1159 (title (with-temp-buffer
1160 (insert-file-contents
1161 (expand-file-name tut tutorial-directory)
1163 (search-forward ".")
1164 (buffer-substring (point-min) (1- (point))))))
1165 ;; If there is a specific tutorial for the current language
1166 ;; environment and it is not English, append its title.
1167 (if (string= en tut)
1169 (concat " (" title ")"))))
1171 :face variable-pitch
1172 :link ("Emacs FAQ" (lambda (button) (view-emacs-FAQ)))
1173 "\tFrequently asked questions and answers\n"
1174 :link ("View Emacs Manual" (lambda (button) (info-emacs-manual)))
1175 "\tView the Emacs manual using Info\n"
1176 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1177 "\tGNU Emacs comes with "
1178 :face (variable-pitch :slant oblique)
1179 "ABSOLUTELY NO WARRANTY\n"
1180 :face variable-pitch
1181 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1182 "\tConditions for redistributing and changing Emacs\n"
1183 :link ("Getting New Versions" (lambda (button) (describe-distribution)))
1184 "\tHow to obtain the latest version of Emacs\n"
1185 :link ("More Manuals / Ordering Manuals" (lambda (button) (view-order-manuals)))
1186 " Buying printed manuals from the FSF\n")
1187 (:face (variable-pitch :weight bold)
1189 :face variable-pitch
1190 :link ("Visit New File"
1191 (lambda (button) (call-interactively 'find-file)))
1192 "\tSpecify a new file's name, to edit the file\n"
1193 :link ("Open Home Directory"
1194 (lambda (button) (dired "~")))
1195 "\tOpen your home directory, to operate on its files\n"
1196 :link ("Open *scratch* buffer"
1197 (lambda (button) (switch-to-buffer (get-buffer-create "*scratch*"))))
1198 "\tOpen buffer for notes you don't want to save\n"
1199 :link ("Customize Startup"
1200 (lambda (button) (customize-group 'initialization)))
1201 "\tChange initialization settings including this screen\n"
1203 "\nEmacs Guided Tour\tSee "
1204 :link ("http://www.gnu.org/software/emacs/tour/"
1205 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/")))
1208 "A list of texts to show in the middle part of splash screens.
1209 Each element in the list should be a list of strings or pairs
1210 `:face FACE', like `fancy-splash-insert' accepts them.")
1213 (defgroup fancy-splash-screen ()
1214 "Fancy splash screen when Emacs starts."
1216 :group 'initialization)
1219 (defcustom fancy-splash-delay 7
1220 "*Delay in seconds between splash screens."
1221 :group 'fancy-splash-screen
1225 (defcustom fancy-splash-max-time 30
1226 "*Show splash screens for at most this number of seconds.
1227 Values less than twice `fancy-splash-delay' are ignored."
1228 :group 'fancy-splash-screen
1232 (defcustom fancy-splash-image nil
1233 "*The image to show in the splash screens, or nil for defaults."
1234 :group 'fancy-splash-screen
1235 :type '(choice (const :tag "Default" nil)
1236 (file :tag "File")))
1239 (defvar splash-screen-keymap
1240 (let ((map (make-sparse-keymap)))
1241 (suppress-keymap map)
1242 (set-keymap-parent map button-buffer-map)
1243 (define-key map "\C-?" 'scroll-down)
1244 (define-key map " " 'scroll-up)
1245 (define-key map "q" 'exit-splash-screen)
1247 "Keymap for splash screen buffer.")
1249 ;; These are temporary storage areas for the splash screen display.
1251 (defvar fancy-current-text nil)
1252 (defvar fancy-splash-help-echo nil)
1253 (defvar fancy-splash-stop-time nil)
1254 (defvar fancy-splash-outer-buffer nil)
1256 (defun fancy-splash-insert (&rest args)
1257 "Insert text into the current buffer, with faces.
1258 Arguments from ARGS should be either strings, functions called
1259 with no args that return a string, or pairs `:face FACE',
1260 where FACE is a valid face specification, as it can be used with
1261 `put-text-property'."
1262 (let ((current-face nil))
1264 (cond ((eq (car args) :face)
1265 (setq args (cdr args) current-face (car args)))
1266 ((eq (car args) :link)
1267 (setq args (cdr args))
1268 (let ((spec (car args)))
1269 (insert-button (car spec)
1270 'face (list 'link current-face)
1273 (t (insert (propertize (let ((it (car args)))
1278 'help-echo fancy-splash-help-echo))))
1279 (setq args (cdr args)))))
1282 (defun fancy-splash-head ()
1283 "Insert the head part of the splash screen into the current buffer."
1284 (let* ((image-file (cond ((stringp fancy-splash-image)
1286 ((and (display-color-p)
1287 (image-type-available-p 'xpm))
1288 (if (and (fboundp 'x-display-planes)
1289 (= (funcall 'x-display-planes) 8))
1293 (img (create-image image-file))
1294 (image-width (and img (car (image-size img))))
1295 (window-width (window-width (selected-window))))
1297 (when (> window-width image-width)
1298 ;; Center the image in the window.
1299 (insert (propertize " " 'display
1300 `(space :align-to (+ center (-0.5 . ,img)))))
1302 ;; Change the color of the XPM version of the splash image
1303 ;; so that it is visible with a dark frame background.
1304 (when (and (memq 'xpm img)
1305 (eq (frame-parameter nil 'background-mode) 'dark))
1306 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1308 ;; Insert the image with a help-echo and a link.
1309 (make-button (prog1 (point) (insert-image img)) (point)
1311 'help-echo "mouse-2: browse http://www.gnu.org/"
1312 'action (lambda (button) (browse-url "http://www.gnu.org/"))
1315 (fancy-splash-insert
1316 :face '(variable-pitch :foreground "red")
1317 (if (eq system-type 'gnu/linux)
1318 "GNU Emacs is one component of the GNU/Linux operating system."
1319 "GNU Emacs is one component of the GNU operating system."))
1321 (fancy-splash-insert
1322 :face 'variable-pitch
1323 "You can do basic editing with the menu bar and scroll bar \
1325 :face 'variable-pitch
1326 "To quit a partially entered command, type "
1329 :face 'variable-pitch
1332 (when fancy-splash-outer-buffer
1333 (fancy-splash-insert
1334 :face 'variable-pitch
1338 :face 'variable-pitch
1339 " to exit from this screen.\n")))
1341 (defun fancy-splash-tail ()
1342 "Insert the tail part of the splash screen into the current buffer."
1343 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1344 "cyan" "darkblue")))
1345 (fancy-splash-insert :face `(variable-pitch :foreground ,fg)
1349 :face '(variable-pitch :height 0.5)
1351 (and auto-save-list-file-prefix
1352 ;; Don't signal an error if the
1353 ;; directory for auto-save-list files
1354 ;; does not yet exist.
1355 (file-directory-p (file-name-directory
1356 auto-save-list-file-prefix))
1358 (file-name-directory auto-save-list-file-prefix)
1361 (regexp-quote (file-name-nondirectory
1362 auto-save-list-file-prefix)))
1364 (fancy-splash-insert :face '(variable-pitch :foreground "red")
1365 "\n\nIf an Emacs session crashed recently, "
1367 :face '(fixed-pitch :foreground "red")
1368 "Meta-x recover-session RET"
1369 :face '(variable-pitch :foreground "red")
1371 " the files you were editing.\n"))))
1373 (defun fancy-splash-screens-1 (buffer)
1374 "Timer function displaying a splash screen."
1375 (when (> (float-time) fancy-splash-stop-time)
1376 (throw 'stop-splashing nil))
1377 (unless fancy-current-text
1378 (setq fancy-current-text fancy-splash-text))
1379 (let ((text (car fancy-current-text))
1380 (inhibit-read-only t))
1383 (if pure-space-overflow
1385 Warning Warning!!! Pure space overflow !!!Warning Warning
1386 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1388 (apply #'fancy-splash-insert text)
1390 (unless (current-message)
1391 (message fancy-splash-help-echo))
1392 (set-buffer-modified-p nil)
1393 (goto-char (point-min))
1394 (force-mode-line-update)
1395 (setq fancy-current-text (cdr fancy-current-text))))
1397 (defun exit-splash-screen ()
1398 "Stop displaying the splash screen buffer."
1400 (if fancy-splash-outer-buffer
1404 (defun fancy-splash-screens (&optional static)
1405 "Display fancy splash screens when Emacs starts."
1407 (let ((old-hourglass display-hourglass)
1408 (fancy-splash-outer-buffer (current-buffer))
1410 (frame (fancy-splash-frame))
1412 (save-selected-window
1413 (select-frame frame)
1414 (switch-to-buffer "*About GNU Emacs*")
1415 (make-local-variable 'cursor-type)
1416 (setq splash-buffer (current-buffer))
1417 (catch 'stop-splashing
1419 (let ((cursor-type nil))
1420 (setq display-hourglass nil
1422 mode-line-format (propertize "---- %b %-"
1423 'face 'mode-line-buffer-id)
1424 fancy-splash-stop-time (+ (float-time)
1425 fancy-splash-max-time)
1426 timer (run-with-timer 0 fancy-splash-delay
1427 #'fancy-splash-screens-1
1429 (use-local-map splash-screen-keymap)
1431 (message "%s" (startup-echo-area-message))
1432 (setq buffer-read-only t)
1434 (cancel-timer timer)
1435 (setq display-hourglass old-hourglass)
1436 (kill-buffer splash-buffer)))))
1437 ;; If static is non-nil, don't show fancy splash screen.
1438 (if (or (window-minibuffer-p)
1439 (window-dedicated-p (selected-window)))
1440 (pop-to-buffer (current-buffer))
1441 (switch-to-buffer "*GNU Emacs*"))
1442 (setq buffer-read-only nil)
1444 (if pure-space-overflow
1446 Warning Warning!!! Pure space overflow !!!Warning Warning
1447 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1448 (let (fancy-splash-outer-buffer)
1450 (dolist (text fancy-splash-text)
1451 (apply #'fancy-splash-insert text)
1453 (skip-chars-backward "\n")
1454 (delete-region (point) (point-max))
1457 (use-local-map splash-screen-keymap)
1459 (set-buffer-modified-p nil)
1460 (setq buffer-read-only t)
1461 (if (and view-read-only (not view-mode))
1462 (view-mode-enter nil 'kill-buffer))
1463 (goto-char (point-min)))))
1465 (defun fancy-splash-frame ()
1466 "Return the frame to use for the fancy splash screen.
1467 Returning non-nil does not mean we should necessarily
1468 use the fancy splash screen, but if we do use it,
1469 we put it on this frame."
1471 (dolist (frame (append (frame-list) (list (selected-frame))))
1472 (if (and (frame-visible-p frame)
1473 (not (window-minibuffer-p (frame-selected-window frame))))
1474 (setq chosen-frame frame)))
1477 (defun use-fancy-splash-screens-p ()
1478 "Return t if fancy splash screens should be used."
1479 (when (and (display-graphic-p)
1480 (or (and (display-color-p)
1481 (image-type-available-p 'xpm))
1482 (image-type-available-p 'pbm)))
1483 (let ((frame (fancy-splash-frame)))
1485 (let* ((img (create-image (or fancy-splash-image
1486 (if (and (display-color-p)
1487 (image-type-available-p 'xpm))
1488 "splash.xpm" "splash.pbm"))))
1489 (image-height (and img (cdr (image-size img nil frame))))
1490 ;; We test frame-height so that, if the frame is split
1491 ;; by displaying a warning, that doesn't cause the normal
1492 ;; splash screen to be used.
1493 (frame-height (1- (frame-height frame))))
1494 (> frame-height (+ image-height 19)))))))
1497 (defun normal-splash-screen (&optional static)
1498 "Display splash screen when Emacs starts."
1499 (let ((prev-buffer (current-buffer)))
1501 (with-current-buffer (get-buffer-create "*About GNU Emacs*")
1502 (setq buffer-read-only nil)
1504 (set (make-local-variable 'tab-width) 8)
1506 (set (make-local-variable 'mode-line-format)
1507 (propertize "---- %b %-" 'face 'mode-line-buffer-id)))
1509 (if pure-space-overflow
1511 Warning Warning!!! Pure space overflow !!!Warning Warning
1512 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1514 ;; The convention for this piece of code is that
1515 ;; each piece of output starts with one or two newlines
1516 ;; and does not end with any newlines.
1517 (insert "Welcome to GNU Emacs")
1519 (if (eq system-type 'gnu/linux)
1520 ", one component of the GNU/Linux operating system.\n"
1521 ", a part of the GNU operating system.\n"))
1524 (insert (substitute-command-keys
1526 "\nType \\[recenter] to quit from this screen.\n"))))
1528 (if (display-mouse-p)
1529 ;; The user can use the mouse to activate menus
1530 ;; so give help in terms of menu items.
1533 You can do basic editing with the menu bar and scroll bar using the mouse.
1534 To quit a partially entered command, type Control-g.\n")
1536 (insert "\nImportant Help menu items:\n")
1537 (insert-button "Emacs Tutorial"
1538 'action (lambda (button) (help-with-tutorial))
1540 (insert "\t\tLearn how to use Emacs efficiently\n")
1541 (insert-button "Emacs FAQ"
1542 'action (lambda (button) (view-emacs-FAQ))
1544 (insert "\t\tFrequently asked questions and answers\n")
1545 (insert-button "Read the Emacs Manual"
1546 'action (lambda (button) (info-emacs-manual))
1548 (insert "\tView the Emacs manual using Info\n")
1549 (insert-button "\(Non)Warranty"
1550 'action (lambda (button) (describe-no-warranty))
1552 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1553 (insert-button "Copying Conditions"
1554 'action (lambda (button) (describe-copying))
1556 (insert "\tConditions for redistributing and changing Emacs\n")
1557 (insert-button "Getting New Versions"
1558 'action (lambda (button) (describe-distribution))
1560 (insert "\tHow to obtain the latest version of Emacs\n")
1561 (insert-button "More Manuals / Ordering Manuals"
1562 'action (lambda (button) (view-order-manuals))
1564 (insert " How to order printed manuals from the FSF\n")
1566 (insert "\nUseful tasks:\n")
1567 (insert-button "Visit New File"
1568 'action (lambda (button) (call-interactively 'find-file))
1570 (insert "\t\tSpecify a new file's name, to edit the file\n")
1571 (insert-button "Open Home Directory"
1572 'action (lambda (button) (dired "~"))
1574 (insert "\tOpen your home directory, to operate on its files\n")
1575 (insert-button "Open *scratch* buffer"
1576 'action (lambda (button) (switch-to-buffer
1577 (get-buffer-create "*scratch*")))
1579 (insert "\tOpen buffer for notes you don't want to save\n")
1580 (insert-button "Customize Startup"
1581 'action (lambda (button) (customize-group 'initialization))
1583 (insert "\tChange initialization settings including this screen\n")
1585 (insert "\n" (emacs-version)
1586 "\n" emacs-copyright))
1588 ;; No mouse menus, so give help using kbd commands.
1590 ;; If keys have their default meanings,
1591 ;; use precomputed string to save lots of time.
1592 (if (and (eq (key-binding "\C-h") 'help-command)
1593 (eq (key-binding "\C-xu") 'advertised-undo)
1594 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
1595 (eq (key-binding "\C-ht") 'help-with-tutorial)
1596 (eq (key-binding "\C-hi") 'info)
1597 (eq (key-binding "\C-hr") 'info-emacs-manual)
1598 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
1601 Get help C-h (Hold down CTRL and press h)
1603 (insert-button "Emacs manual"
1604 'action (lambda (button) (info-emacs-manual))
1607 (insert-button "Browse manuals"
1608 'action (lambda (button) (Info-directory))
1612 (insert-button "Emacs tutorial"
1613 'action (lambda (button) (help-with-tutorial))
1615 (insert " C-h t\tUndo changes\t C-x u
1617 (insert-button "Buy manuals"
1618 'action (lambda (button) (view-order-manuals))
1620 (insert "\t C-h C-m\tExit Emacs\t C-x C-c"))
1625 (let ((where (where-is-internal
1626 'help-command nil t)))
1628 (key-description where)
1630 (insert-button "Emacs manual"
1631 'action (lambda (button) (info-emacs-manual))
1633 (insert (substitute-command-keys" \\[info-emacs-manual]\t"))
1634 (insert-button "Browse manuals"
1635 'action (lambda (button) (Info-directory))
1637 (insert (substitute-command-keys "\t \\[info]
1639 (insert-button "Emacs tutorial"
1640 'action (lambda (button) (help-with-tutorial))
1642 (insert (substitute-command-keys
1643 " \\[help-with-tutorial]\tUndo changes\t \\[advertised-undo]
1645 (insert-button "Buy manuals"
1646 'action (lambda (button) (view-order-manuals))
1648 (insert (substitute-command-keys
1649 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-emacs]")))
1651 ;; Say how to use the menu bar with the keyboard.
1653 (insert-button "Activate menubar"
1654 'action (lambda (button) (tmm-menubar))
1656 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1657 (eq (key-binding [f10]) 'tmm-menubar))
1658 (insert " F10 or ESC ` or M-`")
1659 (insert (substitute-command-keys " \\[tmm-menubar]")))
1661 ;; Many users seem to have problems with these.
1663 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1664 If you have no Meta key, you may instead type ESC followed by the character.)")
1666 ;; Insert links to useful tasks
1667 (insert "\nUseful tasks:\n")
1669 (insert-button "Visit New File"
1670 'action (lambda (button) (call-interactively 'find-file))
1673 (insert-button "Open Home Directory"
1674 'action (lambda (button) (dired "~"))
1678 (insert-button "Customize Startup"
1679 'action (lambda (button) (customize-group 'initialization))
1682 (insert-button "Open *scratch* buffer"
1683 'action (lambda (button) (switch-to-buffer
1684 (get-buffer-create "*scratch*")))
1688 (insert "\n" (emacs-version)
1689 "\n" emacs-copyright)
1691 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1692 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1693 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1697 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1698 (insert-button "full details"
1699 'action (lambda (button) (describe-no-warranty))
1702 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1703 of Emacs and modify it; type C-h C-c to see ")
1704 (insert-button "the conditions"
1705 'action (lambda (button) (describe-copying))
1708 Type C-h C-d for information on ")
1709 (insert-button "getting the latest version"
1710 'action (lambda (button) (describe-distribution))
1713 (insert (substitute-command-keys
1715 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1716 (insert-button "full details"
1717 'action (lambda (button) (describe-no-warranty))
1719 (insert (substitute-command-keys ".
1720 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1721 of Emacs and modify it; type \\[describe-copying] to see "))
1722 (insert-button "the conditions"
1723 'action (lambda (button) (describe-copying))
1725 (insert (substitute-command-keys".
1726 Type \\[describe-distribution] for information on "))
1727 (insert-button "getting the latest version"
1728 'action (lambda (button) (describe-distribution))
1732 ;; The rest of the startup screen is the same on all
1733 ;; kinds of terminals.
1735 ;; Give information on recovering, if there was a crash.
1736 (and auto-save-list-file-prefix
1737 ;; Don't signal an error if the
1738 ;; directory for auto-save-list files
1739 ;; does not yet exist.
1740 (file-directory-p (file-name-directory
1741 auto-save-list-file-prefix))
1743 (file-name-directory auto-save-list-file-prefix)
1746 (regexp-quote (file-name-nondirectory
1747 auto-save-list-file-prefix)))
1749 (insert "\n\nIf an Emacs session crashed recently, "
1750 "type Meta-x recover-session RET\nto recover"
1751 " the files you were editing.\n"))
1753 (use-local-map splash-screen-keymap)
1755 ;; Display the input that we set up in the buffer.
1756 (set-buffer-modified-p nil)
1757 (setq buffer-read-only t)
1758 (if (and view-read-only (not view-mode))
1759 (view-mode-enter nil 'kill-buffer))
1760 (goto-char (point-min))
1762 (if (or (window-minibuffer-p)
1763 (window-dedicated-p (selected-window)))
1764 ;; If static is nil, creating a new frame will
1765 ;; generate enough events that the subsequent `sit-for'
1766 ;; will immediately return anyway.
1767 nil ;; (pop-to-buffer (current-buffer))
1768 (save-window-excursion
1769 (switch-to-buffer (current-buffer))
1772 (switch-to-buffer (current-buffer))
1773 ;; In case the window is dedicated or something.
1774 (error (pop-to-buffer (current-buffer))))))
1775 ;; Unwind ... ensure splash buffer is killed
1777 (kill-buffer "*About GNU Emacs*")
1778 (switch-to-buffer "*About GNU Emacs*")
1779 (rename-buffer "*GNU Emacs*" t)))))
1782 (defun startup-echo-area-message ()
1783 (if (eq (key-binding "\C-h\C-p") 'describe-project)
1784 "For information about the GNU system and GNU/Linux, type C-h C-p."
1785 (substitute-command-keys
1786 "For information about the GNU system and GNU/Linux, type \
1787 \\[describe-project].")))
1790 (defun display-startup-echo-area-message ()
1791 (let ((resize-mini-windows t))
1792 (message "%s" (startup-echo-area-message))))
1795 (defun display-splash-screen (&optional static)
1796 "Display splash screen according to display.
1797 Fancy splash screens are used on graphic displays,
1799 With a prefix argument, any user input hides the splash screen."
1801 (if (use-fancy-splash-screens-p)
1802 (fancy-splash-screens static)
1803 (normal-splash-screen static)))
1805 (defalias 'about-emacs 'display-splash-screen)
1807 (defun command-line-1 (command-line-args-left)
1808 (or noninteractive (input-pending-p) init-file-had-error
1809 ;; t if the init file says to inhibit the echo area startup message.
1810 (and inhibit-startup-echo-area-message
1812 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1813 (equal inhibit-startup-echo-area-message
1814 (if (equal init-file-user "")
1817 ;; Wasn't set with custom; see if .emacs has a setq.
1818 (let ((buffer (get-buffer-create " *temp*")))
1823 (insert-file-contents user-init-file)
1826 "([ \t\n]*setq[ \t\n]+"
1827 "inhibit-startup-echo-area-message[ \t\n]+"
1830 (if (equal init-file-user "")
1836 (kill-buffer buffer)))))
1837 ;; display-splash-screen at the end of command-line-1 calls
1838 ;; use-fancy-splash-screens-p. This can cause image.el to be
1839 ;; loaded, putting "Loading image... done" in the echo area.
1840 ;; This hides startup-echo-area-message. So
1841 ;; use-fancy-splash-screens-p is called here simply to get the
1842 ;; loading of image.el (if needed) out of the way before
1843 ;; display-startup-echo-area-message runs.
1845 (use-fancy-splash-screens-p)
1846 (display-startup-echo-area-message)))
1848 ;; Delay 2 seconds after an init file error message
1849 ;; was displayed, so user can read it.
1850 (when init-file-had-error
1853 (when (and pure-space-overflow
1854 (not noninteractive))
1857 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
1860 (when command-line-args-left
1861 ;; We have command args; process them.
1862 (let ((dir command-line-default-directory)
1866 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
1867 ;; if foo is intended to be found in DIR.
1869 ;; ;; The directories listed in --directory/-L options will *appear*
1870 ;; ;; at the front of `load-path' in the order they appear on the
1871 ;; ;; command-line. We cannot do this by *placing* them at the front
1872 ;; ;; in the order they appear, so we need this variable to hold them,
1876 ;; To DTRT we keep track of the splice point and modify `load-path'
1877 ;; straight away upon any --directory/-L option.
1879 just-files ;; t if this follows the magic -- option.
1880 ;; This includes our standard options' long versions
1881 ;; and long versions of what's on command-switch-alist.
1883 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1884 ("--directory") ("--eval") ("--execute") ("--no-splash")
1885 ("--find-file") ("--visit") ("--file") ("--no-desktop"))
1886 (mapcar (lambda (elt)
1887 (list (concat "-" (car elt))))
1888 command-switch-alist)))
1892 ;; Add the long X options to longopts.
1893 (dolist (tem command-line-x-option-alist)
1894 (if (string-match "^--" (car tem))
1895 (push (list (car tem)) longopts)))
1897 ;; Loop, processing options.
1898 (while command-line-args-left
1899 (let* ((argi (car command-line-args-left))
1902 (setq command-line-args-left (cdr command-line-args-left))
1904 ;; Do preliminary decoding of the option.
1906 ;; After --, don't look for options; treat all args as files.
1908 ;; Convert long options to ordinary options
1909 ;; and separate out an attached option argument into argval.
1910 (when (string-match "^\\(--[^=]*\\)=" argi)
1911 (setq argval (substring argi (match-end 0))
1912 argi (match-string 1 argi)))
1913 (if (equal argi "--")
1914 (setq completion nil)
1915 (setq completion (try-completion argi longopts)))
1916 (if (eq completion t)
1917 (setq argi (substring argi 1))
1918 (if (stringp completion)
1919 (let ((elt (assoc completion longopts)))
1921 (error "Option `%s' is ambiguous" argi))
1922 (setq argi (substring (car elt) 1)))
1926 ;; Execute the option.
1927 (cond ((setq tem (assoc argi command-switch-alist))
1929 (let ((command-line-args-left
1930 (cons argval command-line-args-left)))
1931 (funcall (cdr tem) argi))
1932 (funcall (cdr tem) argi)))
1934 ((equal argi "-no-splash")
1935 (setq inhibit-startup-message t))
1937 ((member argi '("-f" ; what the manual claims
1939 "-e")) ; what the source used to say
1940 (setq tem (intern (or argval (pop command-line-args-left))))
1942 (command-execute tem)
1945 ((member argi '("-eval" "-execute"))
1946 (eval (read (or argval (pop command-line-args-left)))))
1948 ((member argi '("-L" "-directory"))
1949 (setq tem (expand-file-name
1950 (command-line-normalize-file-name
1951 (or argval (pop command-line-args-left)))))
1952 (cond (splice (setcdr splice (cons tem (cdr splice)))
1953 (setq splice (cdr splice)))
1954 (t (setq load-path (cons tem load-path)
1955 splice load-path))))
1957 ((member argi '("-l" "-load"))
1958 (let* ((file (command-line-normalize-file-name
1959 (or argval (pop command-line-args-left))))
1960 ;; Take file from default dir if it exists there;
1961 ;; otherwise let `load' search for it.
1962 (file-ex (expand-file-name file)))
1963 (when (file-exists-p file-ex)
1964 (setq file file-ex))
1967 ;; This is used to handle -script. It's not clear
1968 ;; we need to document it.
1969 ((member argi '("-scriptload"))
1970 (let* ((file (command-line-normalize-file-name
1971 (or argval (pop command-line-args-left))))
1972 ;; Take file from default dir.
1973 (file-ex (expand-file-name file)))
1974 (load file-ex nil t t)))
1976 ((equal argi "-insert")
1977 (setq tem (or argval (pop command-line-args-left)))
1979 (error "File name omitted from `-insert' option"))
1980 (insert-file-contents (command-line-normalize-file-name tem)))
1982 ((equal argi "-kill")
1985 ;; This is for when they use --no-desktop with -q, or
1986 ;; don't load Desktop in their .emacs. If desktop.el
1987 ;; _is_ loaded, it will handle this switch, and we
1988 ;; won't see it by the time we get here.
1989 ((equal argi "-no-desktop")
1990 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
1992 ((string-match "^\\+[0-9]+\\'" argi)
1993 (setq line (string-to-number argi)))
1995 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
1996 (setq line (string-to-number (match-string 1 argi))
1997 column (string-to-number (match-string 2 argi))))
1999 ((setq tem (assoc argi command-line-x-option-alist))
2000 ;; Ignore X-windows options and their args if not using X.
2001 (setq command-line-args-left
2002 (nthcdr (nth 1 tem) command-line-args-left)))
2004 ((member argi '("-find-file" "-file" "-visit"))
2005 ;; An explicit option to specify visiting a file.
2006 (setq tem (or argval (pop command-line-args-left)))
2007 (unless (stringp tem)
2008 (error "File name omitted from `%s' option" argi))
2009 (setq file-count (1+ file-count))
2010 (let ((file (expand-file-name
2011 (command-line-normalize-file-name tem) dir)))
2012 (if (= file-count 1)
2013 (setq first-file-buffer (find-file file))
2014 (find-file-other-window file)))
2018 (unless (< column 1)
2019 (move-to-column (1- column)))
2023 (setq just-files t))
2025 ;; We have almost exhausted our options. See if the
2026 ;; user has made any other command-line options available
2027 (let ((hooks command-line-functions) ;; lrs 7/31/89
2030 (not (setq did-hook (funcall (car hooks)))))
2031 (setq hooks (cdr hooks)))
2033 ;; Presume that the argument is a file name.
2035 (if (string-match "\\`-" argi)
2036 (error "Unknown option `%s'" argi))
2037 (setq file-count (1+ file-count))
2040 (command-line-normalize-file-name orig-argi)
2042 (if (= file-count 1)
2043 (setq first-file-buffer (find-file file))
2044 (find-file-other-window file)))
2048 (unless (< column 1)
2049 (move-to-column (1- column)))
2050 (setq column 0))))))
2051 ;; In unusual circumstances, the execution of Lisp code due
2052 ;; to command-line options can cause the last visible frame
2053 ;; to be deleted. In this case, kill emacs to avoid an
2055 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))
2057 ;; If 3 or more files visited, and not all visible,
2058 ;; show user what they all are. But leave the last one current.
2059 (and (> file-count 2)
2060 (not noninteractive)
2061 (not inhibit-startup-buffer-menu)
2062 (or (get-buffer-window first-file-buffer)
2065 (when initial-buffer-choice
2066 (cond ((eq initial-buffer-choice t)
2067 (switch-to-buffer (get-buffer-create "*scratch*")))
2068 ((stringp initial-buffer-choice)
2069 (find-file initial-buffer-choice))))
2071 ;; Maybe display a startup screen.
2072 (unless (or inhibit-startup-message
2073 initial-buffer-choice
2075 emacs-quick-startup)
2076 ;; Display a startup screen, after some preparations.
2078 ;; If there are no switches to process, we might as well
2079 ;; run this hook now, and there may be some need to do it
2080 ;; before doing any output.
2081 (run-hooks 'emacs-startup-hook)
2082 (and term-setup-hook
2083 (run-hooks 'term-setup-hook))
2084 (setq inhibit-startup-hooks t)
2086 ;; It's important to notice the user settings before we
2087 ;; display the startup message; otherwise, the settings
2088 ;; won't take effect until the user gives the first
2089 ;; keystroke, and that's distracting.
2090 (when (fboundp 'frame-notice-user-settings)
2091 (frame-notice-user-settings))
2093 ;; If there are no switches to process, we might as well
2094 ;; run this hook now, and there may be some need to do it
2095 ;; before doing any output.
2096 (when window-setup-hook
2097 (run-hooks 'window-setup-hook)
2098 ;; Don't let the hook be run twice.
2099 (setq window-setup-hook nil))
2101 ;; Do this now to avoid an annoying delay if the user
2102 ;; clicks the menu bar during the sit-for.
2103 (when (display-popup-menus-p)
2104 (precompute-menubar-bindings))
2106 (setq menubar-bindings-done t))
2108 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2109 (and initial-scratch-message
2110 (get-buffer "*scratch*")
2111 (with-current-buffer "*scratch*"
2112 (when (zerop (buffer-size))
2113 (insert initial-scratch-message)
2114 (set-buffer-modified-p nil))))
2116 ;; If user typed input during all that work,
2117 ;; abort the startup screen. Otherwise, display it now.
2118 (unless (input-pending-p)
2119 (display-splash-screen t))))
2122 (defun command-line-normalize-file-name (file)
2123 "Collapse multiple slashes to one, to handle non-Emacs file names."
2125 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2126 ;; That is significant on some systems.
2127 ;; However, /// at the beginning is supposed to mean just /, not //.
2128 (if (string-match "^///+" file)
2129 (setq file (replace-match "/" t t file)))
2130 (while (string-match "//+" file 1)
2131 (setq file (replace-match "/" t t file)))
2134 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
2135 ;;; startup.el ends here