;;; startup.el --- process Emacs shell arguments
-;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
;;; Commentary:
-; These are processed only at the beginning of the argument list.
-; -batch execute noninteractively (messages go to stdout,
-; variable noninteractive set to t)
-; This option must be the first in the arglist.
-; Processed by `main' in emacs.c -- never seen by lisp
-; -t file Specify to use file rather than stdin/stdout
-; as the terminal.
-; This option must be the first in the arglist.
-; Processed by `main' in emacs.c -- never seen by lisp
-; -nw Inhibit the use of any window-system-specific display
-; code; use the current virtual terminal.
-; This option must be the first in the arglist.
-; Processed by `main' in emacs.c -- never seen by lisp
-; -q load no init file; don't load default.el either.
-; But this has no effect on site-start.el.
-; -no-init-file same
-; -u user load USER's init file instead of your own.
-; -user user same
-; -debug-init Don't catch errors in init file; let debugger run.
-; -no-site-file Don't load site-start.el.
-; (This is the ONLY way to prevent loading that file.)
-
-; These are processed in the order encountered.
-; -f function execute function
-; -funcall function same
-; -l file load file
-; -load file same
-; -insert file insert file into buffer
-; file visit file
-; -kill kill (exit) emacs
+;; 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-windows
+;; -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-windows 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.)
+;; -------------------------
+;; -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-windows.
+;; --icon-type ICONTYPE This option is passed on to term/x-win.el
+;;
+;; -iconic Start Emacs iconified under X-windows.
+;; --iconic This option is passed on to term/x-win.el
+;; -------------------------
+;; Various X-windows options for colors/fonts/geometry/title etc.
+;; These options are passed on to term/x-win.el which see. Certain
+;; of these are also found in term/pc-win.el
+;; -------------------------
+;; FILE Visit 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
+;;
+;; -insert FILE Insert the contents of FILE into buffer.
+;; --insert FILE
+;; -------------------------
+;; -kill Kill (exit) Emacs right away.
+;; --kill
+;; -------------------------
;;; Code:
"*Name of this machine, for purposes of naming users.")
(defvar user-mail-address nil
- "*Full mailing address of this user.")
+ "*Full mailing address of this user.
+This is initialized based on `mail-host-address',
+after your init file is read, in case it sets `mail-host-address'.")
+
+(defvar auto-save-list-file-prefix "~/.saves-"
+ "Prefix for generating auto-save-list-file-name.
+Emacs's pid and the system name will be appended to
+this prefix to create a unique file name.")
(defvar init-file-debug nil)
(if command-line-processed
(message "Back to top level.")
(setq command-line-processed t)
+ ;; Give *Messages* the same default-directory as *scratch*,
+ ;; just to keep things predictable.
+ (let ((dir default-directory))
+ (save-excursion
+ (set-buffer (get-buffer "*Messages*"))
+ (setq default-directory dir)))
;; Look in each dir in load-path for a subdirs.el file.
;; If we find one, load it, which will add the appropriate subdirs
;; of that dir into load-path,
(delete (concat "PWD=" pwd)
process-environment)))))))
(setq default-directory (abbreviate-file-name default-directory))
- (setq user-mail-address (concat (user-login-name) "@"
- (or mail-host-address
- (system-name))))
(let ((menubar-bindings-done nil))
(unwind-protect
(command-line)
;; Do this again, in case .emacs defined more abbreviations.
(setq default-directory (abbreviate-file-name default-directory))
+ ;; Specify the file for recording all the auto save files of this session.
+ ;; This is used by recover-session.
+ (setq auto-save-list-file-name
+ (expand-file-name
+ (format "%s%d-%s"
+ auto-save-list-file-prefix
+ (emacs-pid)
+ (system-name))))
(run-hooks 'emacs-startup-hook)
(and term-setup-hook
(run-hooks 'term-setup-hook))
(and window-setup-hook
(run-hooks 'window-setup-hook))
(or menubar-bindings-done
- (precompute-menubar-bindings))))))
+ (if (or (eq window-system 'x) (eq window-system 'win32))
+ (precompute-menubar-bindings)))))))
;; Precompute the keyboard equivalents in the menu bar items.
(defun precompute-menubar-bindings ()
- (if (eq window-system 'x)
- (let ((submap (lookup-key global-map [menu-bar])))
- (while submap
- (and (consp (car submap))
- (symbolp (car (car submap)))
- (stringp (car-safe (cdr (car submap))))
- (keymapp (cdr (cdr (car submap))))
- (x-popup-menu nil (cdr (cdr (car submap)))))
- (setq submap (cdr submap))))))
+ (let ((submap (lookup-key global-map [menu-bar])))
+ (while submap
+ (and (consp (car submap))
+ (symbolp (car (car submap)))
+ (stringp (car-safe (cdr (car submap))))
+ (keymapp (cdr (cdr (car submap))))
+ (progn
+ (x-popup-menu nil (cdr (cdr (car submap))))
+ (if purify-flag
+ (garbage-collect))))
+ (setq submap (cdr submap))))
+ (setq define-key-rebound-commands t))
(defun command-line ()
(setq command-line-default-directory default-directory)
;; does things.
(while (and (not done) args)
(let ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
- ("--debug-init")))
+ ("--debug-init") ("--iconic") ("--icon-type")))
(argi (car args))
(argval nil))
- (if (string-match "=" argi)
+ ;; Handle --OPTION=VALUE format.
+ (if (and (string-match "\\`--" argi)
+ (string-match "=" argi))
(setq argval (substring argi (match-end 0))
argi (substring argi 0 (match-beginning 0))))
(let ((completion (try-completion argi longopts)))
((or (string-equal argi "-u")
(string-equal argi "-user"))
(or argval
- (setq argval (car args)
- args (cdr args)))
+ (setq args (cdr args)
+ argval (car args)))
(setq init-file-user argval
argval nil
args (cdr args)))
((string-equal argi "-debug-init")
(setq init-file-debug t
args (cdr args)))
+ ((string-equal argi "-iconic")
+ (setq initial-frame-alist
+ (cons '(visibility . icon) initial-frame-alist))
+ (setq args (cdr args)))
+ ((or (string-equal argi "-icon-type")
+ (string-equal argi "-i")
+ (string-equal argi "-itype"))
+ (setq default-frame-alist
+ (cons '(icon-type . t) default-frame-alist))
+ (setq args (cdr args)))
(t (setq done t)))
;; Was argval set but not used?
(and argval
(error "Option `%s' doesn't allow an argument" argi))))
;; Re-attach the program name to the front of the arg list.
- (setcdr command-line-args args))
+ (and command-line-args (setcdr command-line-args args)))
;; Under X Windows, this creates the X frame and deletes the terminal frame.
(if (fboundp 'face-initialize)
(if (fboundp 'frame-initialize)
(frame-initialize))
;; If frame was created with a menu bar, set menu-bar-mode on.
- (if (and (eq window-system 'x)
- (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
+ (if (or (not (or (eq window-system 'x) (eq window-system 'win32)))
+ (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
(menu-bar-mode t))
(run-hooks 'before-init-hook)
(if debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file)))
+ ;; Do this here in case the init file sets mail-host-address.
+ (or user-mail-address
+ (setq user-mail-address (concat (user-login-name) "@"
+ (or mail-host-address
+ (system-name)))))
+
(run-hooks 'after-init-hook)
;; If *scratch* exists and init file didn't change its mode, initialize it.
(setq window-setup-hook nil)
;; Do this now to avoid an annoying delay if the user
;; clicks the menu bar during the sit-for.
- (precompute-menubar-bindings)
+ (if (or (eq window-system 'x) (eq window-system 'win32))
+ (precompute-menubar-bindings))
(setq menubar-bindings-done t)
(unwind-protect
(progn
+ ;; 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 (emacs-version)
"
-Copyright (C) 1994 Free Software Foundation, Inc.\n\n")
+Copyright (C) 1995 Free Software Foundation, Inc.")
;; If keys have their default meanings,
;; use precomputed string to save lots of time.
(if (and (eq (key-binding "\C-h") 'help-command)
(eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
(eq (key-binding "\C-ht") 'help-with-tutorial)
(eq (key-binding "\C-hi") 'info))
- (insert
- "Type C-h for help; C-x u to undo changes. (`C-' means use CTRL key.)
+ (insert "\n
+Type C-h for help; C-x u to undo changes. (`C-' means use CTRL key.)
To kill the Emacs job, type C-x C-c.
Type C-h t for a tutorial on using Emacs.
Type C-h i to enter Info, which you can use to read GNU documentation.")
(insert (substitute-command-keys
- (format "Type %s for help; \\[advertised-undo] to undo changes. (`C-' means use CTRL key.)
+ (format "\n
+Type %s for help; \\[advertised-undo] to undo changes. (`C-' means use CTRL key.)
To kill the Emacs job, type \\[save-buffers-kill-emacs].
Type \\[help-with-tutorial] for a tutorial on using Emacs.
Type \\[info] to enter Info, which you can use to read GNU documentation."
(if where
(key-description where)
"M-x help"))))))
+ ;; Say how to use the menu bar
+ ;; if that is not with the mouse.
+ (if (not (assq 'display (frame-parameters)))
+ (if (eq (key-binding "\M-`") 'tmm-menubar)
+ (insert "\n\nType F10, ESC ` or Meta-` to use the menu bar.")
+ (insert (substitute-command-keys
+ "\n\nType \\[tmm-menubar] to use the menu bar."))))
;; Windows and MSDOS (currently) do not count as
;; window systems, but do have mouse support.
(if (or (memq system-type '(msdos windowsnt))
window-system)
- (insert "
+ (insert "\n
C-mouse-3 (third mouse button, with Control) gets a mode-specific menu."))
- (insert "\n")
+ (if (directory-files "~/" nil "\\`\\.saves-" t)
+ (insert "\n\nIf an Emacs session crashed recently,\n"
+ "type M-x recover-session RET to recover"
+ " the files you were editing."))
+
(if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
(eq (key-binding "\C-h\C-d") 'describe-distribution)
(eq (key-binding "\C-h\C-w") 'describe-no-warranty))
(insert
- "
+ "\n
GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
You may give out copies of Emacs; type C-h C-c to see the conditions.
Type C-h C-d for information on getting the latest version.")
(insert (substitute-command-keys
- "
+ "\n
GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
You may give out copies of Emacs; type \\[describe-copying] to see the conditions.
Type \\[describe-distribution] for information on getting the latest version.")))
+
(set-buffer-modified-p nil)
(sit-for 120))
(save-excursion
;; This includes our standard options' long versions
;; and long versions of what's on command-switch-alist.
(longopts
- (append '(("--funcall") ("--load") ("--insert") ("--kill"))
+ (append '(("--funcall") ("--load") ("--insert") ("--kill")
+ ("--directory") ("--eval"))
(mapcar '(lambda (elt)
(list (concat "-" (car elt))))
command-switch-alist)))
- tem argval completion)
+ tem argval completion
+ ;; List of directories specified in -L/--directory,
+ ;; in reverse of the order specified.
+ extra-load-path
+ (initial-load-path load-path))
(setq command-line-args-left (cdr command-line-args-left))
;; Convert long options to ordinary options
(if (arrayp (symbol-function tem))
(command-execute tem)
(funcall tem)))
+ ((string-equal argi "-eval")
+ (if argval
+ (setq tem argval)
+ (setq tem (car command-line-args-left))
+ (setq command-line-args-left (cdr command-line-args-left)))
+ (eval (read tem)))
+ ;; Set the default directory as specified in -L.
+ ((or (string-equal argi "-L")
+ (string-equal argi "-directory"))
+ (if argval
+ (setq tem argval)
+ (setq tem (car command-line-args-left)
+ command-line-args-left (cdr command-line-args-left)))
+ (setq extra-load-path
+ (cons (expand-file-name tem) extra-load-path))
+ (setq load-path (append (nreverse extra-load-path)
+ initial-load-path)))
((or (string-equal argi "-l")
(string-equal argi "-load"))
(if argval
(setq file (expand-file-name file)))
(load file nil t)))
((string-equal argi "-insert")
- (or (stringp (car command-line-args-left))
- (error "File name omitted from `-insert' option"))
(if argval
(setq tem argval)
(setq tem (car command-line-args-left)
command-line-args-left (cdr command-line-args-left)))
+ (or (stringp tem)
+ (error "File name omitted from `-insert' option"))
(insert-file-contents tem))
((string-equal argi "-kill")
(kill-emacs t))
(if (not did-hook)
;; Ok, presume that the argument is a file name
(progn
+ (if (string-match "\\`-" argi)
+ (error "Unknown option `%s'" argi))
(setq file-count (1+ file-count))
(cond ((= file-count 1)
(setq first-file-buffer