From 5cfaf59402dd2de125b91ffed001767755701dc8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 15 Sep 2025 16:43:52 -0400 Subject: [PATCH] refactor(cli): doom make: accept functions in make targets A little less magical (and more performant) than interpolation. --- .doom | 21 ++++++++++++--------- lisp/cli/make.el | 6 ++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.doom b/.doom index 4847c5ca8..e1e3ed095 100644 --- a/.doom +++ b/.doom @@ -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 - (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))) + ,(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))))) (publish (targets "docs/index.org" "docs" "modules/*/README.org") diff --git a/lisp/cli/make.el b/lisp/cli/make.el index 8af092249..ed33b4463 100644 --- a/lisp/cli/make.el +++ b/lisp/cli/make.el @@ -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)