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

Put functions in scope in the :config block #1059

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
11 changes: 10 additions & 1 deletion use-package-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,15 @@ extending any keys already present."
(setq result (cons (car x) (cons (cdr x) result))))
result)))

(defmacro use-package--eval-when-compile (&rest body)
"Evaluate BODY at compile time.
When expanding the macro, evaluate (progn BODY) and substitute
the macro call by the result of the evaluation. If BODY
is (require feature), then all the symbols declared in feature
are visible to the compiler. This contrasts with standard
`eval-when-compile', which only puts *variables* in scope."
(list 'quote (eval (cons 'progn body))))

(defun use-package-normalize-keywords (name args)
(let* ((name-symbol (if (stringp name) (intern name) name))
(name-string (symbol-name name-symbol)))
Expand Down Expand Up @@ -664,7 +673,7 @@ extending any keys already present."
(plist-get args :defines))
(mapcar #'(lambda (fn) `(declare-function ,fn ,name-string))
(plist-get args :functions))
`((eval-when-compile
`((use-package--eval-when-compile
(with-demoted-errors
,(format "Cannot load %s: %%S" name-string)
,(when (eq use-package-verbose 'debug)
Expand Down