core: minor refactor/reformat
+ Prefer cl-loop over cl-mapcan for performance reasons. + Remove unnecessary let form + Log doom-try-run-hook when doom-debug-mode is on.
This commit is contained in:
parent
adf9b7d26f
commit
600d7bcb4f
3 changed files with 13 additions and 9 deletions
|
@ -57,7 +57,8 @@ omitted, show all available commands, their aliases and brief descriptions."
|
||||||
(cl-destructuring-bind (command &key desc body)
|
(cl-destructuring-bind (command &key desc body)
|
||||||
(let ((sym (intern (car args))))
|
(let ((sym (intern (car args))))
|
||||||
(or (assq sym doom--dispatch-command-alist)
|
(or (assq sym doom--dispatch-command-alist)
|
||||||
(assq (cdr (assq sym doom--dispatch-alias-alist)) doom--dispatch-command-alist)
|
(assq (cdr (assq sym doom--dispatch-alias-alist))
|
||||||
|
doom--dispatch-command-alist)
|
||||||
(error "Invalid command: %s" (car args))))
|
(error "Invalid command: %s" (car args))))
|
||||||
(if help
|
(if help
|
||||||
(apply #'doom--dispatch-help command desc (cdr args))
|
(apply #'doom--dispatch-help command desc (cdr args))
|
||||||
|
@ -71,7 +72,8 @@ bin/doom help.
|
||||||
|
|
||||||
BODY will be run when this dispatcher is called."
|
BODY will be run when this dispatcher is called."
|
||||||
(declare (doc-string 3))
|
(declare (doc-string 3))
|
||||||
(cl-destructuring-bind (cmd &rest aliases) (doom-enlist command)
|
(cl-destructuring-bind (cmd &rest aliases)
|
||||||
|
(doom-enlist command)
|
||||||
(macroexp-progn
|
(macroexp-progn
|
||||||
(append
|
(append
|
||||||
(when aliases
|
(when aliases
|
||||||
|
|
|
@ -94,8 +94,9 @@ Example:
|
||||||
(unless (plist-member plist :path)
|
(unless (plist-member plist :path)
|
||||||
(plist-put plist :path (or (plist-get old-plist :path)
|
(plist-put plist :path (or (plist-get old-plist :path)
|
||||||
(doom-module-locate-path category module))))))
|
(doom-module-locate-path category module))))))
|
||||||
(let ((key (cons category module)))
|
(puthash (cons category module)
|
||||||
(puthash key plist doom-modules)))
|
plist
|
||||||
|
doom-modules))
|
||||||
|
|
||||||
(defun doom-module-path (category module &optional file)
|
(defun doom-module-path (category module &optional file)
|
||||||
"Like `expand-file-name', but expands FILE relative to CATEGORY (keywordp) and
|
"Like `expand-file-name', but expands FILE relative to CATEGORY (keywordp) and
|
||||||
|
@ -205,11 +206,10 @@ non-nil, return paths of possible modules, activated or otherwise."
|
||||||
(remove-hook hook #',fn)))
|
(remove-hook hook #',fn)))
|
||||||
(map-delete doom--deferred-packages-alist ',name)
|
(map-delete doom--deferred-packages-alist ',name)
|
||||||
(fmakunbound ',fn))))
|
(fmakunbound ',fn))))
|
||||||
(cl-mapcan (lambda (hook)
|
(cl-loop for hook in hooks
|
||||||
(if (functionp hook)
|
collect (if (functionp hook)
|
||||||
`((advice-add #',hook :before #',fn))
|
`(advice-add #',hook :before #',fn)
|
||||||
`((add-hook ',hook #',fn))))
|
`(add-hook ',hook #',fn)))
|
||||||
hooks)
|
|
||||||
`((map-put doom--deferred-packages-alist
|
`((map-put doom--deferred-packages-alist
|
||||||
',name
|
',name
|
||||||
'(,@hooks ,@(cdr (assq name doom--deferred-packages-alist)))))
|
'(,@hooks ,@(cdr (assq name doom--deferred-packages-alist)))))
|
||||||
|
|
|
@ -245,6 +245,8 @@ original value of `symbol-file'."
|
||||||
easier to tell where the came from.
|
easier to tell where the came from.
|
||||||
|
|
||||||
Meant to be used with `run-hook-wrapped'."
|
Meant to be used with `run-hook-wrapped'."
|
||||||
|
(when doom-debug-mode
|
||||||
|
(message "Running doom hook: %s" hook))
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(funcall hook)
|
(funcall hook)
|
||||||
((debug error)
|
((debug error)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue