Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions quelpa-use-package.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,36 @@

;;; Code:

(defvar quelpa-use-package-inhibit-loading-quelpa nil
(defgroup quelpa-use-package nil
"Quelpa handler for `use-package'."
:group 'quelpa)

(defcustom quelpa-use-package-inhibit-loading-quelpa nil
"If non-nil, `quelpa-use-package' will do its best to avoid

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line of a docstring should be a complete sentence. If this one's is being updated, it might as well be fixed.

loading `quelpa' unless necessary. This improves performance, but
can prevent packages from being updated automatically.")
can prevent packages from being updated automatically."
:type 'boolean
:group 'quelpa-use-package)

(defvar quelpa-persistent-cache-p)

(defcustom quelpa-use-package-as-source-of-truth nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this variable seems unclear, and a bit mysterious. Could it be given a more descriptive one?

"If non-nil, only packages installed by this package will be managed by `quelpa'.
This option will disable `quelpa-persistent-cache-p'."
:type 'boolean
:group 'quelpa-use-package
:set (lambda (symbol value)
(set-default-toplevel-value symbol value)
(when value
(setq quelpa-persistent-cache-p nil))))

(require 'cl-lib)
(unless quelpa-use-package-inhibit-loading-quelpa
(require 'quelpa))
(require 'use-package-core)

(defvar quelpa-use-package-keyword :quelpa)
(defvar quelpa-cache)

;; insert `:quelpa' keyword after `:unless' so that quelpa only runs
;; if either `:if', `:when', `:unless' or `:requires' are satisfied
Expand Down Expand Up @@ -76,11 +95,18 @@ can prevent packages from being updated automatically.")
;; compiled or evaluated.
(if args
(use-package-concat
`((unless (and quelpa-use-package-inhibit-loading-quelpa
(package-installed-p ',(pcase (car args)
((pred symbolp) (car args))
((pred listp) (car (car args))))))
(apply 'quelpa ',args)))
(let ((info (pcase (car args)
((pred listp) (car args))
(`,pkg `(,pkg)))))
`((let ((pkg ',(car info)))
(require 'finder-inf nil t)
(if (and quelpa-use-package-inhibit-loading-quelpa
(or (assq pkg package--builtins)
(memq pkg package-activated-list)))
(when quelpa-use-package-as-source-of-truth
(setq quelpa-cache (when (boundp 'quelpa-cache) quelpa-cache))
(setf (alist-get ',(car info) quelpa-cache) ',(cdr info)))
(quelpa ',@args)))))
body)
body)))

Expand Down