1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-11 08:30:45 -08:00

Restructure some code

This commit is contained in:
John Wiegley 2017-11-29 22:20:43 -08:00
parent 5e1a656e06
commit 35f46f7b42

View file

@ -729,31 +729,32 @@ If the package is installed, its entry is removed from
"(an unquoted symbol name)"))))))) "(an unquoted symbol name)")))))))
(defun use-package-ensure-elpa (name ensure state context &optional no-refresh) (defun use-package-ensure-elpa (name ensure state context &optional no-refresh)
(let ((package (or (when (eq ensure t) (use-package-as-symbol name)) (let ((package (or (and (eq ensure t) (use-package-as-symbol name))
ensure))) ensure)))
(when package (when package
(require 'package) (require 'package)
(or (package-installed-p package) (or (package-installed-p package)
(not (or ;; Contexts in which the confirmation prompt is bypassed.
;; Contexts in which the confirmation prompt is (not (or (member context '(:byte-compile :ensure :config))
;; bypassed. (y-or-n-p (format "Install package %S?" package))))
(member context '(:byte-compile :ensure :config))
(y-or-n-p (format "Install package %S?" package))))
(condition-case-unless-debug err (condition-case-unless-debug err
(progn (let ((pinned (assoc package (bound-and-true-p
(when (assoc package (bound-and-true-p package-pinned-packages)) package-pinned-packages))))
(when pinned
(package-read-all-archive-contents)) (package-read-all-archive-contents))
(cond ((assoc package package-archive-contents) (if (assoc package package-archive-contents)
(package-install package) (package-install package)
t) (package-refresh-contents)
(t (when pinned
(package-refresh-contents) (package-read-all-archive-contents))
(when (assoc package (package-install package))
(bound-and-true-p package-pinned-packages)) t)
(package-read-all-archive-contents)) (error
(package-install package)))) (ignore
(error (message "Error: Cannot load %s: %S" name err) (display-warning 'use-package
nil)))))) (format "Failed to install %s: %s"
name (error-message-string err))
:error))))))))
(defun use-package-handler/:ensure (name keyword ensure rest state) (defun use-package-handler/:ensure (name keyword ensure rest state)
(let* ((body (use-package-process-keywords name rest (let* ((body (use-package-process-keywords name rest