Fix "Failed to parse X" errors from use-package

use-package-handler/:after-call was (accidentally) relying on the
dynamic value of `name`, but now that use-package uses lexical binding,
this isn't possible anymore, causes errors.
This commit is contained in:
Henrik Lissner 2018-06-14 11:53:52 +02:00
parent 8c4d8d739b
commit cc3fd3126a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -164,7 +164,7 @@ non-nil, return paths of possible modules, activated or otherwise."
;; Adds the :after-call custom keyword to `use-package' (and consequently, ;; Adds the :after-call custom keyword to `use-package' (and consequently,
;; `def-package!'). :after-call takes a symbol or list of symbols. These symbols ;; `def-package!'). :after-call takes a symbol or list of symbols. These symbols
;; can be functions to hook variables. ;; can be functions or hook variables.
;; ;;
;; (use-package X :after-call find-file-hook) ;; (use-package X :after-call find-file-hook)
;; ;;
@ -180,20 +180,20 @@ non-nil, return paths of possible modules, activated or otherwise."
(defalias 'use-package-normalize/:after-call (defalias 'use-package-normalize/:after-call
'use-package-normalize-symlist) 'use-package-normalize-symlist)
(defun use-package-handler/:after-call (name-symbol _keyword hooks rest state) (defun use-package-handler/:after-call (name _keyword hooks rest state)
(let ((fn (intern (format "doom|transient-hook--load-%s" name-symbol))) (let ((fn (intern (format "doom|transient-hook--load-%s" name)))
(hooks (delete-dups hooks))) (hooks (delete-dups hooks)))
(if (plist-get state :demand) (if (plist-get state :demand)
(use-package-process-keywords name rest state) (use-package-process-keywords name rest state)
(use-package-concat (use-package-concat
`((fset ',fn `((fset ',fn
(lambda (&rest _) (lambda (&rest _)
(require ',name-symbol) (require ',name)
(dolist (hook (cdr (assq ',name-symbol doom--deferred-packages-alist))) (dolist (hook (cdr (assq ',name doom--deferred-packages-alist)))
(if (functionp hook) (if (functionp hook)
(advice-remove hook #',fn) (advice-remove hook #',fn)
(remove-hook hook #',fn))) (remove-hook hook #',fn)))
(map-delete doom--deferred-packages-alist ',name-symbol) (map-delete doom--deferred-packages-alist ',name)
(fmakunbound ',fn)))) (fmakunbound ',fn))))
(cl-mapcan (lambda (hook) (cl-mapcan (lambda (hook)
(if (functionp hook) (if (functionp hook)
@ -201,8 +201,8 @@ non-nil, return paths of possible modules, activated or otherwise."
`((add-hook ',hook #',fn)))) `((add-hook ',hook #',fn))))
hooks) hooks)
`((map-put doom--deferred-packages-alist `((map-put doom--deferred-packages-alist
',name-symbol ',name
'(,@hooks ,@(cdr (assq name-symbol doom--deferred-packages-alist))))) '(,@hooks ,@(cdr (assq name doom--deferred-packages-alist)))))
(use-package-process-keywords name rest state)))))) (use-package-process-keywords name rest state))))))