- (or (memq window-system '(x w32))
- (not (tty-display-color-p))
- (let* ((colors (cond ((eq window-system 'pc)
- msdos-color-values)
- ((eq system-type 'windows-nt)
- w32-tty-standard-colors)
- (t tty-standard-colors)))
- (color (car colors)))
- (while colors
- (tty-color-define (car color) (cadr color) (cddr color))
- (setq colors (cdr colors) color (car colors)))
- ;; Modifying color mappings means realized faces don't
- ;; use the right colors, so clear them.
- (clear-face-cache)))
-
- (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.
- (if site-run-file
- (load site-run-file t t))
-
- ;; Sites should not disable this. Only individuals should disable
- ;; the startup message.
- (setq inhibit-startup-message nil)
-
- ;; Load that user's init file, or the default one, or none.
- (let (debug-on-error-from-init-file
- debug-on-error-should-be-set
- (debug-on-error-initial
- (if (eq init-file-debug t) 'startup init-file-debug))
- (orig-enable-multibyte default-enable-multibyte-characters))
- (let ((debug-on-error debug-on-error-initial)
- ;; This function actually reads the init files.
- (inner
- (function
- (lambda ()
- (if init-file-user
- (let ((user-init-file-1
- (cond
- ((eq system-type 'ms-dos)
- (concat "~" init-file-user "/_emacs"))
- ((eq system-type 'windows-nt)
- (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
- "~/.emacs"
- "~/_emacs"))
- ((eq system-type 'vax-vms)
- "sys$login:.emacs")
- (t
- (concat "~" init-file-user "/.emacs")))))
- ;; This tells `load' to store the file name found
- ;; into user-init-file.
- (setq user-init-file t)
- (load user-init-file-1 t t)
-
- ;; If we did not find the user's init file,
- ;; set user-init-file conclusively to nil;
- ;; don't let it be set from default.el.
- (if (eq user-init-file t)
- (setq user-init-file nil))
-
- ;; If we loaded a compiled file, set
- ;; `user-init-file' to the source version if that
- ;; exists.
- (when (and user-init-file
- (equal (file-name-extension user-init-file)
- "elc"))
- (let* ((source (file-name-sans-extension user-init-file))
- (alt (concat source ".el")))
- (setq source (cond ((file-exists-p alt) alt)
- ((file-exists-p source) source)
- (t nil)))
- (when source
- (when (file-newer-than-file-p source user-init-file)
- (message "Warning: %s is newer than %s"
- source user-init-file)
- (sit-for 1))
- (setq user-init-file source))))
-
- (or inhibit-default-init
- (let ((inhibit-startup-message nil))
- ;; Users are supposed to be told their rights.
- ;; (Plus how to get help and how to undo.)
- ;; Don't you dare turn this off for anyone
- ;; except yourself.
- (load "default" t t)))))))))
- (if init-file-debug
- ;; Do this without a condition-case if the user wants to debug.
- (funcall inner)
- (condition-case error
- (progn
- (funcall inner)
- (setq init-file-had-error nil))
- (error
- (let ((message-log-max nil))
- (save-excursion
- (set-buffer (get-buffer-create "*Messages*"))
- (insert "\n\n"
- (format "An error has occurred while loading `%s':\n\n"
- user-init-file)
- (format "%s%s%s"
- (get (car error) 'error-message)
- (if (cdr error) ": " "")
- (mapconcat 'prin1-to-string (cdr error) ", "))
- "\n\n"
- "To ensure normal operation, you should investigate the cause\n"
- "of the error in your initialization file and remove it. Start\n"
- "Emacs with the `--debug-init' option to view a complete error\n"
- "backtrace\n"))
- (message "Error in init file: %s%s%s"
- (get (car error) 'error-message)
- (if (cdr error) ": " "")
- (mapconcat 'prin1-to-string (cdr error) ", "))
- (pop-to-buffer "*Messages*")
- (setq init-file-had-error t)))))
- ;; If we can tell that the init file altered debug-on-error,
- ;; arrange to preserve the value that it set up.
- (or (eq debug-on-error debug-on-error-initial)
- (setq debug-on-error-should-be-set t
- debug-on-error-from-init-file debug-on-error)))
- (if debug-on-error-should-be-set
- (setq debug-on-error debug-on-error-from-init-file))
- (unless (or default-enable-multibyte-characters
- (eq orig-enable-multibyte default-enable-multibyte-characters))
- ;; Init file changed to unibyte. Reset existing multibyte
- ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
- ;; Arguably this should only be done if they're free of
- ;; multibyte characters.
- (mapcar (lambda (buffer)
- (with-current-buffer buffer
- (if enable-multibyte-characters
- (set-buffer-multibyte nil))))
- (buffer-list))
- ;; Also re-set the language environment in case it was
- ;; originally done before unibyte was set and is sensitive to
- ;; unibyte (display table, terminal coding system &c).
- (set-language-environment current-language-environment)))
-
- ;; 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)))))
+ (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))
+
+ ;; Record whether the tool-bar is present before the user and site
+ ;; init files are processed. frame-notice-user-settings uses this
+ ;; to determine if the tool-bar has been disabled by the init files,
+ ;; and the frame needs to be resized.
+ (when (fboundp 'frame-notice-user-settings)
+ (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
+ (assq 'tool-bar-lines default-frame-alist))))
+ (setq tool-bar-originally-present
+ (and tool-bar-lines
+ (cdr tool-bar-lines)
+ (not (eq 0 (cdr tool-bar-lines)))))))
+
+ (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
+ (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.
+ (if site-run-file
+ (load site-run-file t t))
+
+ ;; Sites should not disable this. Only individuals should disable
+ ;; the startup message.
+ (setq inhibit-startup-message nil)
+
+ ;; Load that user's init file, or the default one, or none.
+ (let (debug-on-error-from-init-file
+ debug-on-error-should-be-set
+ (debug-on-error-initial
+ (if (eq init-file-debug t) 'startup init-file-debug))
+ (orig-enable-multibyte default-enable-multibyte-characters))
+ (let ((debug-on-error debug-on-error-initial)
+ ;; This function actually reads the init files.
+ (inner
+ (function
+ (lambda ()
+ (if init-file-user
+ (let ((user-init-file-1
+ (cond
+ ((eq system-type 'ms-dos)
+ (concat "~" init-file-user "/_emacs"))
+ ((eq system-type 'windows-nt)
+ (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
+ "~/.emacs"
+ "~/_emacs"))
+ ((eq system-type 'vax-vms)
+ "sys$login:.emacs")
+ (t
+ (concat "~" init-file-user "/.emacs")))))
+ ;; This tells `load' to store the file name found
+ ;; into user-init-file.
+ (setq user-init-file t)
+ (load user-init-file-1 t t)
+
+ (when (eq user-init-file t)
+ ;; If we did not find ~/.emacs, try
+ ;; ~/.emacs.d/.emacs.
+ (let ((otherfile
+ (expand-file-name
+ (file-name-nondirectory user-init-file-1)
+ (file-name-as-directory
+ (expand-file-name
+ ".emacs.d"
+ (file-name-directory user-init-file-1))))))
+ (load otherfile t t)
+
+ ;; If we did not find the user's init file,
+ ;; set user-init-file conclusively.
+ ;; Don't let it be set from default.el.
+ (when (eq user-init-file t)
+ (setq user-init-file user-init-file-1))))
+
+ ;; If we loaded a compiled file, set
+ ;; `user-init-file' to the source version if that
+ ;; exists.
+ (when (and user-init-file
+ (equal (file-name-extension user-init-file)
+ "elc"))
+ (let* ((source (file-name-sans-extension user-init-file))
+ (alt (concat source ".el")))
+ (setq source (cond ((file-exists-p alt) alt)
+ ((file-exists-p source) source)
+ (t nil)))
+ (when source
+ (when (file-newer-than-file-p source user-init-file)
+ (message "Warning: %s is newer than %s"
+ source user-init-file)
+ (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.
+ ;; (Plus how to get help and how to undo.)
+ ;; Don't you dare turn this off for anyone
+ ;; except yourself.
+ (load "default" t t)))))))))
+ (if init-file-debug
+ ;; Do this without a condition-case if the user wants to debug.
+ (funcall inner)
+ (condition-case error
+ (progn
+ (funcall inner)
+ (setq init-file-had-error nil))
+ (error
+ (let ((message-log-max nil))
+ (save-excursion
+ (set-buffer (get-buffer-create "*Messages*"))
+ (insert "\n\n"
+ (format "An error has occurred while loading `%s':\n\n"
+ user-init-file)
+ (format "%s%s%s"
+ (get (car error) 'error-message)
+ (if (cdr error) ": " "")
+ (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
+ "\n\n"
+ "To ensure normal operation, you should investigate and remove the\n"
+ "cause of the error in your initialization file. Start Emacs with\n"
+ "the `--debug-init' option to view a complete error backtrace.\n\n"))
+ (message "Error in init file: %s%s%s"
+ (get (car error) 'error-message)
+ (if (cdr error) ": " "")
+ (mapconcat 'prin1-to-string (cdr error) ", "))
+ (let ((pop-up-windows nil))
+ (pop-to-buffer "*Messages*"))
+ (setq init-file-had-error t)))))
+
+ ;; If the user has a file of abbrevs, read it.
+ (if (file-exists-p abbrev-file-name)
+ (quietly-read-abbrev-file abbrev-file-name))
+
+ ;; If the abbrevs came entirely from the init file or the
+ ;; abbrevs file, they do not need saving.
+ (setq abbrevs-changed nil)
+
+ ;; If we can tell that the init file altered debug-on-error,
+ ;; arrange to preserve the value that it set up.
+ (or (eq debug-on-error debug-on-error-initial)
+ (setq debug-on-error-should-be-set t
+ debug-on-error-from-init-file debug-on-error)))
+ (if debug-on-error-should-be-set
+ (setq debug-on-error debug-on-error-from-init-file))
+ (unless (or default-enable-multibyte-characters
+ (eq orig-enable-multibyte default-enable-multibyte-characters))
+ ;; Init file changed to unibyte. Reset existing multibyte
+ ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
+ ;; Arguably this should only be done if they're free of
+ ;; multibyte characters.
+ (mapcar (lambda (buffer)
+ (with-current-buffer buffer
+ (if enable-multibyte-characters
+ (set-buffer-multibyte nil))))
+ (buffer-list))
+ ;; Also re-set the language environment in case it was
+ ;; originally done before unibyte was set and is sensitive to
+ ;; unibyte (display table, terminal coding system &c).
+ (set-language-environment current-language-environment)))
+
+ ;; Do this here in case the init file sets mail-host-address.
+ (if (equal user-mail-address "")
+ (setq user-mail-address (concat (user-login-name) "@"
+ (or mail-host-address
+ (system-name)))))
+
+ ;; If parameter have been changed in the init file which influence
+ ;; face realization, clear the face cache so that new faces will
+ ;; be realized.
+ (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
+ (eq font-list-limit old-font-list-limit)
+ (eq face-ignored-fonts old-face-ignored-fonts))
+ (clear-face-cache)))