;;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
-;; Copyright (C) 1985-1986, 1992, 1994-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1992, 1994-2014 Free Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: internal
;; Package: emacs
"Buffer to show after starting Emacs.
If the value is nil and `inhibit-startup-screen' is nil, show the
startup screen. If the value is a string, switch to a buffer
-visiting the file or directory specified by that string. If the
-value is a function, switch to the buffer returned by that
-function. If t, open the `*scratch*' buffer.
+visiting the file or directory that the string specifies. If the
+value is a function, call it with no arguments and switch to the buffer
+that it returns. If t, open the `*scratch*' buffer.
-A string value also causes emacsclient to open the specified file
-or directory when no target file is specified."
+If you use `emacsclient' with no target file, then it obeys any
+string or function value that this variable has."
:type '(choice
(const :tag "Startup screen" nil)
(directory :tag "Directory" :value "~/")
(file :tag "File" :value "~/.emacs")
- (const :tag "Notes buffer" remember-notes)
+ ;; Note sure about hard-coding this as an option...
+ (const :tag "Remember Mode notes buffer" remember-notes)
(function :tag "Function")
(const :tag "Lisp scratch buffer" t))
- :version "24.4"
+ :version "23.1"
:group 'initialization)
(defcustom inhibit-startup-screen nil
"Normal hook run after loading init files and handling the command line.")
(defvar term-setup-hook nil
- "Normal hook run after loading terminal-specific Lisp code.
-It also follows `emacs-startup-hook'. This hook exists for users to set,
-so as to override the definitions made by the terminal-specific file.
-Emacs never sets this variable itself.")
+ "Normal hook run immediately after `emacs-startup-hook'.
+In new code, there is no reason to use this instead of `emacs-startup-hook'.
+If you want to execute terminal-specific Lisp code, for example
+to override the definitions made by the terminal-specific file,
+see `tty-setup-hook'.")
+
+(make-obsolete-variable 'term-setup-hook
+ "use either `emacs-startup-hook' or \
+`tty-setup-hook' instead." "24.4")
(defvar inhibit-startup-hooks nil
"Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
environment variable TERM.")
(defvar window-setup-hook nil
- "Normal hook run to initialize window system display.
-Emacs runs this hook after processing the command line arguments and loading
-the user's init file.")
+ "Normal hook run after loading init files and handling the command line.
+This is very similar to `emacs-startup-hook'. The only difference
+is that this hook runs after frame parameters have been set up in
+response to any settings from your init file. Unless this matters
+to you, use `emacs-startup-hook' instead. (The name of this hook
+is due to historical reasons, and does not reflect its purpose very well.)")
(defcustom initial-major-mode 'lisp-interaction-mode
"Major mode command symbol to use for the initial `*scratch*' buffer."
;; for many other file-name variables and directory lists, so it
;; is important to decode it ASAP.
(when 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)))))
-
- ;; Decode all the important variables and directory lists, now
- ;; that we know the locale's encoding. This is because the
- ;; values of these variables are until here unibyte undecoded
- ;; strings created by build_unibyte_string. data-directory in
- ;; particular is used to construct many other standard directory
- ;; names, so it must be decoded ASAP.
- ;; Note that charset-map-path cannot be decoded here, since we
- ;; could then be trapped in infinite recursion below, when we
- ;; load subdirs.el, because encoding a directory name might need
- ;; to load a charset map, which will want to encode
- ;; charset-map-path, which will want to load the same charset
- ;; map... So decoding of charset-map-path is delayed until
- ;; further down below.
- (dolist (pathsym '(load-path exec-path))
- (let ((path (symbol-value pathsym)))
- (if (listp path)
- (set pathsym (mapcar (lambda (dir)
- (decode-coding-string
- dir
- locale-coding-system t))
- path)))))
- (dolist (filesym '(data-directory doc-directory exec-directory
- installation-directory
- invocation-directory invocation-name
- source-directory
- shared-game-score-directory))
- (let ((file (symbol-value filesym)))
- (if (stringp file)
- (set filesym (decode-coding-string file locale-coding-system t))))))
+ (let ((coding (if (eq system-type 'windows-nt)
+ ;; MS-Windows build converts all file names to
+ ;; UTF-8 during startup.
+ 'utf-8
+ locale-coding-system)))
+ (save-excursion
+ (dolist (elt (buffer-list))
+ (set-buffer elt)
+ (if default-directory
+ (setq default-directory
+ (decode-coding-string default-directory coding t)))))
+
+ ;; Decode all the important variables and directory lists, now
+ ;; that we know the locale's encoding. This is because the
+ ;; values of these variables are until here unibyte undecoded
+ ;; strings created by build_unibyte_string. data-directory in
+ ;; particular is used to construct many other standard
+ ;; directory names, so it must be decoded ASAP. Note that
+ ;; charset-map-path cannot be decoded here, since we could
+ ;; then be trapped in infinite recursion below, when we load
+ ;; subdirs.el, because encoding a directory name might need to
+ ;; load a charset map, which will want to encode
+ ;; charset-map-path, which will want to load the same charset
+ ;; map... So decoding of charset-map-path is delayed until
+ ;; further down below.
+ (dolist (pathsym '(load-path exec-path))
+ (let ((path (symbol-value pathsym)))
+ (if (listp path)
+ (set pathsym (mapcar (lambda (dir)
+ (decode-coding-string dir coding t))
+ path)))))
+ (dolist (filesym '(data-directory doc-directory exec-directory
+ installation-directory
+ invocation-directory invocation-name
+ source-directory
+ shared-game-score-directory))
+ (let ((file (symbol-value filesym)))
+ (if (stringp file)
+ (set filesym (decode-coding-string file coding t)))))))
(let ((dir default-directory))
(with-current-buffer "*Messages*"
;; need for encoding them are already loaded, we are ready to
;; decode charset-map-path.
(if (listp charset-map-path)
- (setq charset-map-path
- (mapcar (lambda (dir)
- (decode-coding-string
- dir
- locale-coding-system t))
- charset-map-path)))
+ (let ((coding (if (eq system-type 'windows-nt)
+ 'utf-8
+ locale-coding-system)))
+ (setq charset-map-path
+ (mapcar (lambda (dir)
+ (decode-coding-string dir coding t))
+ charset-map-path))))
(setq default-directory (abbreviate-file-name default-directory))
(let ((old-face-font-rescale-alist face-font-rescale-alist))
(unwind-protect
(defun tty-handle-args (args)
"Handle the X-like command-line arguments \"-fg\", \"-bg\", \"-name\", etc."
(let (rest)
- (message "%S" args)
(while (and args
(not (equal (car args) "--")))
(let* ((argi (pop args))
;; Load library for our terminal type.
;; User init file can set term-file-prefix to nil to prevent this.
(unless (or noninteractive
- initial-window-system)
- (tty-run-terminal-initialization (selected-frame)))
+ initial-window-system
+ (daemonp))
+ (tty-run-terminal-initialization (selected-frame) nil t))
;; Update the out-of-memory error message based on user's key bindings
;; for save-some-buffers.
;; Process the remaining args.
(command-line-1 (cdr command-line-args))
+ ;; This is a problem because, e.g. if emacs.d/gnus.el exists,
+ ;; trying to load gnus could load the wrong file.
+ ;; OK, it would not matter if .emacs.d were at the end of load-path.
+ ;; but for the sake of simplicity, we discourage it full-stop.
+ ;; Ref eg http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00056.html
+ ;;
+ ;; A bad element could come from user-emacs-file, the command line,
+ ;; or EMACSLOADPATH, so we basically always have to check.
+ (let (warned)
+ (dolist (dir load-path)
+ (and (not warned)
+ (string-match-p "/[._]emacs\\.d/?\\'" dir)
+ (string-equal (file-name-as-directory (expand-file-name dir))
+ (expand-file-name user-emacs-directory))
+ (setq warned t)
+ (display-warning 'initialization
+ (format "Your `load-path' seems to contain
+your `.emacs.d' directory: %s\n\
+This is likely to cause problems...\n\
+Consider using a subdirectory instead, e.g.: %s" dir
+(expand-file-name "lisp" user-emacs-directory))
+ :warning))))
+
;; If -batch, terminate after processing the command options.
(if noninteractive (kill-emacs t))
(declare-function image-size "image.c" (spec &optional pixels frame))
+(defun fancy-splash-image-file ()
+ (cond ((stringp fancy-splash-image) fancy-splash-image)
+ ((display-color-p)
+ (cond ((<= (display-planes) 8)
+ (if (image-type-available-p 'xpm)
+ "splash.xpm"
+ "splash.pbm"))
+ ((or (image-type-available-p 'svg)
+ (image-type-available-p 'imagemagick))
+ "splash.svg")
+ ((image-type-available-p 'png)
+ "splash.png")
+ ((image-type-available-p 'xpm)
+ "splash.xpm")
+ (t "splash.pbm")))
+ (t "splash.pbm")))
+
(defun fancy-splash-head ()
"Insert the head part of the splash screen into the current buffer."
- (let* ((image-file (cond ((stringp fancy-splash-image)
- fancy-splash-image)
- ((display-color-p)
- (cond ((<= (display-planes) 8)
- (if (image-type-available-p 'xpm)
- "splash.xpm"
- "splash.pbm"))
- ((or (image-type-available-p 'svg)
- (image-type-available-p 'imagemagick))
- "splash.svg")
- ((image-type-available-p 'png)
- "splash.png")
- ((image-type-available-p 'xpm)
- "splash.xpm")
- (t "splash.pbm")))
- (t "splash.pbm")))
+ (let* ((image-file (fancy-splash-image-file))
(img (create-image image-file))
(image-width (and img (car (image-size img))))
(window-width (window-width)))
(insert "\n")
(fancy-startup-tail concise))
(use-local-map splash-screen-keymap)
+ (setq-local browse-url-browser-function 'eww-browse-url)
(setq tab-width 22
buffer-read-only t)
(set-buffer-modified-p nil)
(goto-char (point-min))
(force-mode-line-update))
(use-local-map splash-screen-keymap)
+ (setq-local browse-url-browser-function 'eww-browse-url)
(setq tab-width 22)
(setq buffer-read-only t)
(goto-char (point-min))
(image-type-available-p 'pbm)))
(let ((frame (fancy-splash-frame)))
(when frame
- (let* ((img (create-image (or fancy-splash-image
- (if (and (display-color-p)
- (image-type-available-p 'xpm))
- "splash.xpm" "splash.pbm"))))
+ (let* ((img (create-image (fancy-splash-image-file)))
(image-height (and img (cdr (image-size img nil frame))))
;; We test frame-height so that, if the frame is split
;; by displaying a warning, that doesn't cause the normal