Minor refactor of associate! macro
This commit is contained in:
parent
796af69c28
commit
b53df20dd5
1 changed files with 9 additions and 8 deletions
|
@ -353,17 +353,18 @@ The available conditions are:
|
|||
(user-error "associate! :files expects a string or list of strings"))
|
||||
(let ((hook-name (intern (format "doom--init-mode-%s" mode))))
|
||||
`(progn
|
||||
(defun ,hook-name ()
|
||||
(when (and (fboundp ',mode)
|
||||
(fset ',hook-name
|
||||
(lambda ()
|
||||
(and (fboundp ',mode)
|
||||
(not (bound-and-true-p ,mode))
|
||||
(and buffer-file-name (not (file-remote-p buffer-file-name)))
|
||||
,(if match `(if buffer-file-name (string-match-p ,match buffer-file-name)) t)
|
||||
,(if files (doom--resolve-path-forms
|
||||
(if (stringp (car files)) (cons 'and files) files)
|
||||
'(doom-project-root))
|
||||
t)
|
||||
,(or pred-form t))
|
||||
(,mode 1)))
|
||||
,(or (not files)
|
||||
(doom--resolve-path-forms
|
||||
(if (stringp (car files)) (cons 'and files) files)
|
||||
'(doom-project-root)))
|
||||
,(or pred-form t)
|
||||
(,mode 1))))
|
||||
,@(if (and modes (listp modes))
|
||||
(cl-loop for hook in (doom--resolve-hook-forms modes)
|
||||
collect `(add-hook ',hook #',hook-name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue