Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use quelpa-use-package as source of truth for quelpa-cache #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
29 changes: 26 additions & 3 deletions quelpa-use-package.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,35 @@

;;; Code:

(defvar quelpa-use-package-inhibit-loading-quelpa nil
(defgroup quelpa-use-package nil
"Quelpa handler for `use-package'."
:prefix "quelpa-use-package"
Copy link
Member

Choose a reason for hiding this comment

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

It's not harmful to specify the prefix, but it's unnecessary for options specified later in the same file.

:group 'use-package)
Copy link
Member

Choose a reason for hiding this comment

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

Should the parent group be use-package or quelpa?


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

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)

(defcustom quelpa-use-package-as-source-of-truth nil
Copy link
Member

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 via this will be managed by `quelpa'.
Copy link
Member

Choose a reason for hiding this comment

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

It may be unclear what "this" refers to.

As well, it seems unclear what "managed by Quelpa" means.

This option will disable `quelpa-persistent-cache-p'."
:type 'boolean
:group 'quelpa-use-package)

(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)
(defvar quelpa-persistent-cache-p)

(when quelpa-use-package-as-source-of-truth
(setq quelpa-persistent-cache-p nil))
Comment on lines +67 to +68
Copy link
Member

Choose a reason for hiding this comment

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

This form belongs in the defcustom's setter so it will take effect when the option is changed.


;; insert `:quelpa' keyword after `:unless' so that quelpa only runs
;; if either `:if', `:when', `:unless' or `:requires' are satisfied
Expand Down Expand Up @@ -76,10 +94,15 @@ can prevent packages from being updated automatically.")
;; compiled or evaluated.
(if args
(use-package-concat
`((unless (and quelpa-use-package-inhibit-loading-quelpa
`((if (and quelpa-use-package-inhibit-loading-quelpa
(package-installed-p ',(pcase (car args)
((pred symbolp) (car args))
((pred listp) (car (car args))))))
(when quelpa-use-package-as-source-of-truth
(setq quelpa-cache (append (when (boundp 'quelpa-cache) quelpa-cache)
',(pcase (car args)
((pred symbolp) (list args))
((pred listp) args)))))
(apply 'quelpa ',args)))
body)
body)))
Expand Down