* bug#20584: 25.0.50; [PATCH] (list-packages) do not fail, if no user config file present
@ 2015-05-15 7:59 Eduard Wiebe
2015-05-15 9:21 ` Artur Malabarba
0 siblings, 1 reply; 2+ messages in thread
From: Eduard Wiebe @ 2015-05-15 7:59 UTC (permalink / raw)
To: 20584
* lisp/emacs-lisp/package.el (package--ensure-init-file) Ensure
user-init-file exists.
---
lisp/emacs-lisp/package.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 6156313..55901f5 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1810,9 +1810,10 @@ using `package-compute-transaction'."
(search-forward "(package-initialize)" nil 'noerror))))
;; Don't visit the file if we don't have to.
(with-temp-buffer
- (insert-file-contents user-init-file)
- (goto-char (point-min))
- (search-forward "(package-initialize)" nil 'noerror)))))
+ (when (file-exists-p user-init-file)
+ (insert-file-contents user-init-file)
+ (goto-char (point-min))
+ (search-forward "(package-initialize)" nil 'noerror))))))
(unless contains-init
(with-current-buffer (or buffer
(let ((delay-mode-hooks t))
--
Eduard Wiebe
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#20584: 25.0.50; [PATCH] (list-packages) do not fail, if no user config file present
2015-05-15 7:59 bug#20584: 25.0.50; [PATCH] (list-packages) do not fail, if no user config file present Eduard Wiebe
@ 2015-05-15 9:21 ` Artur Malabarba
0 siblings, 0 replies; 2+ messages in thread
From: Artur Malabarba @ 2015-05-15 9:21 UTC (permalink / raw)
To: 20584-done
Thanks for catching this, Eduard.
I think I'd rather not create a possibly-unwanted init file, so I've
applied the following patch instead.
1 file changed, 7 insertions(+), 2 deletions(-)
lisp/emacs-lisp/package.el | 9 +++++++--
modified 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-15 9:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 7:59 bug#20584: 25.0.50; [PATCH] (list-packages) do not fail, if no user config file present Eduard Wiebe
2015-05-15 9:21 ` Artur Malabarba
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).