From: Glenn Morris Date: Sun, 1 Dec 2013 02:04:46 +0000 (-0800) Subject: * lisp/startup.el (command-line): Warn if ~/emacs.d is in load-path. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~616 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2e6710c39621ab7dd18b33517699b3daa3dfbb26;p=emacs.git * lisp/startup.el (command-line): Warn if ~/emacs.d is in load-path. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f03abe793e2..5c6c40bc515 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2013-12-01 Glenn Morris + + * startup.el (command-line): Warn if ~/emacs.d is in load-path. + 2013-11-30 Eli Zaretskii * startup.el (fancy-splash-frame): On MS-Windows, trigger diff --git a/lisp/startup.el b/lisp/startup.el index 25e75c994a6..a21695fe19a 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1289,6 +1289,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))