;;; startup.el --- process Emacs shell arguments
;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;; 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+;; 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
(defvar command-line-processed nil
"Non-nil once command line has been processed.")
+(defvar window-system initial-window-system
+ "Name of window system the selected frame is displaying through.
+The value is a symbol--for instance, `x' for X windows.
+The value is nil if the selected frame is on a text-only-terminal.")
+
+(make-variable-frame-local 'window-system)
+
(defgroup initialization nil
"Emacs start-up procedure."
:group 'internal)
-(defcustom inhibit-startup-message nil
- "*Non-nil inhibits the initial startup message.
+(defcustom inhibit-splash-screen nil
+ "*Non-nil inhibits the startup screen.
This is for use in your personal init file, once you are familiar
-with the contents of the startup message."
+with the contents of the startup screen."
:type 'boolean
:group 'initialization)
-(defvaralias 'inhibit-splash-screen 'inhibit-startup-message)
+(defvaralias 'inhibit-startup-message 'inhibit-splash-screen)
(defcustom inhibit-startup-echo-area-message nil
"*Non-nil inhibits the initial startup echo area message.
("-bg" 1 x-handle-switch background-color)
("-background" 1 x-handle-switch background-color)
("-ms" 1 x-handle-switch mouse-color)
- ("-itype" 0 x-handle-switch icon-type t)
- ("-i" 0 x-handle-switch icon-type t)
+ ("-nbi" 0 x-handle-switch icon-type nil)
("-iconic" 0 x-handle-iconic)
("-xrm" 1 x-handle-xrm-switch)
("-cr" 1 x-handle-switch cursor-color)
("--foreground-color" 1 x-handle-switch foreground-color)
("--background-color" 1 x-handle-switch background-color)
("--mouse-color" 1 x-handle-switch mouse-color)
- ("--icon-type" 0 x-handle-switch icon-type t)
+ ("--no-bitmap-icon" 0 x-handle-switch icon-type nil)
("--iconic" 0 x-handle-iconic)
("--xrm" 1 x-handle-xrm-switch)
("--cursor-color" 1 x-handle-switch cursor-color)
(defvar keyboard-type nil
"The brand of keyboard you are using.
-This variable is used to define
-the proper function and keypad keys for use under X. It is used in a
-fashion analogous to the environment variable TERM.")
+This variable is used to define the proper function and keypad
+keys for use under X. It is used in a fashion analogous to the
+environment variable TERM.")
(defvar window-setup-hook nil
"Normal hook run to initialize window system display.
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."
+this variable usefully is to set it while building and dumping Emacs."
:type '(choice (const :tag "none" nil) string)
:group 'initialization
:initialize 'custom-initialize-default
;; for instance due to a dense colormap.
(when (or frame-initial-frame
;; If frame-initial-frame has no meaning, do this anyway.
- (not (and window-system
+ (not (and initial-window-system
(not noninteractive)
- (not (eq window-system 'pc)))))
+ (not (eq initial-window-system 'pc)))))
;; Modify the initial frame based on what .emacs puts into
;; ...-frame-alist.
(if (fboundp 'frame-notice-user-settings)
(frame-notice-user-settings))
+ ;; Set the faces for the initial background mode even if
+ ;; frame-notice-user-settings didn't (such as on a tty).
+ ;; frame-set-background-mode is idempotent, so it won't
+ ;; cause any harm if it's already been done.
(if (fboundp 'frame-set-background-mode)
- ;; Set the faces for the initial background mode even if
- ;; frame-notice-user-settings didn't (such as on a tty).
- ;; frame-set-background-mode is idempotent, so it won't
- ;; cause any harm if it's already been done.
- (let ((frame (selected-frame))
- term)
- (when (and (null window-system)
- ;; Don't override default set by files in lisp/term.
- (null default-frame-background-mode)
- (let ((bg (frame-parameter frame 'background-color)))
- (or (null bg)
- (member bg '(unspecified "unspecified-bg"
- "unspecified-fg")))))
-
- (setq term (getenv "TERM"))
- ;; Some files in lisp/term do a better job with the
- ;; background mode, but we leave this here anyway, in
- ;; case they remove those files.
- (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
- term)
- (setq default-frame-background-mode 'light)))
- (frame-set-background-mode (selected-frame)))))
+ (frame-set-background-mode (selected-frame))))
;; Now we know the user's default font, so add it to the menu.
(if (fboundp 'font-menu-add-default)
(defvar tool-bar-originally-present nil
"Non-nil if tool-bars are present before user and site init files are read.")
+(defvar handle-args-function-alist '((nil . tty-handle-args))
+ "Functions for processing window-system dependent command-line arguments.
+Window system startup files should add their own function to this
+alist, which should parse the command line arguments. Those
+pertaining to the window system should be processed and removed
+from the returned command line.")
+
+(defvar window-system-initialization-alist '((nil . ignore))
+ "Alist of window-system initialization functions.
+Window-system startup files should add their own initialization
+function to this list. The function should take no arguments,
+and initialize the window system environment to prepare for
+opening the first frame (e.g. open a connection to an X server).")
+
;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
(defun tty-handle-args (args)
(let (rest)
;; Choose a reasonable location for temporary files.
(custom-reevaluate-setting 'temporary-file-directory)
- (custom-reevaluate-setting 'small-emporary-file-directory)
+ (custom-reevaluate-setting 'small-temporary-file-directory)
(custom-reevaluate-setting 'auto-save-file-name-transforms)
;; See if we should import version-control from the environment variable.
(setq eol-mnemonic-dos "(DOS)"
eol-mnemonic-mac "(Mac)")))
- ;; Read window system's init file if using a window system.
+ ;; Make sure window system's init file was loaded in loadup.el if using a window system.
(condition-case error
- (if (and window-system (not noninteractive))
- (load (concat term-file-prefix
- (symbol-name window-system)
- "-win")
- ;; Every window system should have a startup file;
- ;; barf if we can't find it.
- nil t))
- ;; If we can't read it, print the error message and exit.
+ (unless noninteractive
+ (if (and initial-window-system
+ (not (featurep
+ (intern (concat (symbol-name initial-window-system) "-win")))))
+ (error "Unsupported window system `%s'" initial-window-system))
+ ;; Process window-system specific command line parameters.
+ (setq command-line-args
+ (funcall (or (cdr (assq initial-window-system handle-args-function-alist))
+ (error "Unsupported window system `%s'" initial-window-system))
+ command-line-args))
+ ;; Initialize the window system. (Open connection, etc.)
+ (funcall (or (cdr (assq initial-window-system window-system-initialization-alist))
+ (error "Unsupported window system `%s'" initial-window-system))))
+ ;; If there was an error, print the error message and exit.
(error
(princ
(if (eq (car error) 'error)
(cdr error) ", "))))
'external-debugging-output)
(terpri 'external-debugging-output)
- (setq window-system nil)
+ (setq initial-window-system nil)
(kill-emacs)))
- ;; Windowed displays do this inside their *-win.el.
- (unless (or (display-graphic-p) noninteractive)
- (setq command-line-args (tty-handle-args command-line-args)))
-
(set-locale-environment nil)
+ ;; Convert preloaded file names to absolute.
+ (let ((lisp-dir
+ (file-name-directory
+ (locate-file "simple" load-path
+ load-suffixes))))
+
+ (setq load-history
+ (mapcar (lambda (elt)
+ (if (and (stringp (car elt))
+ (not (file-name-absolute-p (car elt))))
+ (cons (concat lisp-dir
+ (car elt)
+ (if (string-match "[.]el$" (car elt))
+ "" ".elc"))
+ (cdr elt))
+ elt))
+ load-history)))
+
;; Convert the arguments to Emacs internal representation.
(let ((args (cdr command-line-args)))
(while args
;; processed. This is consistent with the way main in emacs.c
;; does things.
(while (and (not done) args)
- (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
- ("--debug-init") ("--iconic") ("--icon-type")
- ("--no-blinking-cursor") ("--bare-bones")))
+ (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
+ ("--user") ("--iconic") ("--icon-type") ("--quick")
+ ("--no-blinking-cursor") ("--basic-display")))
(argi (pop args))
(orig-argi argi)
argval)
(and command-line-args
(setcdr command-line-args args)))
+ (run-hooks 'before-init-hook)
+
;; Under X Window, this creates the X frame and deletes the terminal frame.
(when (fboundp 'frame-initialize)
(frame-initialize))
;; If frame was created with a menu bar, set menu-bar-mode on.
(unless (or noninteractive
emacs-basic-display
- (and (memq window-system '(x w32))
+ (and (memq initial-window-system '(x w32))
(<= (frame-parameter nil 'menu-bar-lines) 0)))
(menu-bar-mode 1))
;; Can't do this init in defcustom because the relevant variables
;; are not set.
(custom-reevaluate-setting 'blink-cursor-mode)
- (custom-reevaluate-setting 'normal-erase-is-backspace)
+ (custom-reevaluate-setting 'tooltip-mode)
+ (custom-reevaluate-setting 'global-font-lock-mode)
+ (custom-reevaluate-setting 'mouse-wheel-down-event)
+ (custom-reevaluate-setting 'mouse-wheel-up-event)
+ (custom-reevaluate-setting 'file-name-shadow-mode)
+ (custom-reevaluate-setting 'send-mail-function)
- ;; If you change the code below, you need to also change the
- ;; corresponding code in the tooltip-mode defcustom. The two need
- ;; to be equivalent under all conditions, or Custom will get confused.
- ;; We can not use `custom-reevaluate-setting' here, because it would
- ;; load the tooltip library on systems for which that does not make sense.
- (unless (or noninteractive
- emacs-basic-display
- (not (display-graphic-p))
- (not (fboundp 'x-show-tip)))
- (tooltip-mode 1))
+ (normal-erase-is-backspace-setup-frame)
;; Register default TTY colors for the case the terminal hasn't a
- ;; terminal init file.
- (unless (memq window-system '(x w32))
- ;; We do this regardles of whether the terminal supports colors
- ;; or not, since they can switch that support on or off in
- ;; mid-session by setting the tty-color-mode frame parameter.
- (tty-register-default-colors))
+ ;; terminal init file. We do this regardles of whether the terminal
+ ;; supports colors or not and regardless the current display type,
+ ;; since users can connect to color-capable terminals and also
+ ;; switch color support on or off in mid-session by setting the
+ ;; tty-color-mode frame parameter.
+ (tty-register-default-colors)
;; Record whether the tool-bar is present before the user and site
;; init files are processed. frame-notice-user-settings uses this
(old-font-list-limit font-list-limit)
(old-face-ignored-fonts face-ignored-fonts))
- (run-hooks 'before-init-hook)
-
;; Run the site-start library if it exists. The point of this file is
;; that it is run before .emacs. There is no point in doing this after
;; .emacs; that is useless.
(setq inhibit-startup-message nil)
;; Warn for invalid user name.
- (and init-file-user
- (not (file-directory-p (expand-file-name (concat "~" init-file-user))))
- (display-warning 'initialization
- (format "User %s has no home directory"
- init-file-user)
- :error))
+ (when init-file-user
+ (if (string-match "[~/:\n]" init-file-user)
+ (display-warning 'initialization
+ (format "Invalid user name %s"
+ init-file-user)
+ :error)
+ (if (file-directory-p (expand-file-name (concat "~" init-file-user)))
+ nil
+ (display-warning 'initialization
+ (format "User %s has no home directory"
+ init-file-user)
+ :error))))
;; Load that user's init file, or the default one, or none.
(let (debug-on-error-from-init-file
(when (eq user-init-file t)
;; If we did not find ~/.emacs, try
- ;; ~/.emacs.d/.emacs.
+ ;; ~/.emacs.d/init.el.
(let ((otherfile
(expand-file-name
- (file-name-nondirectory user-init-file-1)
+ "init"
(file-name-as-directory
- (expand-file-name
- ".emacs.d"
- (file-name-directory user-init-file-1))))))
+ (concat "~" init-file-user "/.emacs.d")))))
(load otherfile t t)
;; If we did not find the user's init file,
(pop-to-buffer "*Messages*"))
(setq init-file-had-error t)))))
+ (if (and deactivate-mark transient-mark-mode)
+ (with-current-buffer (window-buffer)
+ (deactivate-mark)))
+
;; If the user has a file of abbrevs, read it.
(if (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file abbrev-file-name))
(or mail-host-address
(system-name)))))
+ ;; Originally face attributes were specified via
+ ;; `font-lock-face-attributes'. Users then changed the default
+ ;; face attributes by setting that variable. However, we try and
+ ;; be back-compatible and respect its value if set except for
+ ;; faces where M-x customize has been used to save changes for the
+ ;; face.
+ (when (boundp 'font-lock-face-attributes)
+ (let ((face-attributes font-lock-face-attributes))
+ (while face-attributes
+ (let* ((face-attribute (pop face-attributes))
+ (face (car face-attribute)))
+ ;; Rustle up a `defface' SPEC from a
+ ;; `font-lock-face-attributes' entry.
+ (unless (get face 'saved-face)
+ (let ((foreground (nth 1 face-attribute))
+ (background (nth 2 face-attribute))
+ (bold-p (nth 3 face-attribute))
+ (italic-p (nth 4 face-attribute))
+ (underline-p (nth 5 face-attribute))
+ face-spec)
+ (when foreground
+ (setq face-spec (cons ':foreground (cons foreground face-spec))))
+ (when background
+ (setq face-spec (cons ':background (cons background face-spec))))
+ (when bold-p
+ (setq face-spec (append '(:weight bold) face-spec)))
+ (when italic-p
+ (setq face-spec (append '(:slant italic) face-spec)))
+ (when underline-p
+ (setq face-spec (append '(:underline t) face-spec)))
+ (face-spec-set face (list (list t face-spec)) nil)))))))
+
;; If parameter have been changed in the init file which influence
;; face realization, clear the face cache so that new faces will
;; be realized.
;; Load library for our terminal type.
;; User init file can set term-file-prefix to nil to prevent this.
(unless (or noninteractive
- window-system
- (null term-file-prefix))
- (let ((term (getenv "TERM"))
- hyphend)
- (while (and term
- (not (load (concat term-file-prefix term) t t)))
- ;; Strip off last hyphen and what follows, then try again
- (setq term
- (if (setq hyphend (string-match "[-_][^-_]+$" term))
- (substring term 0 hyphend)
- nil)))))
+ initial-window-system)
+ (tty-run-terminal-initialization (selected-frame)))
;; Update the out-of-memory error message based on user's key bindings
;; for save-some-buffers.
:face variable-pitch
"\
Copying Conditions\tConditions for redistributing and changing Emacs
+Getting New Versions\tHow to obtain the latest version of Emacs
More Manuals / Ordering Manuals Buying printed manuals from the FSF\n")
(:face variable-pitch
"You can do basic editing with the menu bar and scroll bar \
the user caused an input event by hitting a key or clicking with the
mouse."
(interactive)
- (push last-command-event unread-command-events)
+ (if (and (memq 'down (event-modifiers last-command-event))
+ (eq (posn-window (event-start last-command-event))
+ (selected-window)))
+ ;; This is a mouse-down event in the spash screen window.
+ ;; Ignore it and consume the corresponding mouse-up event.
+ (read-event)
+ (push last-command-event unread-command-events))
(throw 'exit nil))
Useful File menu items:
Exit Emacs (or type Control-x followed by Control-c)
-Recover Session recover files you were editing before a crash
+Recover Crashed Session Recover files you were editing before a crash
Important Help menu items:
-Emacs Tutorial Learn-by-doing tutorial for using Emacs efficiently.
+Emacs Tutorial Learn how to use Emacs efficiently
Emacs FAQ Frequently asked questions and answers
Read the Emacs Manual View the Emacs manual using Info
\(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY
-Copying Conditions Conditions for redistributing and changing Emacs.
-Getting New Versions How to obtain the latest version of Emacs.
-More Manuals / Ordering Manuals How to order printed manuals from the FSF.
+Copying Conditions Conditions for redistributing and changing Emacs
+Getting New Versions How to obtain the latest version of Emacs
+More Manuals / Ordering Manuals How to order printed manuals from the FSF
")
(insert "\n\n" (emacs-version)
"
-Copyright (C) 2004 Free Software Foundation, Inc."))
+Copyright (C) 2005 Free Software Foundation, Inc."))
;; No mouse menus, so give help using kbd commands.
;; use precomputed string to save lots of time.
(if (and (eq (key-binding "\C-h") 'help-command)
(eq (key-binding "\C-xu") 'advertised-undo)
- (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
+ (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
(eq (key-binding "\C-ht") 'help-with-tutorial)
(eq (key-binding "\C-hi") 'info)
(eq (key-binding "\C-hr") 'info-emacs-manual)
Get help %s
Emacs manual \\[info-emacs-manual]
Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
-Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs]
+Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-terminal]
Browse manuals \\[info]"
(let ((where (where-is-internal
'help-command nil t)))
(insert "\n\n" (emacs-version)
"
-Copyright (C) 2004 Free Software Foundation, Inc.")
+Copyright (C) 2005 Free Software Foundation, Inc.")
(if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
(eq (key-binding "\C-h\C-d") 'describe-distribution)
(defun display-startup-echo-area-message ()
(let ((resize-mini-windows t))
- (message (startup-echo-area-message))))
+ (message "%s" (startup-echo-area-message))))
(defun display-splash-screen ()
(setq file file-ex))
(load file nil t)))
+ ;; This is used to handle -script. It's not clear
+ ;; we need to document it.
+ ((member argi '("-scriptload"))
+ (let* ((file (command-line-normalize-file-name
+ (or argval (pop command-line-args-left))))
+ ;; Take file from default dir.
+ (file-ex (expand-file-name file)))
+ (load file-ex nil t t)))
+
((equal argi "-insert")
(setq tem (or argval (pop command-line-args-left)))
(or (stringp tem)
;; Maybe display a startup screen.
(unless (or inhibit-startup-message
noninteractive
- emacs-quick-startup
- ;; Don't display startup screen if init file
- ;; has started some sort of server.
- (and (fboundp 'process-list)
- (process-list)))
+ emacs-quick-startup)
;; Display a startup screen, after some preparations.
;; If there are no switches to process, we might as well