summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/package.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-05-15 10:17:48 +0100
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-05-15 10:17:48 +0100
commitb1c23fb94072cca7f08ea5f50430916b9ea168e6 (patch)
treee817b648cd1f0af3932273f59c519132906e31ec /lisp/emacs-lisp/package.el
parentca6a7774c533d87ad8d8e17624bbd70e9d086bc0 (diff)
downloademacs-b1c23fb94072cca7f08ea5f50430916b9ea168e6.tar.gz
* lisp/emacs-lisp/package.el: Be more careful with the init file
(package--ensure-init-file): Check that user-init-file is set, exists, is readable, and is writable. (Bug#20584) Also expand the docstring.
Diffstat (limited to 'lisp/emacs-lisp/package.el')
-rw-r--r--lisp/emacs-lisp/package.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 615631383e7..1d27bf752df 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1796,9 +1796,14 @@ using `package-compute-transaction'."
(callback (funcall callback))))
(defun package--ensure-init-file ()
- "Ensure that the user's init file calls `package-initialize'."
+ "Ensure that the user's init file has `package-initialize'.
+`package-initialize' doesn't have to be called, as long as it is
+present somewhere in the file, even as a comment. If it is not,
+add a call to it along with some explanatory comments."
;; Don't mess with the init-file from "emacs -Q".
- (when user-init-file
+ (when (and (stringp user-init-file)
+ (file-readable-p user-init-file)
+ (file-writable-p user-init-file))
(let* ((buffer (find-buffer-visiting user-init-file))
(contains-init
(if buffer