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"))
|
(user-error "associate! :files expects a string or list of strings"))
|
||||||
(let ((hook-name (intern (format "doom--init-mode-%s" mode))))
|
(let ((hook-name (intern (format "doom--init-mode-%s" mode))))
|
||||||
`(progn
|
`(progn
|
||||||
(defun ,hook-name ()
|
(fset ',hook-name
|
||||||
(when (and (fboundp ',mode)
|
(lambda ()
|
||||||
|
(and (fboundp ',mode)
|
||||||
(not (bound-and-true-p ,mode))
|
(not (bound-and-true-p ,mode))
|
||||||
(and buffer-file-name (not (file-remote-p buffer-file-name)))
|
(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 match `(if buffer-file-name (string-match-p ,match buffer-file-name)) t)
|
||||||
,(if files (doom--resolve-path-forms
|
,(or (not files)
|
||||||
(if (stringp (car files)) (cons 'and files) files)
|
(doom--resolve-path-forms
|
||||||
'(doom-project-root))
|
(if (stringp (car files)) (cons 'and files) files)
|
||||||
t)
|
'(doom-project-root)))
|
||||||
,(or pred-form t))
|
,(or pred-form t)
|
||||||
(,mode 1)))
|
(,mode 1))))
|
||||||
,@(if (and modes (listp modes))
|
,@(if (and modes (listp modes))
|
||||||
(cl-loop for hook in (doom--resolve-hook-forms modes)
|
(cl-loop for hook in (doom--resolve-hook-forms modes)
|
||||||
collect `(add-hook ',hook #',hook-name))
|
collect `(add-hook ',hook #',hook-name))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue