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)
811 (custom-reevaluate-setting 'global-auto-composition-mode)
813 ;; Register default TTY colors for the case the terminal hasn't a
814 ;; terminal init file.
815 (unless (memq window-system '(x w32 mac))
816 ;; We do this regardles of whether the terminal supports colors
817 ;; or not, since they can switch that support on or off in
818 ;; mid-session by setting the tty-color-mode frame parameter.
819 (tty-register-default-colors))
821 ;; Record whether the tool-bar is present before the user and site
822 ;; init files are processed. frame-notice-user-settings uses this
823 ;; to determine if the tool-bar has been disabled by the init files,
824 ;; and the frame needs to be resized.
825 (when (fboundp 'frame-notice-user-settings)
826 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
827 (assq 'tool-bar-lines default-frame-alist))))
828 (setq tool-bar-originally-present
831 (not (eq 0 (cdr tool-bar-lines)))))))
833 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
834 (old-font-list-limit font-list-limit)
835 (old-face-ignored-fonts face-ignored-fonts))
837 ;; Run the site-start library if it exists. The point of this file is
838 ;; that it is run before .emacs. There is no point in doing this after
839 ;; .emacs; that is useless.
841 (load site-run-file t t))
843 ;; Sites should not disable this. Only individuals should disable
844 ;; the startup message.
845 (setq inhibit-startup-message nil)
847 ;; Warn for invalid user name.
849 (if (string-match "[~/:\n]" init-file-user)
850 (display-warning 'initialization
851 (format "Invalid user name %s"
854 (if (file-directory-p (expand-file-name
855 ;; We don't support ~USER on MS-Windows except
856 ;; for the current user, and always load .emacs
857 ;; from the current user's home directory (see
858 ;; below). So always check "~", even if invoked
859 ;; with "-u USER", or if $USER or $LOGNAME are
860 ;; set to something different.
861 (if (eq system-type 'windows-nt)
863 (concat "~" init-file-user))))
865 (display-warning 'initialization
866 (format "User %s has no home directory"
870 ;; Load that user's init file, or the default one, or none.
871 (let (debug-on-error-from-init-file
872 debug-on-error-should-be-set
873 (debug-on-error-initial
874 (if (eq init-file-debug t) 'startup init-file-debug))
875 (orig-enable-multibyte default-enable-multibyte-characters))
876 (let ((debug-on-error debug-on-error-initial)
877 ;; This function actually reads the init files.
882 (let ((user-init-file-1
884 ((eq system-type 'ms-dos)
885 (concat "~" init-file-user "/_emacs"))
886 ((eq system-type 'windows-nt)
887 ;; Prefer .emacs on Windows.
888 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
890 ;; Also support _emacs for compatibility.
891 (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
893 ;; But default to .emacs if _emacs does not exist.
895 ((eq system-type 'vax-vms)
898 (concat "~" init-file-user "/.emacs")))))
899 ;; This tells `load' to store the file name found
900 ;; into user-init-file.
901 (setq user-init-file t)
902 (load user-init-file-1 t t)
904 (when (eq user-init-file t)
905 ;; If we did not find ~/.emacs, try
906 ;; ~/.emacs.d/init.el.
910 (file-name-as-directory
911 (concat "~" init-file-user "/.emacs.d")))))
914 ;; If we did not find the user's init file,
915 ;; set user-init-file conclusively.
916 ;; Don't let it be set from default.el.
917 (when (eq user-init-file t)
918 (setq user-init-file user-init-file-1))))
920 ;; If we loaded a compiled file, set
921 ;; `user-init-file' to the source version if that
923 (when (and user-init-file
924 (equal (file-name-extension user-init-file)
926 (let* ((source (file-name-sans-extension user-init-file))
927 (alt (concat source ".el")))
928 (setq source (cond ((file-exists-p alt) alt)
929 ((file-exists-p source) source)
932 (when (file-newer-than-file-p source user-init-file)
933 (message "Warning: %s is newer than %s"
934 source user-init-file)
936 (setq user-init-file source))))
938 (unless inhibit-default-init
939 (let ((inhibit-startup-message nil))
940 ;; Users are supposed to be told their rights.
941 ;; (Plus how to get help and how to undo.)
942 ;; Don't you dare turn this off for anyone
944 (load "default" t t)))))))))
946 ;; Do this without a condition-case if the user wants to debug.
948 (condition-case error
951 (setq init-file-had-error nil))
953 (let ((message-log-max nil))
955 (set-buffer (get-buffer-create "*Messages*"))
957 (format "An error has occurred while loading `%s':\n\n"
960 (get (car error) 'error-message)
961 (if (cdr error) ": " "")
962 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
964 "To ensure normal operation, you should investigate and remove the\n"
965 "cause of the error in your initialization file. Start Emacs with\n"
966 "the `--debug-init' option to view a complete error backtrace.\n\n"))
967 (message "Error in init file: %s%s%s"
968 (get (car error) 'error-message)
969 (if (cdr error) ": " "")
970 (mapconcat 'prin1-to-string (cdr error) ", "))
971 (let ((pop-up-windows nil))
972 (pop-to-buffer "*Messages*"))
973 (setq init-file-had-error t)))))
975 (if (and deactivate-mark transient-mark-mode)
976 (with-current-buffer (window-buffer)
979 ;; If the user has a file of abbrevs, read it.
980 ;; FIXME: after the 22.0 release this should be changed so
981 ;; that it does not read the abbrev file when -batch is used
982 ;; on the command line.
983 (when (and (file-exists-p abbrev-file-name)
984 (file-readable-p abbrev-file-name))
985 (quietly-read-abbrev-file abbrev-file-name))
987 ;; If the abbrevs came entirely from the init file or the
988 ;; abbrevs file, they do not need saving.
989 (setq abbrevs-changed nil)
991 ;; If we can tell that the init file altered debug-on-error,
992 ;; arrange to preserve the value that it set up.
993 (or (eq debug-on-error debug-on-error-initial)
994 (setq debug-on-error-should-be-set t
995 debug-on-error-from-init-file debug-on-error)))
996 (if debug-on-error-should-be-set
997 (setq debug-on-error debug-on-error-from-init-file))
998 (unless (or default-enable-multibyte-characters
999 (eq orig-enable-multibyte default-enable-multibyte-characters))
1000 ;; Init file changed to unibyte. Reset existing multibyte
1001 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1002 ;; Arguably this should only be done if they're free of
1003 ;; multibyte characters.
1004 (mapcar (lambda (buffer)
1005 (with-current-buffer buffer
1006 (if enable-multibyte-characters
1007 (set-buffer-multibyte nil))))
1009 ;; Also re-set the language environment in case it was
1010 ;; originally done before unibyte was set and is sensitive to
1011 ;; unibyte (display table, terminal coding system &c).
1012 (set-language-environment current-language-environment)))
1014 ;; Do this here in case the init file sets mail-host-address.
1015 (if (equal user-mail-address "")
1016 (setq user-mail-address (or (getenv "EMAIL")
1017 (concat (user-login-name) "@"
1018 (or mail-host-address
1021 ;; Originally face attributes were specified via
1022 ;; `font-lock-face-attributes'. Users then changed the default
1023 ;; face attributes by setting that variable. However, we try and
1024 ;; be back-compatible and respect its value if set except for
1025 ;; faces where M-x customize has been used to save changes for the
1027 (when (boundp 'font-lock-face-attributes)
1028 (let ((face-attributes font-lock-face-attributes))
1029 (while face-attributes
1030 (let* ((face-attribute (pop face-attributes))
1031 (face (car face-attribute)))
1032 ;; Rustle up a `defface' SPEC from a
1033 ;; `font-lock-face-attributes' entry.
1034 (unless (get face 'saved-face)
1035 (let ((foreground (nth 1 face-attribute))
1036 (background (nth 2 face-attribute))
1037 (bold-p (nth 3 face-attribute))
1038 (italic-p (nth 4 face-attribute))
1039 (underline-p (nth 5 face-attribute))
1042 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1044 (setq face-spec (cons ':background (cons background face-spec))))
1046 (setq face-spec (append '(:weight bold) face-spec)))
1048 (setq face-spec (append '(:slant italic) face-spec)))
1050 (setq face-spec (append '(:underline t) face-spec)))
1051 (face-spec-set face (list (list t face-spec)) nil)))))))
1053 ;; If parameter have been changed in the init file which influence
1054 ;; face realization, clear the face cache so that new faces will
1056 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1057 (eq font-list-limit old-font-list-limit)
1058 (eq face-ignored-fonts old-face-ignored-fonts))
1059 (clear-face-cache)))
1061 (run-hooks 'after-init-hook)
1063 ;; Decode all default-directory.
1064 (if (and default-enable-multibyte-characters locale-coding-system)
1066 (dolist (elt (buffer-list))
1068 (if default-directory
1069 (setq default-directory
1070 (decode-coding-string default-directory
1071 locale-coding-system t))))
1072 (setq command-line-default-directory
1073 (decode-coding-string command-line-default-directory
1074 locale-coding-system t))))
1076 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1077 (if (get-buffer "*scratch*")
1078 (with-current-buffer "*scratch*"
1079 (if (eq major-mode 'fundamental-mode)
1080 (funcall initial-major-mode))))
1082 ;; Load library for our terminal type.
1083 ;; User init file can set term-file-prefix to nil to prevent this.
1084 (unless (or noninteractive
1086 (null term-file-prefix))
1087 (let* ((TERM (getenv "TERM"))
1091 (not (load (concat term-file-prefix term) t t)))
1092 ;; Strip off last hyphen and what follows, then try again
1094 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1095 (substring term 0 hyphend)
1098 ;; The terminal file has been loaded, now call the terminal specific
1099 ;; initialization function.
1101 (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
1102 (if (not (fboundp term-init-func))
1103 ;; Strip off last hyphen and what follows, then try again
1105 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
1106 (substring term 0 hyphend)
1109 (funcall term-init-func))))))
1111 ;; Update the out-of-memory error message based on user's key bindings
1112 ;; for save-some-buffers.
1113 (setq memory-signal-data
1115 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1117 ;; Process the remaining args.
1118 (command-line-1 (cdr command-line-args))
1120 ;; If -batch, terminate after processing the command options.
1121 (if noninteractive (kill-emacs t))
1123 ;; Run emacs-session-restore (session management) if started by
1124 ;; the session manager and we have a session manager connection.
1125 (if (and (boundp 'x-session-previous-id)
1126 (stringp x-session-previous-id))
1128 (emacs-session-restore x-session-previous-id))))
1130 (defcustom initial-scratch-message (purecopy "\
1131 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1132 ;; If you want to create a file, visit that file with C-x C-f,
1133 ;; then enter the text in that file's own buffer.
1136 "Initial message displayed in *scratch* buffer at startup.
1137 If this is nil, no message will be displayed.
1138 If `inhibit-splash-screen' is non-nil, then no message is displayed,
1139 regardless of the value of this variable."
1140 :type '(choice (text :tag "Message")
1141 (const :tag "none" nil))
1142 :group 'initialization)
1145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1146 ;;; Fancy splash screen
1147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1149 (defvar fancy-splash-text
1150 '((:face (variable-pitch :weight bold)
1151 "Important Help menu items:\n"
1152 :face variable-pitch
1153 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1154 "\tLearn how to use Emacs efficiently"
1156 (let* ((en "TUTORIAL")
1157 (tut (or (get-language-info current-language-environment
1160 (title (with-temp-buffer
1161 (insert-file-contents
1162 (expand-file-name tut tutorial-directory)
1164 (search-forward ".")
1165 (buffer-substring (point-min) (1- (point))))))
1166 ;; If there is a specific tutorial for the current language
1167 ;; environment and it is not English, append its title.
1168 (if (string= en tut)
1170 (concat " (" title ")"))))
1172 :face variable-pitch
1173 :link ("Emacs FAQ" (lambda (button) (view-emacs-FAQ)))
1174 "\tFrequently asked questions and answers\n"
1175 :link ("View Emacs Manual" (lambda (button) (info-emacs-manual)))
1176 "\tView the Emacs manual using Info\n"
1177 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1178 "\tGNU Emacs comes with "
1179 :face (variable-pitch :slant oblique)
1180 "ABSOLUTELY NO WARRANTY\n"
1181 :face variable-pitch
1182 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1183 "\tConditions for redistributing and changing Emacs\n"
1184 :link ("Getting New Versions" (lambda (button) (describe-distribution)))
1185 "\tHow to obtain the latest version of Emacs\n"
1186 :link ("More Manuals / Ordering Manuals" (lambda (button) (view-order-manuals)))
1187 " Buying printed manuals from the FSF\n")
1188 (:face (variable-pitch :weight bold)
1190 :face variable-pitch
1191 :link ("Visit New File"
1192 (lambda (button) (call-interactively 'find-file)))
1193 "\tSpecify a new file's name, to edit the file\n"
1194 :link ("Open Home Directory"
1195 (lambda (button) (dired "~")))
1196 "\tOpen your home directory, to operate on its files\n"
1197 :link ("Open *scratch* buffer"
1198 (lambda (button) (switch-to-buffer (get-buffer-create "*scratch*"))))
1199 "\tOpen buffer for notes you don't want to save\n"
1200 :link ("Customize Startup"
1201 (lambda (button) (customize-group 'initialization)))
1202 "\tChange initialization settings including this screen\n"
1204 "\nEmacs Guided Tour\tSee "
1205 :link ("http://www.gnu.org/software/emacs/tour/"
1206 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/")))
1209 "A list of texts to show in the middle part of splash screens.
1210 Each element in the list should be a list of strings or pairs
1211 `:face FACE', like `fancy-splash-insert' accepts them.")
1214 (defgroup fancy-splash-screen ()
1215 "Fancy splash screen when Emacs starts."
1217 :group 'initialization)
1220 (defcustom fancy-splash-delay 7
1221 "*Delay in seconds between splash screens."
1222 :group 'fancy-splash-screen
1226 (defcustom fancy-splash-max-time 30
1227 "*Show splash screens for at most this number of seconds.
1228 Values less than twice `fancy-splash-delay' are ignored."
1229 :group 'fancy-splash-screen
1233 (defcustom fancy-splash-image nil
1234 "*The image to show in the splash screens, or nil for defaults."
1235 :group 'fancy-splash-screen
1236 :type '(choice (const :tag "Default" nil)
1237 (file :tag "File")))
1240 (defvar splash-screen-keymap
1241 (let ((map (make-sparse-keymap)))
1242 (suppress-keymap map)
1243 (set-keymap-parent map button-buffer-map)
1244 (define-key map "\C-?" 'scroll-down)
1245 (define-key map " " 'scroll-up)
1246 (define-key map "q" 'exit-splash-screen)
1248 "Keymap for splash screen buffer.")
1250 ;; These are temporary storage areas for the splash screen display.
1252 (defvar fancy-current-text nil)
1253 (defvar fancy-splash-help-echo nil)
1254 (defvar fancy-splash-stop-time nil)
1255 (defvar fancy-splash-outer-buffer nil)
1257 (defun fancy-splash-insert (&rest args)
1258 "Insert text into the current buffer, with faces.
1259 Arguments from ARGS should be either strings, functions called
1260 with no args that return a string, or pairs `:face FACE',
1261 where FACE is a valid face specification, as it can be used with
1262 `put-text-property'."
1263 (let ((current-face nil))
1265 (cond ((eq (car args) :face)
1266 (setq args (cdr args) current-face (car args)))
1267 ((eq (car args) :link)
1268 (setq args (cdr args))
1269 (let ((spec (car args)))
1270 (insert-button (car spec)
1271 'face (list 'link current-face)
1274 (t (insert (propertize (let ((it (car args)))
1279 'help-echo fancy-splash-help-echo))))
1280 (setq args (cdr args)))))
1283 (defun fancy-splash-head ()
1284 "Insert the head part of the splash screen into the current buffer."
1285 (let* ((image-file (cond ((stringp fancy-splash-image)
1287 ((and (display-color-p)
1288 (image-type-available-p 'xpm))
1289 (if (and (fboundp 'x-display-planes)
1290 (= (funcall 'x-display-planes) 8))
1294 (img (create-image image-file))
1295 (image-width (and img (car (image-size img))))
1296 (window-width (window-width (selected-window))))
1298 (when (> window-width image-width)
1299 ;; Center the image in the window.
1300 (insert (propertize " " 'display
1301 `(space :align-to (+ center (-0.5 . ,img)))))
1303 ;; Change the color of the XPM version of the splash image
1304 ;; so that it is visible with a dark frame background.
1305 (when (and (memq 'xpm img)
1306 (eq (frame-parameter nil 'background-mode) 'dark))
1307 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1309 ;; Insert the image with a help-echo and a link.
1310 (make-button (prog1 (point) (insert-image img)) (point)
1312 'help-echo "mouse-2: browse http://www.gnu.org/"
1313 'action (lambda (button) (browse-url "http://www.gnu.org/"))
1316 (fancy-splash-insert
1317 :face '(variable-pitch :background "red")
1318 "\n!! This version is ALPHA status. It may lose your data!!\n\n")
1319 (fancy-splash-insert
1320 :face '(variable-pitch :foreground "red")
1321 (if (eq system-type 'gnu/linux)
1322 "GNU Emacs is one component of the GNU/Linux operating system."
1323 "GNU Emacs is one component of the GNU operating system."))
1325 (fancy-splash-insert
1326 :face 'variable-pitch
1327 "You can do basic editing with the menu bar and scroll bar \
1329 :face 'variable-pitch
1330 "To quit a partially entered command, type "
1333 :face 'variable-pitch
1336 (when fancy-splash-outer-buffer
1337 (fancy-splash-insert
1338 :face 'variable-pitch
1342 :face 'variable-pitch
1343 " to exit from this screen.\n")))
1345 (defun fancy-splash-tail ()
1346 "Insert the tail part of the splash screen into the current buffer."
1347 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1348 "cyan" "darkblue")))
1349 (fancy-splash-insert :face `(variable-pitch :foreground ,fg)
1353 :face '(variable-pitch :height 0.5)
1355 (and auto-save-list-file-prefix
1356 ;; Don't signal an error if the
1357 ;; directory for auto-save-list files
1358 ;; does not yet exist.
1359 (file-directory-p (file-name-directory
1360 auto-save-list-file-prefix))
1362 (file-name-directory auto-save-list-file-prefix)
1365 (regexp-quote (file-name-nondirectory
1366 auto-save-list-file-prefix)))
1368 (fancy-splash-insert :face '(variable-pitch :foreground "red")
1369 "\n\nIf an Emacs session crashed recently, "
1371 :face '(fixed-pitch :foreground "red")
1372 "Meta-x recover-session RET"
1373 :face '(variable-pitch :foreground "red")
1375 " the files you were editing.\n"))))
1377 (defun fancy-splash-screens-1 (buffer)
1378 "Timer function displaying a splash screen."
1379 (when (> (float-time) fancy-splash-stop-time)
1380 (throw 'stop-splashing nil))
1381 (unless fancy-current-text
1382 (setq fancy-current-text fancy-splash-text))
1383 (let ((text (car fancy-current-text))
1384 (inhibit-read-only t))
1387 (if pure-space-overflow
1389 Warning Warning!!! Pure space overflow !!!Warning Warning
1390 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1392 (apply #'fancy-splash-insert text)
1394 (unless (current-message)
1395 (message fancy-splash-help-echo))
1396 (set-buffer-modified-p nil)
1397 (goto-char (point-min))
1398 (force-mode-line-update)
1399 (setq fancy-current-text (cdr fancy-current-text))))
1401 (defun exit-splash-screen ()
1402 "Stop displaying the splash screen buffer."
1404 (if fancy-splash-outer-buffer
1408 (defun fancy-splash-screens (&optional static)
1409 "Display fancy splash screens when Emacs starts."
1411 (let ((old-hourglass display-hourglass)
1412 (fancy-splash-outer-buffer (current-buffer))
1414 (frame (fancy-splash-frame))
1416 (save-selected-window
1417 (select-frame frame)
1418 (switch-to-buffer "*About GNU Emacs*")
1419 (make-local-variable 'cursor-type)
1420 (setq splash-buffer (current-buffer))
1421 (catch 'stop-splashing
1423 (let ((cursor-type nil))
1424 (setq display-hourglass nil
1426 mode-line-format (propertize "---- %b %-"
1427 'face 'mode-line-buffer-id)
1428 fancy-splash-stop-time (+ (float-time)
1429 fancy-splash-max-time)
1430 timer (run-with-timer 0 fancy-splash-delay
1431 #'fancy-splash-screens-1
1433 (use-local-map splash-screen-keymap)
1435 (message "%s" (startup-echo-area-message))
1436 (setq buffer-read-only t)
1438 (cancel-timer timer)
1439 (setq display-hourglass old-hourglass)
1440 (kill-buffer splash-buffer)))))
1441 ;; If static is non-nil, don't show fancy splash screen.
1442 (if (or (window-minibuffer-p)
1443 (window-dedicated-p (selected-window)))
1444 (pop-to-buffer (current-buffer))
1445 (switch-to-buffer "*GNU Emacs*"))
1446 (setq buffer-read-only nil)
1448 (if pure-space-overflow
1450 Warning Warning!!! Pure space overflow !!!Warning Warning
1451 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1452 (let (fancy-splash-outer-buffer)
1454 (dolist (text fancy-splash-text)
1455 (apply #'fancy-splash-insert text)
1457 (skip-chars-backward "\n")
1458 (delete-region (point) (point-max))
1461 (use-local-map splash-screen-keymap)
1463 (set-buffer-modified-p nil)
1464 (setq buffer-read-only t)
1465 (if (and view-read-only (not view-mode))
1466 (view-mode-enter nil 'kill-buffer))
1467 (goto-char (point-min)))))
1469 (defun fancy-splash-frame ()
1470 "Return the frame to use for the fancy splash screen.
1471 Returning non-nil does not mean we should necessarily
1472 use the fancy splash screen, but if we do use it,
1473 we put it on this frame."
1475 (dolist (frame (append (frame-list) (list (selected-frame))))
1476 (if (and (frame-visible-p frame)
1477 (not (window-minibuffer-p (frame-selected-window frame))))
1478 (setq chosen-frame frame)))
1481 (defun use-fancy-splash-screens-p ()
1482 "Return t if fancy splash screens should be used."
1483 (when (and (display-graphic-p)
1484 (or (and (display-color-p)
1485 (image-type-available-p 'xpm))
1486 (image-type-available-p 'pbm)))
1487 (let ((frame (fancy-splash-frame)))
1489 (let* ((img (create-image (or fancy-splash-image
1490 (if (and (display-color-p)
1491 (image-type-available-p 'xpm))
1492 "splash.xpm" "splash.pbm"))))
1493 (image-height (and img (cdr (image-size img nil frame))))
1494 ;; We test frame-height so that, if the frame is split
1495 ;; by displaying a warning, that doesn't cause the normal
1496 ;; splash screen to be used.
1497 (frame-height (1- (frame-height frame))))
1498 (> frame-height (+ image-height 19)))))))
1501 (defun normal-splash-screen (&optional static)
1502 "Display splash screen when Emacs starts."
1503 (let ((prev-buffer (current-buffer)))
1505 (with-current-buffer (get-buffer-create "*About GNU Emacs*")
1506 (setq buffer-read-only nil)
1508 (set (make-local-variable 'tab-width) 8)
1510 (set (make-local-variable 'mode-line-format)
1511 (propertize "---- %b %-" 'face 'mode-line-buffer-id)))
1513 (if pure-space-overflow
1515 Warning Warning!!! Pure space overflow !!!Warning Warning
1516 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1518 ;; The convention for this piece of code is that
1519 ;; each piece of output starts with one or two newlines
1520 ;; and does not end with any newlines.
1521 (insert "Welcome to GNU Emacs")
1523 (if (eq system-type 'gnu/linux)
1524 ", one component of the GNU/Linux operating system.\n"
1525 ", a part of the GNU operating system.\n"))
1528 (insert (substitute-command-keys
1530 "\nType \\[recenter] to quit from this screen.\n"))))
1532 (if (display-mouse-p)
1533 ;; The user can use the mouse to activate menus
1534 ;; so give help in terms of menu items.
1537 You can do basic editing with the menu bar and scroll bar using the mouse.
1538 To quit a partially entered command, type Control-g.\n")
1540 (insert "\nImportant Help menu items:\n")
1541 (insert-button "Emacs Tutorial"
1542 'action (lambda (button) (help-with-tutorial))
1544 (insert "\t\tLearn how to use Emacs efficiently\n")
1545 (insert-button "Emacs FAQ"
1546 'action (lambda (button) (view-emacs-FAQ))
1548 (insert "\t\tFrequently asked questions and answers\n")
1549 (insert-button "Read the Emacs Manual"
1550 'action (lambda (button) (info-emacs-manual))
1552 (insert "\tView the Emacs manual using Info\n")
1553 (insert-button "\(Non)Warranty"
1554 'action (lambda (button) (describe-no-warranty))
1556 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1557 (insert-button "Copying Conditions"
1558 'action (lambda (button) (describe-copying))
1560 (insert "\tConditions for redistributing and changing Emacs\n")
1561 (insert-button "Getting New Versions"
1562 'action (lambda (button) (describe-distribution))
1564 (insert "\tHow to obtain the latest version of Emacs\n")
1565 (insert-button "More Manuals / Ordering Manuals"
1566 'action (lambda (button) (view-order-manuals))
1568 (insert " How to order printed manuals from the FSF\n")
1570 (insert "\nUseful tasks:\n")
1571 (insert-button "Visit New File"
1572 'action (lambda (button) (call-interactively 'find-file))
1574 (insert "\t\tSpecify a new file's name, to edit the file\n")
1575 (insert-button "Open Home Directory"
1576 'action (lambda (button) (dired "~"))
1578 (insert "\tOpen your home directory, to operate on its files\n")
1579 (insert-button "Open *scratch* buffer"
1580 'action (lambda (button) (switch-to-buffer
1581 (get-buffer-create "*scratch*")))
1583 (insert "\tOpen buffer for notes you don't want to save\n")
1584 (insert-button "Customize Startup"
1585 'action (lambda (button) (customize-group 'initialization))
1587 (insert "\tChange initialization settings including this screen\n")
1589 (insert "\n" (emacs-version)
1590 "\n" emacs-copyright))
1592 ;; No mouse menus, so give help using kbd commands.
1594 ;; If keys have their default meanings,
1595 ;; use precomputed string to save lots of time.
1596 (if (and (eq (key-binding "\C-h") 'help-command)
1597 (eq (key-binding "\C-xu") 'advertised-undo)
1598 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
1599 (eq (key-binding "\C-ht") 'help-with-tutorial)
1600 (eq (key-binding "\C-hi") 'info)
1601 (eq (key-binding "\C-hr") 'info-emacs-manual)
1602 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
1605 Get help C-h (Hold down CTRL and press h)
1607 (insert-button "Emacs manual"
1608 'action (lambda (button) (info-emacs-manual))
1611 (insert-button "Browse manuals"
1612 'action (lambda (button) (Info-directory))
1616 (insert-button "Emacs tutorial"
1617 'action (lambda (button) (help-with-tutorial))
1619 (insert " C-h t\tUndo changes\t C-x u
1621 (insert-button "Buy manuals"
1622 'action (lambda (button) (view-order-manuals))
1624 (insert "\t C-h C-m\tExit Emacs\t C-x C-c"))
1629 (let ((where (where-is-internal
1630 'help-command nil t)))
1632 (key-description where)
1634 (insert-button "Emacs manual"
1635 'action (lambda (button) (info-emacs-manual))
1637 (insert (substitute-command-keys" \\[info-emacs-manual]\t"))
1638 (insert-button "Browse manuals"
1639 'action (lambda (button) (Info-directory))
1641 (insert (substitute-command-keys "\t \\[info]
1643 (insert-button "Emacs tutorial"
1644 'action (lambda (button) (help-with-tutorial))
1646 (insert (substitute-command-keys
1647 " \\[help-with-tutorial]\tUndo changes\t \\[advertised-undo]
1649 (insert-button "Buy manuals"
1650 'action (lambda (button) (view-order-manuals))
1652 (insert (substitute-command-keys
1653 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-emacs]")))
1655 ;; Say how to use the menu bar with the keyboard.
1657 (insert-button "Activate menubar"
1658 'action (lambda (button) (tmm-menubar))
1660 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1661 (eq (key-binding [f10]) 'tmm-menubar))
1662 (insert " F10 or ESC ` or M-`")
1663 (insert (substitute-command-keys " \\[tmm-menubar]")))
1665 ;; Many users seem to have problems with these.
1667 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1668 If you have no Meta key, you may instead type ESC followed by the character.)")
1670 ;; Insert links to useful tasks
1671 (insert "\nUseful tasks:\n")
1673 (insert-button "Visit New File"
1674 'action (lambda (button) (call-interactively 'find-file))
1677 (insert-button "Open Home Directory"
1678 'action (lambda (button) (dired "~"))
1682 (insert-button "Customize Startup"
1683 'action (lambda (button) (customize-group 'initialization))
1686 (insert-button "Open *scratch* buffer"
1687 'action (lambda (button) (switch-to-buffer
1688 (get-buffer-create "*scratch*")))
1692 (insert "\n" (emacs-version)
1693 "\n" emacs-copyright)
1695 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1696 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1697 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1701 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1702 (insert-button "full details"
1703 'action (lambda (button) (describe-no-warranty))
1706 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1707 of Emacs and modify it; type C-h C-c to see ")
1708 (insert-button "the conditions"
1709 'action (lambda (button) (describe-copying))
1712 Type C-h C-d for information on ")
1713 (insert-button "getting the latest version"
1714 'action (lambda (button) (describe-distribution))
1717 (insert (substitute-command-keys
1719 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1720 (insert-button "full details"
1721 'action (lambda (button) (describe-no-warranty))
1723 (insert (substitute-command-keys ".
1724 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1725 of Emacs and modify it; type \\[describe-copying] to see "))
1726 (insert-button "the conditions"
1727 'action (lambda (button) (describe-copying))
1729 (insert (substitute-command-keys".
1730 Type \\[describe-distribution] for information on "))
1731 (insert-button "getting the latest version"
1732 'action (lambda (button) (describe-distribution))
1736 ;; The rest of the startup screen is the same on all
1737 ;; kinds of terminals.
1739 ;; Give information on recovering, if there was a crash.
1740 (and auto-save-list-file-prefix
1741 ;; Don't signal an error if the
1742 ;; directory for auto-save-list files
1743 ;; does not yet exist.
1744 (file-directory-p (file-name-directory
1745 auto-save-list-file-prefix))
1747 (file-name-directory auto-save-list-file-prefix)
1750 (regexp-quote (file-name-nondirectory
1751 auto-save-list-file-prefix)))
1753 (insert "\n\nIf an Emacs session crashed recently, "
1754 "type Meta-x recover-session RET\nto recover"
1755 " the files you were editing.\n"))
1757 (use-local-map splash-screen-keymap)
1759 ;; Display the input that we set up in the buffer.
1760 (set-buffer-modified-p nil)
1761 (setq buffer-read-only t)
1762 (if (and view-read-only (not view-mode))
1763 (view-mode-enter nil 'kill-buffer))
1764 (goto-char (point-min))
1766 (if (or (window-minibuffer-p)
1767 (window-dedicated-p (selected-window)))
1768 ;; If static is nil, creating a new frame will
1769 ;; generate enough events that the subsequent `sit-for'
1770 ;; will immediately return anyway.
1771 nil ;; (pop-to-buffer (current-buffer))
1772 (save-window-excursion
1773 (switch-to-buffer (current-buffer))
1776 (switch-to-buffer (current-buffer))
1777 ;; In case the window is dedicated or something.
1778 (error (pop-to-buffer (current-buffer))))))
1779 ;; Unwind ... ensure splash buffer is killed
1781 (kill-buffer "*About GNU Emacs*")
1782 (switch-to-buffer "*About GNU Emacs*")
1783 (rename-buffer "*GNU Emacs*" t)))))
1786 (defun startup-echo-area-message ()
1787 (if (eq (key-binding "\C-h\C-p") 'describe-project)
1788 "For information about the GNU system and GNU/Linux, type C-h C-p."
1789 (substitute-command-keys
1790 "For information about the GNU system and GNU/Linux, type \
1791 \\[describe-project].")))
1794 (defun display-startup-echo-area-message ()
1795 (let ((resize-mini-windows t))
1796 (message "%s" (startup-echo-area-message))))
1799 (defun display-splash-screen (&optional static)
1800 "Display splash screen according to display.
1801 Fancy splash screens are used on graphic displays,
1803 With a prefix argument, any user input hides the splash screen."
1805 (if (use-fancy-splash-screens-p)
1806 (fancy-splash-screens static)
1807 (normal-splash-screen static)))
1809 (defalias 'about-emacs 'display-splash-screen)
1811 (defun command-line-1 (command-line-args-left)
1812 (or noninteractive (input-pending-p) init-file-had-error
1813 ;; t if the init file says to inhibit the echo area startup message.
1814 (and inhibit-startup-echo-area-message
1816 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1817 (equal inhibit-startup-echo-area-message
1818 (if (equal init-file-user "")
1821 ;; Wasn't set with custom; see if .emacs has a setq.
1822 (let ((buffer (get-buffer-create " *temp*")))
1827 (insert-file-contents user-init-file)
1830 "([ \t\n]*setq[ \t\n]+"
1831 "inhibit-startup-echo-area-message[ \t\n]+"
1834 (if (equal init-file-user "")
1840 (kill-buffer buffer)))))
1841 ;; display-splash-screen at the end of command-line-1 calls
1842 ;; use-fancy-splash-screens-p. This can cause image.el to be
1843 ;; loaded, putting "Loading image... done" in the echo area.
1844 ;; This hides startup-echo-area-message. So
1845 ;; use-fancy-splash-screens-p is called here simply to get the
1846 ;; loading of image.el (if needed) out of the way before
1847 ;; display-startup-echo-area-message runs.
1849 (use-fancy-splash-screens-p)
1850 (display-startup-echo-area-message)))
1852 ;; Delay 2 seconds after an init file error message
1853 ;; was displayed, so user can read it.
1854 (when init-file-had-error
1857 (when (and pure-space-overflow
1858 (not noninteractive))
1861 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
1864 (when command-line-args-left
1865 ;; We have command args; process them.
1866 (let ((dir command-line-default-directory)
1870 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
1871 ;; if foo is intended to be found in DIR.
1873 ;; ;; The directories listed in --directory/-L options will *appear*
1874 ;; ;; at the front of `load-path' in the order they appear on the
1875 ;; ;; command-line. We cannot do this by *placing* them at the front
1876 ;; ;; in the order they appear, so we need this variable to hold them,
1880 ;; To DTRT we keep track of the splice point and modify `load-path'
1881 ;; straight away upon any --directory/-L option.
1883 just-files ;; t if this follows the magic -- option.
1884 ;; This includes our standard options' long versions
1885 ;; and long versions of what's on command-switch-alist.
1887 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1888 ("--directory") ("--eval") ("--execute") ("--no-splash")
1889 ("--find-file") ("--visit") ("--file") ("--no-desktop"))
1890 (mapcar (lambda (elt)
1891 (list (concat "-" (car elt))))
1892 command-switch-alist)))
1896 ;; Add the long X options to longopts.
1897 (dolist (tem command-line-x-option-alist)
1898 (if (string-match "^--" (car tem))
1899 (push (list (car tem)) longopts)))
1901 ;; Loop, processing options.
1902 (while command-line-args-left
1903 (let* ((argi (car command-line-args-left))
1906 (setq command-line-args-left (cdr command-line-args-left))
1908 ;; Do preliminary decoding of the option.
1910 ;; After --, don't look for options; treat all args as files.
1912 ;; Convert long options to ordinary options
1913 ;; and separate out an attached option argument into argval.
1914 (when (string-match "^\\(--[^=]*\\)=" argi)
1915 (setq argval (substring argi (match-end 0))
1916 argi (match-string 1 argi)))
1917 (if (equal argi "--")
1918 (setq completion nil)
1919 (setq completion (try-completion argi longopts)))
1920 (if (eq completion t)
1921 (setq argi (substring argi 1))
1922 (if (stringp completion)
1923 (let ((elt (assoc completion longopts)))
1925 (error "Option `%s' is ambiguous" argi))
1926 (setq argi (substring (car elt) 1)))
1930 ;; Execute the option.
1931 (cond ((setq tem (assoc argi command-switch-alist))
1933 (let ((command-line-args-left
1934 (cons argval command-line-args-left)))
1935 (funcall (cdr tem) argi))
1936 (funcall (cdr tem) argi)))
1938 ((equal argi "-no-splash")
1939 (setq inhibit-startup-message t))
1941 ((member argi '("-f" ; what the manual claims
1943 "-e")) ; what the source used to say
1944 (setq tem (intern (or argval (pop command-line-args-left))))
1946 (command-execute tem)
1949 ((member argi '("-eval" "-execute"))
1950 (eval (read (or argval (pop command-line-args-left)))))
1952 ((member argi '("-L" "-directory"))
1953 (setq tem (expand-file-name
1954 (command-line-normalize-file-name
1955 (or argval (pop command-line-args-left)))))
1956 (cond (splice (setcdr splice (cons tem (cdr splice)))
1957 (setq splice (cdr splice)))
1958 (t (setq load-path (cons tem load-path)
1959 splice load-path))))
1961 ((member argi '("-l" "-load"))
1962 (let* ((file (command-line-normalize-file-name
1963 (or argval (pop command-line-args-left))))
1964 ;; Take file from default dir if it exists there;
1965 ;; otherwise let `load' search for it.
1966 (file-ex (expand-file-name file)))
1967 (when (file-exists-p file-ex)
1968 (setq file file-ex))
1971 ;; This is used to handle -script. It's not clear
1972 ;; we need to document it.
1973 ((member argi '("-scriptload"))
1974 (let* ((file (command-line-normalize-file-name
1975 (or argval (pop command-line-args-left))))
1976 ;; Take file from default dir.
1977 (file-ex (expand-file-name file)))
1978 (load file-ex nil t t)))
1980 ((equal argi "-insert")
1981 (setq tem (or argval (pop command-line-args-left)))
1983 (error "File name omitted from `-insert' option"))
1984 (insert-file-contents (command-line-normalize-file-name tem)))
1986 ((equal argi "-kill")
1989 ;; This is for when they use --no-desktop with -q, or
1990 ;; don't load Desktop in their .emacs. If desktop.el
1991 ;; _is_ loaded, it will handle this switch, and we
1992 ;; won't see it by the time we get here.
1993 ((equal argi "-no-desktop")
1994 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
1996 ((string-match "^\\+[0-9]+\\'" argi)
1997 (setq line (string-to-number argi)))
1999 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
2000 (setq line (string-to-number (match-string 1 argi))
2001 column (string-to-number (match-string 2 argi))))
2003 ((setq tem (assoc argi command-line-x-option-alist))
2004 ;; Ignore X-windows options and their args if not using X.
2005 (setq command-line-args-left
2006 (nthcdr (nth 1 tem) command-line-args-left)))
2008 ((member argi '("-find-file" "-file" "-visit"))
2009 ;; An explicit option to specify visiting a file.
2010 (setq tem (or argval (pop command-line-args-left)))
2011 (unless (stringp tem)
2012 (error "File name omitted from `%s' option" argi))
2013 (setq file-count (1+ file-count))
2014 (let ((file (expand-file-name
2015 (command-line-normalize-file-name tem) dir)))
2016 (if (= file-count 1)
2017 (setq first-file-buffer (find-file file))
2018 (find-file-other-window file)))
2022 (unless (< column 1)
2023 (move-to-column (1- column)))
2027 (setq just-files t))
2029 ;; We have almost exhausted our options. See if the
2030 ;; user has made any other command-line options available
2031 (let ((hooks command-line-functions) ;; lrs 7/31/89
2034 (not (setq did-hook (funcall (car hooks)))))
2035 (setq hooks (cdr hooks)))
2037 ;; Presume that the argument is a file name.
2039 (if (string-match "\\`-" argi)
2040 (error "Unknown option `%s'" argi))
2041 (setq file-count (1+ file-count))
2044 (command-line-normalize-file-name orig-argi)
2046 (if (= file-count 1)
2047 (setq first-file-buffer (find-file file))
2048 (find-file-other-window file)))
2052 (unless (< column 1)
2053 (move-to-column (1- column)))
2054 (setq column 0))))))
2055 ;; In unusual circumstances, the execution of Lisp code due
2056 ;; to command-line options can cause the last visible frame
2057 ;; to be deleted. In this case, kill emacs to avoid an
2059 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))
2061 ;; If 3 or more files visited, and not all visible,
2062 ;; show user what they all are. But leave the last one current.
2063 (and (> file-count 2)
2064 (not noninteractive)
2065 (not inhibit-startup-buffer-menu)
2066 (or (get-buffer-window first-file-buffer)
2069 (when initial-buffer-choice
2070 (cond ((eq initial-buffer-choice t)
2071 (switch-to-buffer (get-buffer-create "*scratch*")))
2072 ((stringp initial-buffer-choice)
2073 (find-file initial-buffer-choice))))
2075 ;; Maybe display a startup screen.
2076 (unless (or inhibit-startup-message
2077 initial-buffer-choice
2079 emacs-quick-startup)
2080 ;; Display a startup screen, after some preparations.
2082 ;; If there are no switches to process, we might as well
2083 ;; run this hook now, and there may be some need to do it
2084 ;; before doing any output.
2085 (run-hooks 'emacs-startup-hook)
2086 (and term-setup-hook
2087 (run-hooks 'term-setup-hook))
2088 (setq inhibit-startup-hooks t)
2090 ;; It's important to notice the user settings before we
2091 ;; display the startup message; otherwise, the settings
2092 ;; won't take effect until the user gives the first
2093 ;; keystroke, and that's distracting.
2094 (when (fboundp 'frame-notice-user-settings)
2095 (frame-notice-user-settings))
2097 ;; If there are no switches to process, we might as well
2098 ;; run this hook now, and there may be some need to do it
2099 ;; before doing any output.
2100 (when window-setup-hook
2101 (run-hooks 'window-setup-hook)
2102 ;; Don't let the hook be run twice.
2103 (setq window-setup-hook nil))
2105 ;; Do this now to avoid an annoying delay if the user
2106 ;; clicks the menu bar during the sit-for.
2107 (when (display-popup-menus-p)
2108 (precompute-menubar-bindings))
2110 (setq menubar-bindings-done t))
2112 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2113 (and initial-scratch-message
2114 (get-buffer "*scratch*")
2115 (with-current-buffer "*scratch*"
2116 (when (zerop (buffer-size))
2117 (insert initial-scratch-message)
2118 (set-buffer-modified-p nil))))
2120 ;; If user typed input during all that work,
2121 ;; abort the startup screen. Otherwise, display it now.
2122 (unless (input-pending-p)
2123 (display-splash-screen t))))
2126 (defun command-line-normalize-file-name (file)
2127 "Collapse multiple slashes to one, to handle non-Emacs file names."
2129 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2130 ;; That is significant on some systems.
2131 ;; However, /// at the beginning is supposed to mean just /, not //.
2132 (if (string-match "^///+" file)
2133 (setq file (replace-match "/" t t file)))
2134 (while (string-match "//+" file 1)
2135 (setq file (replace-match "/" t t file)))
2138 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
2139 ;;; startup.el ends here