refactor(cli): doom make: accept functions in make targets

A little less magical (and more performant) than interpolation.
This commit is contained in:
Henrik Lissner
2025-09-15 16:43:52 -04:00
parent 15a0e90808
commit 5cfaf59402
2 changed files with 16 additions and 11 deletions

9
.doom
View File

@@ -27,7 +27,8 @@
(make
("LICENSE"
"The MIT License (MIT)\n"
,(format-time-string "Copyright (c) 2014-%Y Henrik Lissner.\n")
,(lambda (_)
(insert (format-time-string "Copyright (c) 2014-%Y Henrik Lissner.\n\n")))
"Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
\"Software\"), to deal in the Software without restriction, including
@@ -49,14 +50,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.")
"# Auto-generated by 'doom make .github/CODEOWNERS', do not edit it by hand.\n"
"* @doomemacs/maintainers\n" ; default until another takes precedence
"# Module maintainers"
,@(cl-sort
,(lambda (rc)
(mapc (lambda (line) (insert line "\n"))
(cl-sort
(cl-loop for path in (doom-module-load-path (list doom-modules-dir))
if (string-match "/modules/\\([^/]+\\)/\\([^/]+\\)$" path)
collect (format "%-35s @doomemacs/%s-%s"
(substring (match-string 0 path) 1)
(match-string 1 path)
(match-string 2 path)))
#'string-lessp)))
#'string-lessp)))))
(publish
(targets "docs/index.org" "docs" "modules/*/README.org")

View File

@@ -34,8 +34,10 @@
(if (null rule)
(print! (warn "No known make rule for: %s" name))
(dolist (entry rule)
(when (stringp entry)
(insert entry "\n")))
(cond ((stringp entry)
(insert entry "\n"))
((functionp entry)
(funcall entry rc))))
(if (null outfile)
(print! "%s" (buffer-string))
(print! (start "Wrote %s") name)