Document Image Mode's new animation features.
[bpt/emacs.git] / lisp / startup.el
index 0b1c55b..98b6d20 100644 (file)
@@ -1,6 +1,7 @@
 ;;; 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
 ;; Keywords: internal
@@ -499,8 +500,6 @@ It is the default value of the variable `top-level'."
     ;; available input methods.
     (let ((tail load-path)
           (lispdir (expand-file-name "../lisp" data-directory))
-          ;; For out-of-tree builds, leim-list is generated in the build dir.
-          (leimdir (expand-file-name "../leim" doc-directory))
           dir)
       (while tail
         (setq dir (car tail))
@@ -508,12 +507,8 @@ It is the default value of the variable `top-level'."
           (load (expand-file-name "subdirs.el") t t t))
         ;; Do not scan standard directories that won't contain a leim-list.el.
         ;; http://lists.gnu.org/archive/html/emacs-devel/2009-10/msg00502.html
-        ;; Also skip leim/leim-list.el, since we preloaded that one.
+        ;; (Except the preloaded one in lisp/leim.)
         (or (string-prefix-p lispdir dir)
-            ;; Not supposed to be subdirs.el in leim, but someone
-            ;; might have added one and be keeping their own leim-list
-            ;; files in subdirs of leim.
-            (string-equal leimdir dir)
             (let ((default-directory dir))
               (load (expand-file-name "leim-list.el") t t t)))
         ;; We don't use a dolist loop and we put this "setq-cdr" command at
@@ -539,43 +534,45 @@ It is the default value of the variable `top-level'."
     ;; 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*"
@@ -605,12 +602,13 @@ It is the default value of the variable `top-level'."
     ;; 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
@@ -1295,6 +1293,29 @@ the `--debug-init' option to view a complete error backtrace."
   ;; 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))
 
@@ -1722,6 +1743,7 @@ splash screen in another window."
        (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)
@@ -1759,6 +1781,7 @@ splash screen in another window."
        (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))
@@ -1770,6 +1793,10 @@ Returning non-nil does not mean we should necessarily
 use the fancy splash screen, but if we do use it,
 we put it on this frame."
   (let (chosen-frame)
+    ;; MS-Windows needs this to have a chance to make the initial
+    ;; frame visible.
+    (if (eq system-type 'windows-nt)
+       (sit-for 0 t))
     (dolist (frame (append (frame-list) (list (selected-frame))))
       (if (and (frame-visible-p frame)
               (not (window-minibuffer-p (frame-selected-window frame))))
@@ -1780,7 +1807,7 @@ we put it on this frame."
   "Return t if fancy splash screens should be used."
   (when (and (display-graphic-p)
              (or (and (display-color-p)
-                (image-type-available-p 'xpm))
+                     (image-type-available-p 'xpm))
                  (image-type-available-p 'pbm)))
     (let ((frame (fancy-splash-frame)))
       (when frame