fix(emacs): Clj-nix template paths

This commit is contained in:
Madeleine Sydney
2025-02-21 21:14:41 -07:00
parent 88bb97c170
commit bf18ac3e16

View File

@@ -55,6 +55,19 @@
"n" #'skeletor-create-project "n" #'skeletor-create-project
"N" #'skeletor-create-project-at) "N" #'skeletor-create-project-at)
:config :config
;; TODO: Fix the `ns' form in Clojure files.
(defun syd-fix-clojure-file-name! (file-name)
(let ((new-file-name (->> file-name
(string-replace "-" "_")
;; NOTE: Will cause fuckiness if file-name starts
;; with a dot.
(string-replace "." "/"))))
(make-directory (file-name-directory new-file-name) t)
(rename-file file-name new-file-name)))
(defun syd-fix-clojure-file-names! (directory)
(let ((default-directory (file-name-concat directory "src")))
(dolist (file-name (directory-files "." nil "-" t))
(syd-fix-clojure-file-name! file-name))))
(skeletor-define-template "clj-nix" (skeletor-define-template "clj-nix"
:substitutions :substitutions
'(("__PROJECT-OWNER__" . (lambda () '(("__PROJECT-OWNER__" . (lambda ()
@@ -62,11 +75,7 @@
:before-git :before-git
(lambda (dir) (lambda (dir)
;; Use underscores instead of hyphens in clj file names. ;; Use underscores instead of hyphens in clj file names.
(let ((default-directory (file-name-concat dir "src"))) (syd-fix-clojure-file-names! dir)
(dolist (f (directory-files "." nil "-" t))
(rename-file
f
(string-replace "-" "_" f))))
;; REVIEW: Is it safe to make this be async? We require that the command ;; REVIEW: Is it safe to make this be async? We require that the command
;; has finished before Git initialises. ;; has finished before Git initialises.
(skeletor-shell-command "nix run github:jlesquembre/clj-nix#deps-lock" (skeletor-shell-command "nix run github:jlesquembre/clj-nix#deps-lock"