;;; startup.el --- process Emacs shell arguments
-;; Copyright (C) 1985, 86, 92, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
+;; Copyright (C) 1985, 86, 92, 94, 95, 96, 97, 98, 99, 2000, 01, 02, 2004
;; Free Software Foundation, Inc.
;; Maintainer: FSF
;;; Commentary:
-;; This file parses the command line and gets Emacs running. Options on
-;; the command line are handled in precedence order. The order is the
-;; one in the list below; first described means first handled. Options
-;; within each category (delimited by a bar) are handled in the order
-;; encountered on the command line.
-
-;; -------------------------
-;; -version Print Emacs version to stderr, then exit
-;; --version successfully right away.
-;; This option is handled by emacs.c
-;; -------------------------
-;; -help Print a short usage description and exit
-;; --help successfully right away.
-;; This option is handled by emacs.c
-;; -------------------------
-;; -nl Do not use shared memory (for systems that
-;; -no-shared-memory support this) for the dumped Emacs data.
-;; This option is handled by emacs.c
-;;
-;; -map For VMS.
-;; --map-data This option is handled by emacs.c
-;; -------------------------
-;; -t FILE Use FILE as the name of the terminal.
-;; --terminal FILE Using this implies "-nw" also.
-;; This option is handled by emacs.c
-;; -------------------------
-;; -d DISPNAME Use DISPNAME as the name of the X
-;; -display DISPNAME display for the initial frame.
-;; --display DISPNAME This option is handled by emacs.c
-;; -------------------------
-;; -nw Do not use a windows system (but use the
-;; --no-window-system terminal instead.)
-;; This option is handled by emacs.c
-;; -------------------------
-;; -batch Execute noninteractively (messages go to stdout,
-;; --batch variable noninteractive set to t)
-;; This option is handled by emacs.c
-;; -------------------------
-;; -q Do not load user's init file and do not load
-;; -no-init-file "default.el". Regardless of this switch,
-;; --no-init-file "site-start" is still loaded.
-;; -------------------------
-;; -no-site-file Do not load "site-start.el". (This is the ONLY
-;; --no-site-file way to prevent loading that file.)
-;; -------------------------
-;; -no-splash Don't display a splash screen on startup.
-;; --no-splash
-;; -------------------------
-;; -u USER Load USER's init file instead of the init
-;; -user USER file belonging to the user starting Emacs.
-;; --user USER
-;; -------------------------
-;; -debug-init Don't catch errors in init files; let the
-;; --debug-init debugger run.
-;; -------------------------
-;; -i ICONTYPE Set type of icon using when Emacs is
-;; -itype ICONTYPE iconified under X.
-;; --icon-type ICONTYPE This option is passed on to term/x-win.el
-;;
-;; -iconic Start Emacs iconified.
-;; --iconic This option is passed on to term/x-win.el
-;; -------------------------
-;; Various X options for colors/fonts/geometry/title etc.
-;; These options are passed on to term/x-win.el which see.
-;; -------------------------
-;; FILE Visit FILE.
-;; -visit FILE
-;; --visit FILE
-;; -file FILE
-;; --file FILE
-;;
-;; -L DIRNAME Add DIRNAME to load-path
-;; -directory DIRNAME
-;; --directory DIRNAME
-;;
-;; -l FILE Load and execute the Emacs lisp code
-;; -load FILE in FILE.
-;; --load FILE
-;;
-;; -f FUNC Execute Emacs lisp function FUNC with
-;; -funcall FUNC no arguments. The "-e" form is outdated
-;; --funcall FUNC and should not be used. (It's a typo
-;; -e FUNC promoted to a feature.)
-;;
-;; -eval FORM Execute Emacs lisp form FORM.
-;; --eval FORM
-;; -execute EXPR
-;; --execute EXPR
-;;
-;; -insert FILE Insert the contents of FILE into buffer.
-;; --insert FILE
-;; -------------------------
-;; -kill Kill (exit) Emacs right away.
-;; --kill
-;; -------------------------
+;; This file parses the command line and gets Emacs running. Options
+;; on the command line are handled in precedence order. For priorities
+;; see the structure standard_args in the emacs.c file.
;;; Code:
(defvar command-switch-alist nil
"Alist of command-line switches.
Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
-HANDLER-FUNCTION receives switch name as sole arg;
-remaining command-line args are in the variable `command-line-args-left'.")
+HANDLER-FUNCTION receives the switch string as its sole argument;
+the remaining command-line args are in the variable `command-line-args-left'.")
(defvar command-line-args-left nil
"List of command-line args not yet processed.")
"File containing site-wide run-time initializations.
This file is loaded at run-time before `~/.emacs'. It contains inits
that need to be in place for the entire site, but which, due to their
-higher incidence of change, don't make sense to load into emacs'
+higher incidence of change, don't make sense to load into Emacs's
dumped image. Thus, the run-time load order is: 1. file described in
this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
override them. Users can prevent loading `default.el' with the `-q'
option or by setting `inhibit-default-init' in their own init files,
but inhibiting `site-start.el' requires `--no-site-file', which
-is less convenient."
+is less convenient.
+
+This variable is defined for customization so as to make
+it visible in the relevant context. However, actually customizing it
+is not allowed, since it would not work anyway. The only way to set
+this variable usefully is to set it during while building and dumping Emacs."
:type '(choice (const :tag "none" nil) string)
- :group 'initialization)
+ :group 'initialization
+ :initialize 'custom-initialize-default
+ :set '(lambda (variable value)
+ (error "Customizing `site-run-file' does not work")))
(defcustom mail-host-address nil
"*Name of this machine, for purposes of naming users."
string)
:group 'auto-save)
+(defvar emacs-quick-startup nil)
+
(defvar init-file-debug nil)
(defvar init-file-had-error nil)
(defvar normal-top-level-add-subdirs-inode-list nil)
+(defvar pure-space-overflow nil
+ "Non-nil if building Emacs overflowed pure space.")
+
(defun normal-top-level-add-subdirs-to-load-path ()
"Add all subdirectories of current directory to `load-path'.
More precisely, this uses only the subdirectories whose names
(let* ((this-dir (car dirs))
(contents (directory-files this-dir))
(default-directory this-dir)
- (canonicalized (and (eq system-type 'windows-nt)
- (untranslated-canonical-name this-dir))))
+ (canonicalized (if (fboundp 'untranslated-canonical-name)
+ (untranslated-canonical-name this-dir))))
;; The Windows version doesn't report meaningful inode
;; numbers, so use the canonicalized absolute file name of the
;; directory instead.
;; Give *Messages* the same default-directory as *scratch*,
;; just to keep things predictable.
(let ((dir default-directory))
- (save-excursion
- (set-buffer (get-buffer "*Messages*"))
+ (with-current-buffer "*Messages*"
(setq default-directory dir)))
;; `user-full-name' is now known; reset its standard-value here.
(put 'user-full-name 'standard-value
;; of that dir into load-path,
;; Look for a leim-list.el file too. Loading it will register
;; available input methods.
- (let ((tail load-path)
- new)
- (while tail
- (push (car tail) new)
- (condition-case nil
- (let ((default-directory (car tail)))
- (load (expand-file-name "subdirs.el" (car tail)) t t t)))
- (condition-case nil
- (let ((default-directory (car tail)))
- (load (expand-file-name "leim-list.el" (car tail)) t t t)))
- (setq tail (cdr tail))))
- (if (not (eq system-type 'vax-vms))
- (progn
- ;; If the PWD environment variable isn't accurate, delete it.
- (let ((pwd (getenv "PWD")))
- (and (stringp pwd)
- ;; Use FOO/., so that if FOO is a symlink, file-attributes
- ;; describes the directory linked to, not FOO itself.
- (or (equal (file-attributes
- (concat (file-name-as-directory pwd) "."))
- (file-attributes
- (concat (file-name-as-directory default-directory)
- ".")))
- (setq process-environment
- (delete (concat "PWD=" pwd)
- process-environment)))))))
+ (dolist (dir load-path)
+ (let ((default-directory dir))
+ (load (expand-file-name "subdirs.el") t t t))
+ (let ((default-directory dir))
+ (load (expand-file-name "leim-list.el") t t t)))
+ (unless (eq system-type 'vax-vms)
+ ;; If the PWD environment variable isn't accurate, delete it.
+ (let ((pwd (getenv "PWD")))
+ (and (stringp pwd)
+ ;; Use FOO/., so that if FOO is a symlink, file-attributes
+ ;; describes the directory linked to, not FOO itself.
+ (or (equal (file-attributes
+ (concat (file-name-as-directory pwd) "."))
+ (file-attributes
+ (concat (file-name-as-directory default-directory)
+ ".")))
+ (setq process-environment
+ (delete (concat "PWD=" pwd)
+ process-environment))))))
(setq default-directory (abbreviate-file-name default-directory))
(let ((menubar-bindings-done nil))
(unwind-protect
(if (eq system-type 'ms-dos)
(getenv "TMPDIR")))
(setq auto-save-file-name-transforms
- (list (list "\\`/[^/]*:\\(.+/\\)*\\(.*\\)"
+ (list (list (car (car auto-save-file-name-transforms))
;; Don't put "\\2" inside expand-file-name, since
;; it will be transformed to "/2" on DOS/Windows.
(concat temporary-file-directory "\\2") t)))
(setq argval nil
argi orig-argi)))))
(cond
+ ((equal argi "-Q")
+ (setq init-file-user nil
+ site-run-file nil
+ emacs-quick-startup t)
+ (push '(vertical-scroll-bars . nil) initial-frame-alist))
((member argi '("-q" "-no-init-file"))
(setq init-file-user nil))
((member argi '("-u" "-user"))
;; If frame was created with a menu bar, set menu-bar-mode on.
(unless (or noninteractive
+ emacs-quick-startup
(and (memq window-system '(x w32))
(<= (frame-parameter nil 'menu-bar-lines) 0)))
(menu-bar-mode 1))
;; If frame was created with a tool bar, switch tool-bar-mode on.
(unless (or noninteractive
+ emacs-quick-startup
(not (display-graphic-p))
(<= (frame-parameter nil 'tool-bar-lines) 0))
(tool-bar-mode 1))
- ;; Can't do this init in defcustom because window-system isn't set.
+ ;; Can't do this init in defcustom because the relevant variables
+ ;; are not set. If you make any changes to the `or' form below,
+ ;; you should also change the corresponding expression in the
+ ;; defcustom in frame.el, or Custom will be badly confused.
(unless (or noninteractive
+ emacs-quick-startup
(eq system-type 'ms-dos)
(not (memq window-system '(x w32))))
- (setq-default blink-cursor t)
(blink-cursor-mode 1))
(unless noninteractive
(normal-erase-is-backspace-mode 1)))
(unless (or noninteractive
+ emacs-quick-startup
(not (display-graphic-p))
(not (fboundp 'x-show-tip)))
(setq-default tooltip-mode t)
((eq system-type 'ms-dos)
(concat "~" init-file-user "/_emacs"))
((eq system-type 'windows-nt)
+ ;; Prefer .emacs on Windows.
(if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
"~/.emacs"
- "~/_emacs"))
+ ;; Also support _emacs for compatibility.
+ (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
+ "~/_emacs"
+ ;; But default to .emacs if _emacs does not exist.
+ "~/.emacs")))
((eq system-type 'vax-vms)
"sys$login:.emacs")
(t
(sit-for 1))
(setq user-init-file source))))
- (when (stringp custom-file)
- (unless (assoc custom-file load-history)
- ;; If the .emacs file has set `custom-file' but hasn't
- ;; loaded the file yet, let's load it.
- (load custom-file t t)))
-
(unless inhibit-default-init
(let ((inhibit-startup-message nil))
;; Users are supposed to be told their rights.
(run-hooks 'after-init-hook)
+ ;; Decode all default-directory.
+ (if (and default-enable-multibyte-characters locale-coding-system)
+ (save-excursion
+ (dolist (elt (buffer-list))
+ (set-buffer elt)
+ (if default-directory
+ (setq default-directory
+ (decode-coding-string default-directory
+ locale-coding-system t))))
+ (setq command-line-default-directory
+ (decode-coding-string command-line-default-directory
+ locale-coding-system t))))
+
;; If *scratch* exists and init file didn't change its mode, initialize it.
(if (get-buffer "*scratch*")
(with-current-buffer "*scratch*"
(when img
(when (> window-width image-width)
;; Center the image in the window.
- (let ((pos (/ (- window-width image-width) 2)))
- (insert (propertize " " 'display `(space :align-to ,pos))))
+ (insert (propertize " " 'display
+ `(space :align-to (+ center (-0.5 . ,img)))))
;; Change the color of the XPM version of the splash image
;; so that it is visible with a dark frame background.
(emacs-version)
"\n"
:face '(variable-pitch :height 0.5)
- "Copyright (C) 2002 Free Software Foundation, Inc.")
+ "Copyright (C) 2004 Free Software Foundation, Inc.")
(and auto-save-list-file-prefix
;; Don't signal an error if the
;; directory for auto-save-list files
(let ((text (car fancy-current-text)))
(set-buffer buffer)
(erase-buffer)
+ (if pure-space-overflow
+ (insert "Warning Warning Pure space overflow Warning Warning\n"))
(fancy-splash-head)
(apply #'fancy-splash-insert text)
(fancy-splash-tail)
(defun use-fancy-splash-screens-p ()
"Return t if fancy splash screens should be used."
- (when (or (and (display-color-p)
+ (when (and (display-graphic-p)
+ (or (and (display-color-p)
(image-type-available-p 'xpm))
- (image-type-available-p 'pbm))
+ (image-type-available-p 'pbm)))
(let ((frame (fancy-splash-frame)))
(when frame
(let* ((img (create-image (or fancy-splash-image
(mode-line-format (propertize "---- %b %-"
'face '(:weight bold))))
+ (if pure-space-overflow
+ (insert "Warning Warning Pure space overflow Warning Warning\n"))
+
;; The convention for this piece of code is that
;; each piece of output starts with one or two newlines
;; and does not end with any newlines.
")
(insert "\n\n" (emacs-version)
"
-Copyright (C) 2002 Free Software Foundation, Inc."))
+Copyright (C) 2004 Free Software Foundation, Inc."))
;; No mouse menus, so give help using kbd commands.
(insert "\n\n" (emacs-version)
"
-Copyright (C) 2002 Free Software Foundation, Inc.")
+Copyright (C) 2004 Free Software Foundation, Inc.")
(if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
(eq (key-binding "\C-h\C-d") 'describe-distribution)
Fancy splash screens are used on graphic displays,
normal otherwise."
(interactive)
- (if (and (display-graphic-p)
- (use-fancy-splash-screens-p))
+ (if (use-fancy-splash-screens-p)
(fancy-splash-screens)
(normal-splash-screen)))
nil t))
(error nil))
(kill-buffer buffer)))))
+ ;; Stop any "Loading image..." message hiding echo-area-message.
+ (use-fancy-splash-screens-p)
(display-startup-echo-area-message))
;; Delay 2 seconds after an init file error message
(file-count 0)
first-file-buffer
tem
- ;; The directories listed in --directory/-L options will *appear*
- ;; at the front of `load-path' in the order they appear on the
- ;; command-line. We cannot do this by *placing* them at the front
- ;; in the order they appear, so we need this variable to hold them,
- ;; temporarily.
- extra-load-path
+ ;; This approach loses for "-batch -L DIR --eval "(require foo)",
+ ;; if foo is intended to be found in DIR.
+ ;;
+ ;; ;; The directories listed in --directory/-L options will *appear*
+ ;; ;; at the front of `load-path' in the order they appear on the
+ ;; ;; command-line. We cannot do this by *placing* them at the front
+ ;; ;; in the order they appear, so we need this variable to hold them,
+ ;; ;; temporarily.
+ ;; extra-load-path
+ ;;
+ ;; To DTRT we keep track of the splice point and modify `load-path'
+ ;; straight away upon any --directory/-L option.
+ splice
just-files ;; t if this follows the magic -- option.
;; This includes our standard options' long versions
;; and long versions of what's on command-switch-alist.
((member argi '("-eval" "-execute"))
(eval (read (or argval (pop command-line-args-left)))))
- ;; Set the default directory as specified in -L.
((member argi '("-L" "-directory"))
- (setq tem (or argval (pop command-line-args-left)))
- ;; We will reverse `extra-load-path' and prepend it to
- ;; `load-path' after all the arguments have been processed.
- (push
- (expand-file-name (command-line-normalize-file-name tem))
- extra-load-path))
+ (setq tem (expand-file-name
+ (command-line-normalize-file-name
+ (or argval (pop command-line-args-left)))))
+ (cond (splice (setcdr splice (cons tem (cdr splice)))
+ (setq splice (cdr splice)))
+ (t (setq load-path (cons tem load-path)
+ splice load-path))))
((member argi '("-l" "-load"))
(let* ((file (command-line-normalize-file-name
(move-to-column (1- column)))
(setq column 0))))))))
- ;; See --directory/-L option above.
- (when extra-load-path
- (setq load-path (append (nreverse extra-load-path) load-path)))
-
;; If 3 or more files visited, and not all visible,
;; show user what they all are. But leave the last one current.
(and (> file-count 2)
(list-buffers)))))
;; Maybe display a startup screen.
- (when (and (not inhibit-startup-message) (not noninteractive)
+ (unless (or inhibit-startup-message
+ noninteractive
+ emacs-quick-startup
;; Don't display startup screen if init file
;; has started some sort of server.
- (not (and (fboundp 'process-list)
- (process-list))))
+ (and (fboundp 'process-list)
+ (process-list)))
;; Display a startup screen, after some preparations.
;; If there are no switches to process, we might as well
(setq file (replace-match "/" t t file)))
file))
+;;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
;;; startup.el ends here