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