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 (defun normal-top-level-add-subdirs-to-load-path ()
312 "Add all subdirectories of current directory to `load-path'.
313 More precisely, this uses only the subdirectories whose names
314 start with letters or digits; it excludes any subdirectory named `RCS'
315 or `CVS', and any subdirectory that contains a file named `.nosearch'."
318 (pending (list default-directory
)))
319 ;; This loop does a breadth-first tree walk on DIR's subtree,
320 ;; putting each subdir into DIRS as its contents are examined.
322 (push (pop pending
) dirs
)
323 (let* ((this-dir (car dirs
))
324 (contents (directory-files this-dir
))
325 (default-directory this-dir
)
326 (canonicalized (if (fboundp 'untranslated-canonical-name
)
327 (untranslated-canonical-name this-dir
))))
328 ;; The Windows version doesn't report meaningful inode
329 ;; numbers, so use the canonicalized absolute file name of the
330 ;; directory instead.
331 (setq attrs
(or canonicalized
332 (nthcdr 10 (file-attributes this-dir
))))
333 (unless (member attrs normal-top-level-add-subdirs-inode-list
)
334 (push attrs normal-top-level-add-subdirs-inode-list
)
335 (dolist (file contents
)
336 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
337 (unless (member file
'("." ".." "RCS" "CVS" "rcs" "cvs"))
338 (when (and (string-match "\\`[[:alnum:]]" file
)
339 ;; Avoid doing a `stat' when it isn't necessary
340 ;; because that can cause trouble when an NFS server
342 (not (string-match "\\.elc?\\'" file
))
343 (file-directory-p file
))
344 (let ((expanded (expand-file-name file
)))
345 (unless (file-exists-p (expand-file-name ".nosearch"
347 (setq pending
(nconc pending
(list expanded
)))))))))))
348 (normal-top-level-add-to-load-path (cdr (nreverse dirs
)))))
350 ;; This function is called from a subdirs.el file.
351 ;; It assumes that default-directory is the directory
352 ;; in which the subdirs.el file exists,
353 ;; and it adds to load-path the subdirs of that directory
354 ;; as specified in DIRS. Normally the elements of DIRS are relative.
355 (defun normal-top-level-add-to-load-path (dirs)
356 (let ((tail load-path
)
357 (thisdir (directory-file-name default-directory
)))
359 ;;Don't go all the way to the nil terminator.
361 (not (equal thisdir
(car tail
)))
362 (not (and (memq system-type
'(ms-dos windows-nt
))
363 (equal (downcase thisdir
) (downcase (car tail
))))))
364 (setq tail
(cdr tail
)))
365 ;;Splice the new section in.
367 (setcdr tail
(append (mapcar 'expand-file-name dirs
) (cdr tail
))))))
369 (defun normal-top-level ()
370 (if command-line-processed
371 (message "Back to top level.")
372 (setq command-line-processed t
)
373 ;; Give *Messages* the same default-directory as *scratch*,
374 ;; just to keep things predictable.
375 (let ((dir default-directory
))
376 (with-current-buffer "*Messages*"
377 (setq default-directory dir
)))
378 ;; `user-full-name' is now known; reset its standard-value here.
379 (put 'user-full-name
'standard-value
380 (list (default-value 'user-full-name
)))
381 ;; For root, preserve owner and group when editing files.
382 (if (equal (user-uid) 0)
383 (setq backup-by-copying-when-mismatch t
))
384 ;; Look in each dir in load-path for a subdirs.el file.
385 ;; If we find one, load it, which will add the appropriate subdirs
386 ;; of that dir into load-path,
387 ;; Look for a leim-list.el file too. Loading it will register
388 ;; available input methods.
389 (let ((tail load-path
) dir
)
391 (setq dir
(car tail
))
392 (let ((default-directory dir
))
393 (load (expand-file-name "subdirs.el") t t t
))
394 (let ((default-directory dir
))
395 (load (expand-file-name "leim-list.el") t t t
))
396 ;; We don't use a dolist loop and we put this "setq-cdr" command at
397 ;; the end, because the subdirs.el files may add elements to the end
398 ;; of load-path and we want to take it into account.
399 (setq tail
(cdr tail
))))
400 (unless (eq system-type
'vax-vms
)
401 ;; If the PWD environment variable isn't accurate, delete it.
402 (let ((pwd (getenv "PWD")))
404 ;; Use FOO/., so that if FOO is a symlink, file-attributes
405 ;; describes the directory linked to, not FOO itself.
406 (or (equal (file-attributes
407 (concat (file-name-as-directory pwd
) "."))
409 (concat (file-name-as-directory default-directory
)
411 (setq process-environment
412 (delete (concat "PWD=" pwd
)
413 process-environment
))))))
414 (setq default-directory
(abbreviate-file-name default-directory
))
415 (let ((menubar-bindings-done nil
))
418 ;; Do this again, in case .emacs defined more abbreviations.
419 (setq default-directory
(abbreviate-file-name default-directory
))
420 ;; Specify the file for recording all the auto save files of this session.
421 ;; This is used by recover-session.
422 (or auto-save-list-file-name
423 (and auto-save-list-file-prefix
424 (setq auto-save-list-file-name
425 ;; Under MS-DOS our PID is almost always reused between
426 ;; Emacs invocations. We need something more unique.
427 (cond ((eq system-type
'ms-dos
)
428 ;; We are going to access the auto-save
429 ;; directory, so make sure it exists.
431 (file-name-directory auto-save-list-file-prefix
)
436 auto-save-list-file-prefix
))
441 auto-save-list-file-prefix
444 (unless inhibit-startup-hooks
445 (run-hooks 'emacs-startup-hook
)
447 (run-hooks 'term-setup-hook
)))
449 ;; Don't do this if we failed to create the initial frame,
450 ;; for instance due to a dense colormap.
451 (when (or frame-initial-frame
452 ;; If frame-initial-frame has no meaning, do this anyway.
453 (not (and window-system
455 (not (eq window-system
'pc
)))))
456 ;; Modify the initial frame based on what .emacs puts into
458 (if (fboundp 'frame-notice-user-settings
)
459 (frame-notice-user-settings))
460 (if (fboundp 'frame-set-background-mode
)
461 ;; Set the faces for the initial background mode even if
462 ;; frame-notice-user-settings didn't (such as on a tty).
463 ;; frame-set-background-mode is idempotent, so it won't
464 ;; cause any harm if it's already been done.
465 (let ((frame (selected-frame))
467 (when (and (null window-system
)
468 ;; Don't override default set by files in lisp/term.
469 (null default-frame-background-mode
)
470 (let ((bg (frame-parameter frame
'background-color
)))
472 (member bg
'(unspecified "unspecified-bg"
473 "unspecified-fg")))))
475 (setq term
(getenv "TERM"))
476 ;; Some files in lisp/term do a better job with the
477 ;; background mode, but we leave this here anyway, in
478 ;; case they remove those files.
479 (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
481 (setq default-frame-background-mode
'light
)))
482 (frame-set-background-mode (selected-frame)))))
484 ;; Now we know the user's default font, so add it to the menu.
485 (if (fboundp 'font-menu-add-default
)
486 (font-menu-add-default))
487 (and window-setup-hook
488 (run-hooks 'window-setup-hook
))
489 (or menubar-bindings-done
490 (if (display-popup-menus-p)
491 (precompute-menubar-bindings)))))))
493 ;; Precompute the keyboard equivalents in the menu bar items.
494 (defun precompute-menubar-bindings ()
495 (let ((submap (lookup-key global-map
[menu-bar
])))
497 (and (consp (car submap
))
498 (symbolp (car (car submap
)))
499 (stringp (car-safe (cdr (car submap
))))
500 (keymapp (cdr (cdr (car submap
))))
502 (x-popup-menu nil
(cdr (cdr (car submap
))))
505 (setq submap
(cdr submap
))))
506 (setq define-key-rebound-commands t
))
508 ;; Command-line options supported by tty's:
509 (defconst tty-long-option-alist
510 '(("--name" .
"-name")
512 ("--reverse-video" .
"-reverse")
513 ("--foreground-color" .
"-fg")
514 ("--background-color" .
"-bg")
515 ("--color" .
"-color")))
517 (defconst tool-bar-images-pixel-height
24
518 "Height in pixels of images in the tool bar.")
520 (defvar tool-bar-originally-present nil
521 "Non-nil if tool-bars are present before user and site init files are read.")
523 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
524 (defun tty-handle-args (args)
528 (not (equal (car args
) "--")))
529 (let* ((argi (pop args
))
532 ;; Check for long options with attached arguments
533 ;; and separate out the attached option argument into argval.
534 (when (string-match "^\\(--[^=]*\\)=" argi
)
535 (setq argval
(substring argi
(match-end 0))
536 argi
(match-string 1 argi
)))
537 (when (string-match "^--" argi
)
538 (setq completion
(try-completion argi tty-long-option-alist
))
539 (if (eq completion t
)
540 ;; Exact match for long option.
541 (setq argi
(cdr (assoc argi tty-long-option-alist
)))
542 (if (stringp completion
)
543 (let ((elt (assoc completion tty-long-option-alist
)))
544 ;; Check for abbreviated long option.
546 (error "Option `%s' is ambiguous" argi
))
547 (setq argi
(cdr elt
)))
548 ;; Check for a short option.
551 (cond ((member argi
'("-fg" "-foreground"))
552 (push (cons 'foreground-color
(or argval
(pop args
)))
553 default-frame-alist
))
554 ((member argi
'("-bg" "-background"))
555 (push (cons 'background-color
(or argval
(pop args
)))
556 default-frame-alist
))
557 ((member argi
'("-T" "-name"))
558 (unless argval
(setq argval
(pop args
)))
562 (let ((case-fold-search t
)
564 (setq argval
(invocation-name))
566 ;; Change any . or * characters in name to
567 ;; hyphens, so as to emulate behavior on X.
569 (setq i
(string-match "[.*]" argval
))
572 default-frame-alist
))
573 ((member argi
'("-r" "-rv" "-reverse"))
575 default-frame-alist
))
576 ((equal argi
"-color")
577 (unless argval
(setq argval
8)) ; default --color means 8 ANSI colors
578 (push (cons 'tty-color-mode
580 ((numberp argval
) argval
)
581 ((string-match "-?[0-9]+" argval
)
582 (string-to-number argval
))
583 (t (intern argval
))))
584 default-frame-alist
))
589 (defun command-line ()
590 (setq command-line-default-directory default-directory
)
592 ;; Choose a reasonable location for temporary files.
593 (custom-reevaluate-setting 'temporary-file-directory
)
594 (custom-reevaluate-setting 'small-temporary-file-directory
)
595 (custom-reevaluate-setting 'auto-save-file-name-transforms
)
597 ;; See if we should import version-control from the environment variable.
598 (let ((vc (getenv "VERSION_CONTROL")))
599 (cond ((eq vc nil
)) ;don't do anything if not set
600 ((member vc
'("t" "numbered"))
601 (setq version-control t
))
602 ((member vc
'("nil" "existing"))
603 (setq version-control nil
))
604 ((member vc
'("never" "simple"))
605 (setq version-control
'never
))))
607 ;;! This has been commented out; I currently find the behavior when
608 ;;! split-window-keep-point is nil disturbing, but if I can get used
609 ;;! to it, then it would be better to eliminate the option.
610 ;;! ;; Choose a good default value for split-window-keep-point.
611 ;;! (setq split-window-keep-point (> baud-rate 2400))
613 ;; Set the default strings to display in mode line for
614 ;; end-of-line formats that aren't native to this platform.
616 ((memq system-type
'(ms-dos windows-nt emx
))
617 (setq eol-mnemonic-unix
"(Unix)"
618 eol-mnemonic-mac
"(Mac)"))
619 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
620 ;; abbreviated strings `/' and `:' set in coding.c for them.
621 ((eq system-type
'macos
)
622 (setq eol-mnemonic-dos
"(DOS)"))
623 (t ; this is for Unix/GNU/Linux systems
624 (setq eol-mnemonic-dos
"(DOS)"
625 eol-mnemonic-mac
"(Mac)")))
627 ;; Read window system's init file if using a window system.
628 (condition-case error
629 (if (and window-system
(not noninteractive
))
630 (load (concat term-file-prefix
631 (symbol-name window-system
)
633 ;; Every window system should have a startup file;
634 ;; barf if we can't find it.
636 ;; If we can't read it, print the error message and exit.
639 (if (eq (car error
) 'error
)
640 (apply 'concat
(cdr error
))
641 (if (memq 'file-error
(get (car error
) 'error-conditions
))
644 (mapconcat (lambda (obj) (prin1-to-string obj t
))
645 (cdr (cdr error
)) ", "))
647 (get (car error
) 'error-message
)
648 (mapconcat (lambda (obj) (prin1-to-string obj t
))
650 'external-debugging-output
)
651 (terpri 'external-debugging-output
)
652 (setq window-system nil
)
655 ;; Windowed displays do this inside their *-win.el.
656 (unless (or (display-graphic-p) noninteractive
)
657 (setq command-line-args
(tty-handle-args command-line-args
)))
659 (set-locale-environment nil
)
661 ;; Convert preloaded file names in load-history to absolute.
662 (let ((simple-file-name
663 ;; Look for simple.el or simple.elc and use their directory
664 ;; as the place where all Lisp files live.
665 (locate-file "simple" load-path
(get-load-suffixes)))
667 ;; Don't abort if simple.el cannot be found, but print a warning.
668 (if (null simple-file-name
)
670 (princ "Warning: Could not find simple.el nor simple.elc"
671 'external-debugging-output
)
672 (terpri 'external-debugging-output
))
673 (setq lisp-dir
(file-truename (file-name-directory simple-file-name
)))
675 (mapcar (lambda (elt)
676 (if (and (stringp (car elt
))
677 (not (file-name-absolute-p (car elt
))))
678 (cons (concat lisp-dir
684 ;; Convert the arguments to Emacs internal representation.
685 (let ((args (cdr command-line-args
)))
688 (decode-coding-string (car args
) locale-coding-system t
))
692 (args (cdr command-line-args
)))
694 ;; Figure out which user's init file to load,
695 ;; either from the environment or from the options.
696 (setq init-file-user
(if noninteractive nil
(user-login-name)))
697 ;; If user has not done su, use current $HOME to find .emacs.
699 (equal init-file-user
(user-real-login-name))
700 (setq init-file-user
""))
702 ;; Process the command-line args, and delete the arguments
703 ;; processed. This is consistent with the way main in emacs.c
705 (while (and (not done
) args
)
706 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
707 ("--user") ("--iconic") ("--icon-type") ("--quick")
708 ("--no-blinking-cursor") ("--basic-display")))
712 ;; Handle --OPTION=VALUE format.
713 (when (string-match "^\\(--[^=]*\\)=" argi
)
714 (setq argval
(substring argi
(match-end 0))
715 argi
(match-string 1 argi
)))
716 (unless (equal argi
"--")
717 (let ((completion (try-completion argi longopts
)))
718 (if (eq completion t
)
719 (setq argi
(substring argi
1))
720 (if (stringp completion
)
721 (let ((elt (assoc completion longopts
)))
723 (error "Option `%s' is ambiguous" argi
))
724 (setq argi
(substring (car elt
) 1)))
728 ((member argi
'("-Q" "-quick"))
729 (setq init-file-user nil
731 emacs-quick-startup t
))
732 ((member argi
'("-D" "-basic-display"))
733 (setq no-blinking-cursor t
734 emacs-basic-display t
)
735 (push '(vertical-scroll-bars . nil
) initial-frame-alist
))
736 ((member argi
'("-q" "-no-init-file"))
737 (setq init-file-user nil
))
738 ((member argi
'("-u" "-user"))
739 (setq init-file-user
(or argval
(pop args
))
741 ((equal argi
"-no-site-file")
742 (setq site-run-file nil
))
743 ((equal argi
"-debug-init")
744 (setq init-file-debug t
))
745 ((equal argi
"-iconic")
746 (push '(visibility . icon
) initial-frame-alist
))
747 ((member argi
'("-icon-type" "-i" "-itype"))
748 (push '(icon-type . t
) default-frame-alist
))
749 ((member argi
'("-nbc" "-no-blinking-cursor"))
750 (setq no-blinking-cursor t
))
751 ;; Push the popped arg back on the list of arguments.
755 ;; Was argval set but not used?
757 (error "Option `%s' doesn't allow an argument" argi
))))
759 ;; Re-attach the program name to the front of the arg list.
760 (and command-line-args
761 (setcdr command-line-args args
)))
763 (run-hooks 'before-init-hook
)
765 ;; Under X Window, this creates the X frame and deletes the terminal frame.
766 (when (fboundp 'frame-initialize
)
769 ;; Turn off blinking cursor if so specified in X resources. This is here
770 ;; only because all other settings of no-blinking-cursor are here.
771 (unless (or noninteractive
773 (and (memq window-system
'(x w32 mac
))
774 (not (member (x-get-resource "cursorBlink" "CursorBlink")
776 (setq no-blinking-cursor t
))
778 ;; If frame was created with a menu bar, set menu-bar-mode on.
779 (unless (or noninteractive
781 (and (memq window-system
'(x w32
))
782 (<= (frame-parameter nil
'menu-bar-lines
) 0)))
785 ;; If frame was created with a tool bar, switch tool-bar-mode on.
786 (unless (or noninteractive
788 (not (display-graphic-p))
789 (<= (frame-parameter nil
'tool-bar-lines
) 0))
792 ;; Can't do this init in defcustom because the relevant variables
794 (custom-reevaluate-setting 'blink-cursor-mode
)
795 (custom-reevaluate-setting 'normal-erase-is-backspace
)
796 (custom-reevaluate-setting 'tooltip-mode
)
797 (custom-reevaluate-setting 'global-font-lock-mode
)
798 (custom-reevaluate-setting 'mouse-wheel-down-event
)
799 (custom-reevaluate-setting 'mouse-wheel-up-event
)
800 (custom-reevaluate-setting 'file-name-shadow-mode
)
801 (custom-reevaluate-setting 'send-mail-function
)
802 (custom-reevaluate-setting 'focus-follows-mouse
)
804 ;; Register default TTY colors for the case the terminal hasn't a
805 ;; terminal init file.
806 (unless (memq window-system
'(x w32 mac
))
807 ;; We do this regardles of whether the terminal supports colors
808 ;; or not, since they can switch that support on or off in
809 ;; mid-session by setting the tty-color-mode frame parameter.
810 (tty-register-default-colors))
812 ;; Record whether the tool-bar is present before the user and site
813 ;; init files are processed. frame-notice-user-settings uses this
814 ;; to determine if the tool-bar has been disabled by the init files,
815 ;; and the frame needs to be resized.
816 (when (fboundp 'frame-notice-user-settings
)
817 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist
)
818 (assq 'tool-bar-lines default-frame-alist
))))
819 (setq tool-bar-originally-present
822 (not (eq 0 (cdr tool-bar-lines
)))))))
824 (let ((old-scalable-fonts-allowed scalable-fonts-allowed
)
825 (old-font-list-limit font-list-limit
)
826 (old-face-ignored-fonts face-ignored-fonts
))
828 ;; Run the site-start library if it exists. The point of this file is
829 ;; that it is run before .emacs. There is no point in doing this after
830 ;; .emacs; that is useless.
832 (load site-run-file t t
))
834 ;; Sites should not disable this. Only individuals should disable
835 ;; the startup message.
836 (setq inhibit-startup-message nil
)
838 ;; Warn for invalid user name.
840 (if (string-match "[~/:\n]" init-file-user
)
841 (display-warning 'initialization
842 (format "Invalid user name %s"
845 (if (file-directory-p (expand-file-name
846 ;; We don't support ~USER on MS-Windows except
847 ;; for the current user, and always load .emacs
848 ;; from the current user's home directory (see
849 ;; below). So always check "~", even if invoked
850 ;; with "-u USER", or if $USER or $LOGNAME are
851 ;; set to something different.
852 (if (eq system-type
'windows-nt
)
854 (concat "~" init-file-user
))))
856 (display-warning 'initialization
857 (format "User %s has no home directory"
861 ;; Load that user's init file, or the default one, or none.
862 (let (debug-on-error-from-init-file
863 debug-on-error-should-be-set
864 (debug-on-error-initial
865 (if (eq init-file-debug t
) 'startup init-file-debug
))
866 (orig-enable-multibyte default-enable-multibyte-characters
))
867 (let ((debug-on-error debug-on-error-initial
)
868 ;; This function actually reads the init files.
873 (let ((user-init-file-1
875 ((eq system-type
'ms-dos
)
876 (concat "~" init-file-user
"/_emacs"))
877 ((eq system-type
'windows-nt
)
878 ;; Prefer .emacs on Windows.
879 (if (directory-files "~" nil
"^\\.emacs\\(\\.elc?\\)?$")
881 ;; Also support _emacs for compatibility.
882 (if (directory-files "~" nil
"^_emacs\\(\\.elc?\\)?$")
884 ;; But default to .emacs if _emacs does not exist.
886 ((eq system-type
'vax-vms
)
889 (concat "~" init-file-user
"/.emacs")))))
890 ;; This tells `load' to store the file name found
891 ;; into user-init-file.
892 (setq user-init-file t
)
893 (load user-init-file-1 t t
)
895 (when (eq user-init-file t
)
896 ;; If we did not find ~/.emacs, try
897 ;; ~/.emacs.d/init.el.
901 (file-name-as-directory
902 (concat "~" init-file-user
"/.emacs.d")))))
905 ;; If we did not find the user's init file,
906 ;; set user-init-file conclusively.
907 ;; Don't let it be set from default.el.
908 (when (eq user-init-file t
)
909 (setq user-init-file user-init-file-1
))))
911 ;; If we loaded a compiled file, set
912 ;; `user-init-file' to the source version if that
914 (when (and user-init-file
915 (equal (file-name-extension user-init-file
)
917 (let* ((source (file-name-sans-extension user-init-file
))
918 (alt (concat source
".el")))
919 (setq source
(cond ((file-exists-p alt
) alt
)
920 ((file-exists-p source
) source
)
923 (when (file-newer-than-file-p source user-init-file
)
924 (message "Warning: %s is newer than %s"
925 source user-init-file
)
927 (setq user-init-file source
))))
929 (unless inhibit-default-init
930 (let ((inhibit-startup-message nil
))
931 ;; Users are supposed to be told their rights.
932 ;; (Plus how to get help and how to undo.)
933 ;; Don't you dare turn this off for anyone
935 (load "default" t t
)))))))))
937 ;; Do this without a condition-case if the user wants to debug.
939 (condition-case error
942 (setq init-file-had-error nil
))
944 (let ((message-log-max nil
))
946 (set-buffer (get-buffer-create "*Messages*"))
948 (format "An error has occurred while loading `%s':\n\n"
951 (get (car error
) 'error-message
)
952 (if (cdr error
) ": " "")
953 (mapconcat (lambda (s) (prin1-to-string s t
)) (cdr error
) ", "))
955 "To ensure normal operation, you should investigate and remove the\n"
956 "cause of the error in your initialization file. Start Emacs with\n"
957 "the `--debug-init' option to view a complete error backtrace.\n\n"))
958 (message "Error in init file: %s%s%s"
959 (get (car error
) 'error-message
)
960 (if (cdr error
) ": " "")
961 (mapconcat 'prin1-to-string
(cdr error
) ", "))
962 (let ((pop-up-windows nil
))
963 (pop-to-buffer "*Messages*"))
964 (setq init-file-had-error t
)))))
966 (if (and deactivate-mark transient-mark-mode
)
967 (with-current-buffer (window-buffer)
970 ;; If the user has a file of abbrevs, read it.
971 ;; FIXME: after the 22.0 release this should be changed so
972 ;; that it does not read the abbrev file when -batch is used
973 ;; on the command line.
974 (when (and (file-exists-p abbrev-file-name
)
975 (file-readable-p abbrev-file-name
))
976 (quietly-read-abbrev-file abbrev-file-name
))
978 ;; If the abbrevs came entirely from the init file or the
979 ;; abbrevs file, they do not need saving.
980 (setq abbrevs-changed nil
)
982 ;; If we can tell that the init file altered debug-on-error,
983 ;; arrange to preserve the value that it set up.
984 (or (eq debug-on-error debug-on-error-initial
)
985 (setq debug-on-error-should-be-set t
986 debug-on-error-from-init-file debug-on-error
)))
987 (if debug-on-error-should-be-set
988 (setq debug-on-error debug-on-error-from-init-file
))
989 (unless (or default-enable-multibyte-characters
990 (eq orig-enable-multibyte default-enable-multibyte-characters
))
991 ;; Init file changed to unibyte. Reset existing multibyte
992 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
993 ;; Arguably this should only be done if they're free of
994 ;; multibyte characters.
995 (mapcar (lambda (buffer)
996 (with-current-buffer buffer
997 (if enable-multibyte-characters
998 (set-buffer-multibyte nil
))))
1000 ;; Also re-set the language environment in case it was
1001 ;; originally done before unibyte was set and is sensitive to
1002 ;; unibyte (display table, terminal coding system &c).
1003 (set-language-environment current-language-environment
)))
1005 ;; Do this here in case the init file sets mail-host-address.
1006 (if (equal user-mail-address
"")
1007 (setq user-mail-address
(or (getenv "EMAIL")
1008 (concat (user-login-name) "@"
1009 (or mail-host-address
1012 ;; Originally face attributes were specified via
1013 ;; `font-lock-face-attributes'. Users then changed the default
1014 ;; face attributes by setting that variable. However, we try and
1015 ;; be back-compatible and respect its value if set except for
1016 ;; faces where M-x customize has been used to save changes for the
1018 (when (boundp 'font-lock-face-attributes
)
1019 (let ((face-attributes font-lock-face-attributes
))
1020 (while face-attributes
1021 (let* ((face-attribute (pop face-attributes
))
1022 (face (car face-attribute
)))
1023 ;; Rustle up a `defface' SPEC from a
1024 ;; `font-lock-face-attributes' entry.
1025 (unless (get face
'saved-face
)
1026 (let ((foreground (nth 1 face-attribute
))
1027 (background (nth 2 face-attribute
))
1028 (bold-p (nth 3 face-attribute
))
1029 (italic-p (nth 4 face-attribute
))
1030 (underline-p (nth 5 face-attribute
))
1033 (setq face-spec
(cons ':foreground
(cons foreground face-spec
))))
1035 (setq face-spec
(cons ':background
(cons background face-spec
))))
1037 (setq face-spec
(append '(:weight bold
) face-spec
)))
1039 (setq face-spec
(append '(:slant italic
) face-spec
)))
1041 (setq face-spec
(append '(:underline t
) face-spec
)))
1042 (face-spec-set face
(list (list t face-spec
)) nil
)))))))
1044 ;; If parameter have been changed in the init file which influence
1045 ;; face realization, clear the face cache so that new faces will
1047 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed
)
1048 (eq font-list-limit old-font-list-limit
)
1049 (eq face-ignored-fonts old-face-ignored-fonts
))
1050 (clear-face-cache)))
1052 (run-hooks 'after-init-hook
)
1054 ;; Decode all default-directory.
1055 (if (and default-enable-multibyte-characters locale-coding-system
)
1057 (dolist (elt (buffer-list))
1059 (if default-directory
1060 (setq default-directory
1061 (decode-coding-string default-directory
1062 locale-coding-system t
))))
1063 (setq command-line-default-directory
1064 (decode-coding-string command-line-default-directory
1065 locale-coding-system t
))))
1067 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1068 (if (get-buffer "*scratch*")
1069 (with-current-buffer "*scratch*"
1070 (if (eq major-mode
'fundamental-mode
)
1071 (funcall initial-major-mode
))))
1073 ;; Load library for our terminal type.
1074 ;; User init file can set term-file-prefix to nil to prevent this.
1075 (unless (or noninteractive
1077 (null term-file-prefix
))
1078 (let* ((TERM (getenv "TERM"))
1082 (not (load (concat term-file-prefix term
) t t
)))
1083 ;; Strip off last hyphen and what follows, then try again
1085 (if (setq hyphend
(string-match "[-_][^-_]+\\'" term
))
1086 (substring term
0 hyphend
)
1089 ;; The terminal file has been loaded, now call the terminal specific
1090 ;; initialization function.
1092 (let ((term-init-func (intern-soft (concat "terminal-init-" term
))))
1093 (if (not (fboundp term-init-func
))
1094 ;; Strip off last hyphen and what follows, then try again
1096 (if (setq hyphend
(string-match "[-_][^-_]+\\'" term
))
1097 (substring term
0 hyphend
)
1100 (funcall term-init-func
))))))
1102 ;; Update the out-of-memory error message based on user's key bindings
1103 ;; for save-some-buffers.
1104 (setq memory-signal-data
1106 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1108 ;; Process the remaining args.
1109 (command-line-1 (cdr command-line-args
))
1111 ;; If -batch, terminate after processing the command options.
1112 (if noninteractive
(kill-emacs t
))
1114 ;; Run emacs-session-restore (session management) if started by
1115 ;; the session manager and we have a session manager connection.
1116 (if (and (boundp 'x-session-previous-id
)
1117 (stringp x-session-previous-id
))
1119 (emacs-session-restore x-session-previous-id
))))
1121 (defcustom initial-scratch-message
(purecopy "\
1122 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1123 ;; If you want to create a file, visit that file with C-x C-f,
1124 ;; then enter the text in that file's own buffer.
1127 "Initial message displayed in *scratch* buffer at startup.
1128 If this is nil, no message will be displayed.
1129 If `inhibit-splash-screen' is non-nil, then no message is displayed,
1130 regardless of the value of this variable."
1131 :type
'(choice (text :tag
"Message")
1132 (const :tag
"none" nil
))
1133 :group
'initialization
)
1136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1137 ;;; Fancy splash screen
1138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1140 (defvar fancy-splash-text
1141 '((:face
(variable-pitch :weight bold
)
1142 "Important Help menu items:\n"
1143 :face variable-pitch
1144 :link
("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1145 "\t\tLearn how to use Emacs efficiently"
1147 (let* ((en "TUTORIAL")
1148 (tut (or (get-language-info current-language-environment
1151 (title (with-temp-buffer
1152 (insert-file-contents
1153 (expand-file-name tut data-directory
)
1155 (search-forward ".")
1156 (buffer-substring (point-min) (1- (point))))))
1157 ;; If there is a specific tutorial for the current language
1158 ;; environment and it is not English, append its title.
1159 (if (string= en tut
)
1161 (concat " (" title
")"))))
1163 :face variable-pitch
1164 :link
("Emacs FAQ" (lambda (button) (view-emacs-FAQ)))
1165 "\t\tFrequently asked questions and answers\n"
1166 :link
("View Emacs Manual" (lambda (button) (info-emacs-manual)))
1167 "\t\tView the Emacs manual using Info\n"
1168 :link
("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1169 "\tGNU Emacs comes with "
1170 :face
(variable-pitch :slant oblique
)
1171 "ABSOLUTELY NO WARRANTY\n"
1172 :face variable-pitch
1173 :link
("Copying Conditions" (lambda (button) (describe-copying)))
1174 "\t\tConditions for redistributing and changing Emacs\n"
1175 :link
("Getting New Versions" (lambda (button) (describe-distribution)))
1176 "\tHow to obtain the latest version of Emacs\n"
1177 :link
("More Manuals / Ordering Manuals" (lambda (button) (view-order-manuals)))
1178 " Buying printed manuals from the FSF\n")
1179 (:face
(variable-pitch :weight bold
)
1180 "Useful File menu items:\n"
1181 :face variable-pitch
1182 :link
("Exit Emacs" (lambda (button) (save-buffers-kill-emacs)))
1186 :face variable-pitch
1190 :face variable-pitch
1192 :link
("Recover Crashed Session" (lambda (button) (recover-session)))
1193 "\tRecover files you were editing before a crash\n\n"
1195 :face
(variable-pitch :weight bold
)
1197 :face variable-pitch
1198 :link
("Visit New File"
1199 (lambda (button) (call-interactively 'find-file
)))
1200 " Specify a new file's name, to edit the file\n"
1201 :link
("Open Home Directory"
1202 (lambda (button) (dired "~")))
1203 " Open your home directory, to operate on its files\n"
1204 :link
("Open *scratch* buffer"
1205 (lambda (button) (switch-to-buffer (get-buffer-create "*scratch*"))))
1206 " Open buffer for notes you don't want to save\n"
1207 :link
("Customize Startup"
1208 (lambda (button) (customize-group 'initialization
)))
1209 " Change initialization settings including this screen\n"
1211 "\nEmacs Guided Tour\t\tSee "
1212 :link
("http://www.gnu.org/software/emacs/tour/"
1213 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/")))
1216 "A list of texts to show in the middle part of splash screens.
1217 Each element in the list should be a list of strings or pairs
1218 `:face FACE', like `fancy-splash-insert' accepts them.")
1221 (defgroup fancy-splash-screen
()
1222 "Fancy splash screen when Emacs starts."
1224 :group
'initialization
)
1227 (defcustom fancy-splash-delay
7
1228 "*Delay in seconds between splash screens."
1229 :group
'fancy-splash-screen
1233 (defcustom fancy-splash-max-time
30
1234 "*Show splash screens for at most this number of seconds.
1235 Values less than twice `fancy-splash-delay' are ignored."
1236 :group
'fancy-splash-screen
1240 (defcustom fancy-splash-image nil
1241 "*The image to show in the splash screens, or nil for defaults."
1242 :group
'fancy-splash-screen
1243 :type
'(choice (const :tag
"Default" nil
)
1244 (file :tag
"File")))
1247 (defvar fancy-splash-keymap
1248 (let ((map (make-sparse-keymap)))
1249 (suppress-keymap map
)
1250 (set-keymap-parent map button-buffer-map
)
1252 (define-key map
" " 'fancy-splash-quit
)
1253 (define-key map
"q" 'fancy-splash-quit
)
1255 "Keymap for splash screen buffer.")
1257 ;; These are temporary storage areas for the splash screen display.
1259 (defvar fancy-current-text nil
)
1260 (defvar fancy-splash-help-echo nil
)
1261 (defvar fancy-splash-stop-time nil
)
1262 (defvar fancy-splash-outer-buffer nil
)
1264 (defun fancy-splash-insert (&rest args
)
1265 "Insert text into the current buffer, with faces.
1266 Arguments from ARGS should be either strings, functions called
1267 with no args that return a string, or pairs `:face FACE',
1268 where FACE is a valid face specification, as it can be used with
1269 `put-text-property'."
1270 (let ((current-face nil
))
1272 (cond ((eq (car args
) :face
)
1273 (setq args
(cdr args
) current-face
(car args
)))
1274 ((eq (car args
) :link
)
1275 (setq args
(cdr args
))
1276 (let ((spec (car args
)))
1277 (insert-button (car spec
)
1278 'face
(list 'link current-face
)
1281 (t (insert (propertize (let ((it (car args
)))
1286 'help-echo fancy-splash-help-echo
))))
1287 (setq args
(cdr args
)))))
1290 (defun fancy-splash-head ()
1291 "Insert the head part of the splash screen into the current buffer."
1292 (let* ((image-file (cond ((stringp fancy-splash-image
)
1294 ((and (display-color-p)
1295 (image-type-available-p 'xpm
))
1296 (if (and (fboundp 'x-display-planes
)
1297 (= (funcall 'x-display-planes
) 8))
1301 (img (create-image image-file
))
1302 (image-width (and img
(car (image-size img
))))
1303 (window-width (window-width (selected-window))))
1305 (when (> window-width image-width
)
1306 ;; Center the image in the window.
1307 (insert (propertize " " 'display
1308 `(space :align-to
(+ center
(-0.5 .
,img
)))))
1310 ;; Change the color of the XPM version of the splash image
1311 ;; so that it is visible with a dark frame background.
1312 (when (and (memq 'xpm img
)
1313 (eq (frame-parameter nil
'background-mode
) 'dark
))
1314 (setq img
(append img
'(:color-symbols
(("#000000" .
"gray30"))))))
1316 ;; Insert the image with a help-echo and a keymap.
1317 (let ((map (make-sparse-keymap))
1318 (help-echo "mouse-2: browse http://www.gnu.org/"))
1319 (define-key map
[mouse-2
]
1322 (browse-url "http://www.gnu.org/")
1324 (define-key map
[down-mouse-2
] 'ignore
)
1325 (define-key map
[up-mouse-2
] 'ignore
)
1326 (insert-image img
(propertize "[image]" 'help-echo help-echo
1329 (fancy-splash-insert
1330 :face
'(variable-pitch :foreground
"red")
1331 (if (eq system-type
'gnu
/linux
)
1332 "GNU Emacs is one component of the GNU/Linux operating system."
1333 "GNU Emacs is one component of the GNU operating system."))
1335 (fancy-splash-insert
1336 :face
'variable-pitch
1337 "You can do basic editing with the menu bar and scroll bar \
1339 :face
'variable-pitch
1340 "To quit a partially entered command, type "
1343 :face
'variable-pitch
1346 (when fancy-splash-outer-buffer
1347 (fancy-splash-insert
1348 :face
'variable-pitch
1352 :face
'variable-pitch
1353 " to exit from this screen.\n")))
1355 (defun fancy-splash-tail ()
1356 "Insert the tail part of the splash screen into the current buffer."
1357 (let ((fg (if (eq (frame-parameter nil
'background-mode
) 'dark
)
1358 "cyan" "darkblue")))
1359 (fancy-splash-insert :face
`(variable-pitch :foreground
,fg
)
1363 :face
'(variable-pitch :height
0.5)
1365 (and auto-save-list-file-prefix
1366 ;; Don't signal an error if the
1367 ;; directory for auto-save-list files
1368 ;; does not yet exist.
1369 (file-directory-p (file-name-directory
1370 auto-save-list-file-prefix
))
1372 (file-name-directory auto-save-list-file-prefix
)
1375 (regexp-quote (file-name-nondirectory
1376 auto-save-list-file-prefix
)))
1378 (fancy-splash-insert :face
'(variable-pitch :foreground
"red")
1379 "\n\nIf an Emacs session crashed recently, "
1381 :face
'(fixed-pitch :foreground
"red")
1382 "Meta-x recover-session RET"
1383 :face
'(variable-pitch :foreground
"red")
1385 " the files you were editing."))))
1387 (defun fancy-splash-screens-1 (buffer)
1388 "Timer function displaying a splash screen."
1389 (when (> (float-time) fancy-splash-stop-time
)
1390 (throw 'stop-splashing nil
))
1391 (unless fancy-current-text
1392 (setq fancy-current-text fancy-splash-text
))
1393 (let ((text (car fancy-current-text
))
1394 (inhibit-read-only t
))
1397 (if pure-space-overflow
1399 Warning Warning!!! Pure space overflow !!!Warning Warning
1400 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1402 (apply #'fancy-splash-insert text
)
1404 (unless (current-message)
1405 (message fancy-splash-help-echo
))
1406 (set-buffer-modified-p nil
)
1407 (goto-char (point-min))
1408 (force-mode-line-update)
1409 (setq fancy-current-text
(cdr fancy-current-text
))))
1411 (defun fancy-splash-quit ()
1412 "Stop displaying the splash screen buffer."
1414 (if fancy-splash-outer-buffer
1416 (kill-buffer (current-buffer))))
1418 (defun fancy-splash-screens (&optional static
)
1419 "Display fancy splash screens when Emacs starts."
1421 (let ((old-hourglass display-hourglass
)
1422 (fancy-splash-outer-buffer (current-buffer))
1424 (frame (fancy-splash-frame))
1426 (save-selected-window
1427 (select-frame frame
)
1428 (switch-to-buffer " About GNU Emacs")
1429 (make-local-variable 'cursor-type
)
1430 (setq splash-buffer
(current-buffer))
1431 (catch 'stop-splashing
1433 (let ((cursor-type nil
))
1434 (setq display-hourglass nil
1436 mode-line-format
(propertize "---- %b %-"
1437 'face
'mode-line-buffer-id
)
1438 fancy-splash-stop-time
(+ (float-time)
1439 fancy-splash-max-time
)
1440 timer
(run-with-timer 0 fancy-splash-delay
1441 #'fancy-splash-screens-1
1443 (use-local-map fancy-splash-keymap
)
1444 (message "%s" (startup-echo-area-message))
1445 (setq buffer-read-only t
)
1447 (cancel-timer timer
)
1448 (setq display-hourglass old-hourglass
)
1449 (kill-buffer splash-buffer
)))))
1450 ;; If static is non-nil, don't show fancy splash screen.
1451 (if (or (window-minibuffer-p)
1452 (window-dedicated-p (selected-window)))
1453 (pop-to-buffer (current-buffer))
1454 (switch-to-buffer " GNU Emacs"))
1455 (setq buffer-read-only nil
)
1457 (if pure-space-overflow
1459 Warning Warning!!! Pure space overflow !!!Warning Warning
1460 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1461 (let (fancy-splash-outer-buffer)
1463 (dolist (text fancy-splash-text
)
1464 (apply #'fancy-splash-insert text
)
1466 (skip-chars-backward "\n")
1467 (delete-region (point) (point-max))
1470 (use-local-map fancy-splash-keymap
)
1471 (set-buffer-modified-p nil
)
1472 (setq buffer-read-only t
)
1473 (if (and view-read-only
(not view-mode
))
1474 (view-mode-enter nil
'kill-buffer
))
1475 (goto-char (point-min)))))
1477 (defun fancy-splash-frame ()
1478 "Return the frame to use for the fancy splash screen.
1479 Returning non-nil does not mean we should necessarily
1480 use the fancy splash screen, but if we do use it,
1481 we put it on this frame."
1483 (dolist (frame (append (frame-list) (list (selected-frame))))
1484 (if (and (frame-visible-p frame
)
1485 (not (window-minibuffer-p (frame-selected-window frame
))))
1486 (setq chosen-frame frame
)))
1489 (defun use-fancy-splash-screens-p ()
1490 "Return t if fancy splash screens should be used."
1491 (when (and (display-graphic-p)
1492 (or (and (display-color-p)
1493 (image-type-available-p 'xpm
))
1494 (image-type-available-p 'pbm
)))
1495 (let ((frame (fancy-splash-frame)))
1497 (let* ((img (create-image (or fancy-splash-image
1498 (if (and (display-color-p)
1499 (image-type-available-p 'xpm
))
1500 "splash.xpm" "splash.pbm"))))
1501 (image-height (and img
(cdr (image-size img nil frame
))))
1502 ;; We test frame-height so that, if the frame is split
1503 ;; by displaying a warning, that doesn't cause the normal
1504 ;; splash screen to be used.
1505 (frame-height (1- (frame-height frame
))))
1506 (> frame-height
(+ image-height
19)))))))
1509 (defun normal-splash-screen (&optional static
)
1510 "Display splash screen when Emacs starts."
1511 (let ((prev-buffer (current-buffer)))
1513 (with-current-buffer (get-buffer-create " About GNU Emacs")
1514 (setq buffer-read-only nil
)
1516 (set (make-local-variable 'tab-width
) 8)
1518 (set (make-local-variable 'mode-line-format
)
1519 (propertize "---- %b %-" 'face
'mode-line-buffer-id
)))
1521 (if pure-space-overflow
1523 Warning Warning!!! Pure space overflow !!!Warning Warning
1524 \(See the node Pure Storage in the Lisp manual for details.)\n"))
1526 ;; The convention for this piece of code is that
1527 ;; each piece of output starts with one or two newlines
1528 ;; and does not end with any newlines.
1529 (insert "Welcome to GNU Emacs")
1531 (if (eq system-type
'gnu
/linux
)
1532 ", one component of the GNU/Linux operating system.\n"
1533 ", a part of the GNU operating system.\n"))
1536 (insert (substitute-command-keys
1538 "\nType \\[recenter] to quit from this screen.\n"))))
1540 (if (display-mouse-p)
1541 ;; The user can use the mouse to activate menus
1542 ;; so give help in terms of menu items.
1545 You can do basic editing with the menu bar and scroll bar using the mouse.
1546 To quit a partially entered command, type Control-g.\n")
1548 (insert "\nImportant Help menu items:\n")
1549 (insert-button "Emacs Tutorial"
1550 'action
(lambda (button) (help-with-tutorial))
1552 (insert " Learn how to use Emacs efficiently\n")
1553 (insert-button "Emacs FAQ"
1554 'action
(lambda (button) (view-emacs-FAQ))
1556 (insert " Frequently asked questions and answers\n")
1557 (insert-button "Read the Emacs Manual"
1558 'action
(lambda (button) (info-emacs-manual))
1560 (insert " View the Emacs manual using Info\n")
1561 (insert-button "\(Non)Warranty"
1562 'action
(lambda (button) (describe-no-warranty))
1564 (insert " GNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1565 (insert-button "Copying Conditions"
1566 'action
(lambda (button) (describe-copying))
1568 (insert " Conditions for redistributing and changing Emacs\n")
1569 (insert-button "Getting New Versions"
1570 'action
(lambda (button) (describe-distribution))
1572 (insert " How to obtain the latest version of Emacs\n")
1573 (insert-button "More Manuals / Ordering Manuals"
1574 'action
(lambda (button) (view-order-manuals))
1576 (insert " How to order printed manuals from the FSF\n")
1578 (insert "\nUseful File menu items:\n")
1579 (insert-button "Exit Emacs"
1580 'action
(lambda (button) (save-buffers-kill-emacs))
1582 (insert " (or type Control-x followed by Control-c)\n")
1583 (insert-button "Recover Crashed Session"
1584 'action
(lambda (button) (recover-session))
1586 (insert " Recover files you were editing before a crash\n")
1588 (insert "\nUseful tasks:\n")
1589 (insert-button "Visit New File"
1590 'action
(lambda (button) (call-interactively 'find-file
))
1592 (insert " Specify a new file's name, to edit the file\n")
1593 (insert-button "Open Home Directory"
1594 'action
(lambda (button) (dired "~"))
1596 (insert " Open your home directory, to operate on its files\n")
1597 (insert-button "Open *scratch* buffer"
1598 'action
(lambda (button) (switch-to-buffer
1599 (get-buffer-create "*scratch*")))
1601 (insert " Open buffer for notes you don't want to save\n")
1602 (insert-button "Customize Startup"
1603 'action
(lambda (button) (customize-group 'initialization
))
1605 (insert " Change initialization settings including this screen\n")
1607 (insert "\n" (emacs-version)
1608 "\n" emacs-copyright
))
1610 ;; No mouse menus, so give help using kbd commands.
1612 ;; If keys have their default meanings,
1613 ;; use precomputed string to save lots of time.
1614 (if (and (eq (key-binding "\C-h") 'help-command
)
1615 (eq (key-binding "\C-xu") 'advertised-undo
)
1616 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs
)
1617 (eq (key-binding "\C-ht") 'help-with-tutorial
)
1618 (eq (key-binding "\C-hi") 'info
)
1619 (eq (key-binding "\C-hr") 'info-emacs-manual
)
1620 (eq (key-binding "\C-h\C-n") 'view-emacs-news
))
1622 Get help C-h (Hold down CTRL and press h)
1624 Emacs tutorial C-h t Undo changes C-x u
1625 Buy manuals C-h C-m Exit Emacs C-x C-c
1626 Browse manuals C-h i")
1628 (insert (substitute-command-keys
1631 Emacs manual \\[info-emacs-manual]
1632 Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
1633 Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs]
1634 Browse manuals \\[info]"
1635 (let ((where (where-is-internal
1636 'help-command nil t
)))
1638 (key-description where
)
1641 ;; Say how to use the menu bar with the keyboard.
1642 (if (and (eq (key-binding "\M-`") 'tmm-menubar
)
1643 (eq (key-binding [f10]) 'tmm-menubar))
1645 Activate menubar F10 or ESC ` or M-`")
1646 (insert (substitute-command-keys "
1647 Activate menubar \\[tmm-menubar]")))
1649 ;; Many users seem to have problems with these.
1651 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1652 If you have no Meta key, you may instead type ESC followed by the character.)")
1654 ;; Insert links to useful tasks
1655 (insert "\n\nUseful tasks (move point to the link and press RET):\n")
1656 (insert-button "Visit New File"
1657 'action (lambda (button) (call-interactively 'find-file))
1659 (insert " Specify a new file's name, to edit the file\n")
1660 (insert-button "Open Home Directory"
1661 'action (lambda (button) (dired "~"))
1663 (insert " Open your home directory, to operate on its files\n")
1664 (insert-button "Open *scratch* buffer"
1665 'action (lambda (button) (switch-to-buffer
1666 (get-buffer-create "*scratch*")))
1668 (insert " Open buffer for notes you don't want to save\n")
1669 (insert-button "Customize Startup"
1670 'action (lambda (button) (customize-group 'initialization))
1672 (insert " Change initialization settings including this screen\n")
1674 (insert "\n" (emacs-version)
1675 "\n" emacs-copyright)
1677 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1678 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1679 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1682 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
1683 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1684 of Emacs and modify it; type C-h C-c to see the conditions.
1685 Type C-h C-d for information on getting the latest version.")
1686 (insert (substitute-command-keys
1688 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
1689 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1690 of Emacs and modify it; type \\[describe-copying] to see the conditions.
1691 Type \\[describe-distribution] for information on getting the latest version."))))
1693 ;; The rest of the startup screen is the same on all
1694 ;; kinds of terminals.
1696 ;; Give information on recovering, if there was a crash.
1697 (and auto-save-list-file-prefix
1698 ;; Don't signal an error if the
1699 ;; directory for auto-save-list files
1700 ;; does not yet exist.
1701 (file-directory-p (file-name-directory
1702 auto-save-list-file-prefix))
1704 (file-name-directory auto-save-list-file-prefix)
1707 (regexp-quote (file-name-nondirectory
1708 auto-save-list-file-prefix)))
1710 (insert "\n\nIf an Emacs session crashed recently, "
1711 "type Meta-x recover-session RET\nto recover"
1712 " the files you were editing.\n"))
1714 (use-local-map button-buffer-map)
1716 ;; Display the input that we set up in the buffer.
1717 (set-buffer-modified-p nil)
1718 (setq buffer-read-only t)
1719 (if (and view-read-only (not view-mode))
1720 (view-mode-enter nil 'kill-buffer))
1721 (goto-char (point-min))
1723 (if (or (window-minibuffer-p)
1724 (window-dedicated-p (selected-window)))
1725 ;; If static is nil, creating a new frame will
1726 ;; generate enough events that the subsequent `sit-for'
1727 ;; will immediately return anyway.
1728 nil ;; (pop-to-buffer (current-buffer))
1729 (save-window-excursion
1730 (switch-to-buffer (current-buffer))
1733 (switch-to-buffer (current-buffer))
1734 ;; In case the window is dedicated or something.
1735 (error (pop-to-buffer (current-buffer))))))
1736 ;; Unwind ... ensure splash buffer is killed
1738 (kill-buffer " About GNU Emacs")
1739 (switch-to-buffer " About GNU Emacs")
1740 (rename-buffer " GNU Emacs" t)))))
1743 (defun startup-echo-area-message ()
1744 (if (eq (key-binding "\C-h\C-p") 'describe-project)
1745 "For information about the GNU system and GNU/Linux, type C-h C-p."
1746 (substitute-command-keys
1747 "For information about the GNU system and GNU/Linux, type \
1748 \\[describe-project].")))
1751 (defun display-startup-echo-area-message ()
1752 (let ((resize-mini-windows t))
1753 (message "%s" (startup-echo-area-message))))
1756 (defun display-splash-screen (&optional static)
1757 "Display splash screen according to display.
1758 Fancy splash screens are used on graphic displays,
1760 With a prefix argument, any user input hides the splash screen."
1762 (if (use-fancy-splash-screens-p)
1763 (fancy-splash-screens static)
1764 (normal-splash-screen static)))
1766 (defalias 'about-emacs 'display-splash-screen)
1768 (defun command-line-1 (command-line-args-left)
1769 (or noninteractive (input-pending-p) init-file-had-error
1770 ;; t if the init file says to inhibit the echo area startup message.
1771 (and inhibit-startup-echo-area-message
1773 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1774 (equal inhibit-startup-echo-area-message
1775 (if (equal init-file-user "")
1778 ;; Wasn't set with custom; see if .emacs has a setq.
1779 (let ((buffer (get-buffer-create " *temp*")))
1784 (insert-file-contents user-init-file)
1787 "([ \t\n]*setq[ \t\n]+"
1788 "inhibit-startup-echo-area-message[ \t\n]+"
1791 (if (equal init-file-user "")
1797 (kill-buffer buffer)))))
1798 ;; display-splash-screen at the end of command-line-1 calls
1799 ;; use-fancy-splash-screens-p. This can cause image.el to be
1800 ;; loaded, putting "Loading image... done" in the echo area.
1801 ;; This hides startup-echo-area-message. So
1802 ;; use-fancy-splash-screens-p is called here simply to get the
1803 ;; loading of image.el (if needed) out of the way before
1804 ;; display-startup-echo-area-message runs.
1806 (use-fancy-splash-screens-p)
1807 (display-startup-echo-area-message)))
1809 ;; Delay 2 seconds after an init file error message
1810 ;; was displayed, so user can read it.
1811 (when init-file-had-error
1814 (when (and pure-space-overflow
1815 (not noninteractive))
1818 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
1821 (when command-line-args-left
1822 ;; We have command args; process them.
1823 (let ((dir command-line-default-directory)
1827 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
1828 ;; if foo is intended to be found in DIR.
1830 ;; ;; The directories listed in --directory/-L options will *appear*
1831 ;; ;; at the front of `load-path' in the order they appear on the
1832 ;; ;; command-line. We cannot do this by *placing* them at the front
1833 ;; ;; in the order they appear, so we need this variable to hold them,
1837 ;; To DTRT we keep track of the splice point and modify `load-path'
1838 ;; straight away upon any --directory/-L option.
1840 just-files ;; t if this follows the magic -- option.
1841 ;; This includes our standard options' long versions
1842 ;; and long versions of what's on command-switch-alist.
1844 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1845 ("--directory") ("--eval") ("--execute") ("--no-splash")
1846 ("--find-file") ("--visit") ("--file") ("--no-desktop"))
1847 (mapcar (lambda (elt)
1848 (list (concat "-" (car elt))))
1849 command-switch-alist)))
1853 ;; Add the long X options to longopts.
1854 (dolist (tem command-line-x-option-alist)
1855 (if (string-match "^--" (car tem))
1856 (push (list (car tem)) longopts)))
1858 ;; Loop, processing options.
1859 (while command-line-args-left
1860 (let* ((argi (car command-line-args-left))
1863 (setq command-line-args-left (cdr command-line-args-left))
1865 ;; Do preliminary decoding of the option.
1867 ;; After --, don't look for options; treat all args as files.
1869 ;; Convert long options to ordinary options
1870 ;; and separate out an attached option argument into argval.
1871 (when (string-match "^\\(--[^=]*\\)=" argi)
1872 (setq argval (substring argi (match-end 0))
1873 argi (match-string 1 argi)))
1874 (if (equal argi "--")
1875 (setq completion nil)
1876 (setq completion (try-completion argi longopts)))
1877 (if (eq completion t)
1878 (setq argi (substring argi 1))
1879 (if (stringp completion)
1880 (let ((elt (assoc completion longopts)))
1882 (error "Option `%s' is ambiguous" argi))
1883 (setq argi (substring (car elt) 1)))
1887 ;; Execute the option.
1888 (cond ((setq tem (assoc argi command-switch-alist))
1890 (let ((command-line-args-left
1891 (cons argval command-line-args-left)))
1892 (funcall (cdr tem) argi))
1893 (funcall (cdr tem) argi)))
1895 ((equal argi "-no-splash")
1896 (setq inhibit-startup-message t))
1898 ((member argi '("-f" ; what the manual claims
1900 "-e")) ; what the source used to say
1901 (setq tem (intern (or argval (pop command-line-args-left))))
1903 (command-execute tem)
1906 ((member argi '("-eval" "-execute"))
1907 (eval (read (or argval (pop command-line-args-left)))))
1909 ((member argi '("-L" "-directory"))
1910 (setq tem (expand-file-name
1911 (command-line-normalize-file-name
1912 (or argval (pop command-line-args-left)))))
1913 (cond (splice (setcdr splice (cons tem (cdr splice)))
1914 (setq splice (cdr splice)))
1915 (t (setq load-path (cons tem load-path)
1916 splice load-path))))
1918 ((member argi '("-l" "-load"))
1919 (let* ((file (command-line-normalize-file-name
1920 (or argval (pop command-line-args-left))))
1921 ;; Take file from default dir if it exists there;
1922 ;; otherwise let `load' search for it.
1923 (file-ex (expand-file-name file)))
1924 (when (file-exists-p file-ex)
1925 (setq file file-ex))
1928 ;; This is used to handle -script. It's not clear
1929 ;; we need to document it.
1930 ((member argi '("-scriptload"))
1931 (let* ((file (command-line-normalize-file-name
1932 (or argval (pop command-line-args-left))))
1933 ;; Take file from default dir.
1934 (file-ex (expand-file-name file)))
1935 (load file-ex nil t t)))
1937 ((equal argi "-insert")
1938 (setq tem (or argval (pop command-line-args-left)))
1940 (error "File name omitted from `-insert' option"))
1941 (insert-file-contents (command-line-normalize-file-name tem)))
1943 ((equal argi "-kill")
1946 ;; This is for when they use --no-desktop with -q, or
1947 ;; don't load Desktop in their .emacs. If desktop.el
1948 ;; _is_ loaded, it will handle this switch, and we
1949 ;; won't see it by the time we get here.
1950 ((equal argi "-no-desktop")
1951 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
1953 ((string-match "^\\+[0-9]+\\'" argi)
1954 (setq line (string-to-number argi)))
1956 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
1957 (setq line (string-to-number (match-string 1 argi))
1958 column (string-to-number (match-string 2 argi))))
1960 ((setq tem (assoc argi command-line-x-option-alist))
1961 ;; Ignore X-windows options and their args if not using X.
1962 (setq command-line-args-left
1963 (nthcdr (nth 1 tem) command-line-args-left)))
1965 ((member argi '("-find-file" "-file" "-visit"))
1966 ;; An explicit option to specify visiting a file.
1967 (setq tem (or argval (pop command-line-args-left)))
1968 (unless (stringp tem)
1969 (error "File name omitted from `%s' option" argi))
1970 (setq file-count (1+ file-count))
1971 (let ((file (expand-file-name
1972 (command-line-normalize-file-name tem) dir)))
1973 (if (= file-count 1)
1974 (setq first-file-buffer (find-file file))
1975 (find-file-other-window file)))
1979 (unless (< column 1)
1980 (move-to-column (1- column)))
1984 (setq just-files t))
1986 ;; We have almost exhausted our options. See if the
1987 ;; user has made any other command-line options available
1988 (let ((hooks command-line-functions) ;; lrs 7/31/89
1991 (not (setq did-hook (funcall (car hooks)))))
1992 (setq hooks (cdr hooks)))
1994 ;; Presume that the argument is a file name.
1996 (if (string-match "\\`-" argi)
1997 (error "Unknown option `%s'" argi))
1998 (setq file-count (1+ file-count))
2001 (command-line-normalize-file-name orig-argi)
2003 (if (= file-count 1)
2004 (setq first-file-buffer (find-file file))
2005 (find-file-other-window file)))
2009 (unless (< column 1)
2010 (move-to-column (1- column)))
2011 (setq column 0))))))
2012 ;; In unusual circumstances, the execution of Lisp code due
2013 ;; to command-line options can cause the last visible frame
2014 ;; to be deleted. In this case, kill emacs to avoid an
2016 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))
2018 ;; If 3 or more files visited, and not all visible,
2019 ;; show user what they all are. But leave the last one current.
2020 (and (> file-count 2)
2021 (not noninteractive)
2022 (not inhibit-startup-buffer-menu)
2023 (or (get-buffer-window first-file-buffer)
2026 (when initial-buffer-choice
2027 (cond ((eq initial-buffer-choice t)
2028 (switch-to-buffer (get-buffer-create "*scratch*")))
2029 ((stringp initial-buffer-choice)
2030 (find-file initial-buffer-choice))))
2032 ;; Maybe display a startup screen.
2033 (unless (or inhibit-startup-message
2034 initial-buffer-choice
2036 emacs-quick-startup)
2037 ;; Display a startup screen, after some preparations.
2039 ;; If there are no switches to process, we might as well
2040 ;; run this hook now, and there may be some need to do it
2041 ;; before doing any output.
2042 (run-hooks 'emacs-startup-hook)
2043 (and term-setup-hook
2044 (run-hooks 'term-setup-hook))
2045 (setq inhibit-startup-hooks t)
2047 ;; It's important to notice the user settings before we
2048 ;; display the startup message; otherwise, the settings
2049 ;; won't take effect until the user gives the first
2050 ;; keystroke, and that's distracting.
2051 (when (fboundp 'frame-notice-user-settings)
2052 (frame-notice-user-settings))
2054 ;; If there are no switches to process, we might as well
2055 ;; run this hook now, and there may be some need to do it
2056 ;; before doing any output.
2057 (when window-setup-hook
2058 (run-hooks 'window-setup-hook)
2059 ;; Don't let the hook be run twice.
2060 (setq window-setup-hook nil))
2062 ;; Do this now to avoid an annoying delay if the user
2063 ;; clicks the menu bar during the sit-for.
2064 (when (display-popup-menus-p)
2065 (precompute-menubar-bindings))
2067 (setq menubar-bindings-done t))
2069 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2070 (and initial-scratch-message
2071 (get-buffer "*scratch*")
2072 (with-current-buffer "*scratch*"
2073 (when (zerop (buffer-size))
2074 (insert initial-scratch-message)
2075 (set-buffer-modified-p nil))))
2077 ;; If user typed input during all that work,
2078 ;; abort the startup screen. Otherwise, display it now.
2079 (unless (input-pending-p)
2080 (display-splash-screen t))))
2083 (defun command-line-normalize-file-name (file)
2084 "Collapse multiple slashes to one, to handle non-Emacs file names."
2086 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2087 ;; That is significant on some systems.
2088 ;; However, /// at the beginning is supposed to mean just /, not //.
2089 (if (string-match "^///+" file)
2090 (setq file (replace-match "/" t t file)))
2091 (while (string-match "//+" file 1)
2092 (setq file (replace-match "/" t t file)))
2095 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
2096 ;;; startup.el ends here