(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.
;; 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)
(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.
- (setq load-history
- (mapcar (lambda (elt)
- (if (and (stringp (car elt))
- (not (file-name-absolute-p (car elt))))
- (cons (locate-file (car elt) load-path
- load-suffixes)
- (cdr elt))
- elt))
- load-history))
+ (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)))
(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)
+
+ (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"))
- (term 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)))
- (setq term TERM)
- ;; The terminal file has been loaded, now call the terminal specific
- ;; initialization function.
- (while term
- (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
- (if (not (fboundp term-init-func))
- ;; Strip off last hyphen and what follows, then try again
- (setq term
- (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
- (substring term 0 hyphend)
- nil))
- (setq term nil)
- (funcall term-init-func))))))
+ 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.
the user caused an input event by hitting a key or clicking with the
mouse."
(interactive)
- (if (and (consp last-command-event)
+ (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.
;; 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)))