Prefer 'vc as the project-find-file type when at briefcase's root

See the explanatory comment that I left in the code.
This commit is contained in:
William Carroll 2020-09-06 18:20:19 +01:00
parent 5cf6a0b23d
commit 43fc1d93fb

View file

@ -215,10 +215,16 @@
;; TODO: Consider moving this into a briefcase.el module. ;; TODO: Consider moving this into a briefcase.el module.
(defun wpc-misc--briefcase-find (dir) (defun wpc-misc--briefcase-find (dir)
"Find the default.nix nearest to DIR." "Find the default.nix nearest to DIR."
(when (s-starts-with? constants-briefcase (f-expand dir)) ;; I use 'vc only at the root of my monorepo because 'transient doesn't use my
(if (f-exists? (f-join dir "default.nix")) ;; .gitignore, which slows things down. Ideally, I could write a version that
(cons 'transient dir) ;; behaves like 'transient but also respects my monorepo's .gitignore and any
(wpc-misc--briefcase-find (f-parent dir))))) ;; ancestor .gitignore files.
(if (f-equal? constants-briefcase dir)
(cons 'vc dir)
(when (f-parent-of? constants-briefcase dir)
(if (f-exists? (f-join dir "default.nix"))
(cons 'transient dir)
(wpc-misc--briefcase-find (f-parent dir))))))
(add-to-list 'project-find-functions #'wpc-misc--briefcase-find) (add-to-list 'project-find-functions #'wpc-misc--briefcase-find)