about summary refs log tree commit diff
path: root/emacs/.emacs.d
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-24T10·19+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-24T10·19+0100
commit7a1e56e7d1a7086765f5810993012c52512060dc (patch)
tree629a5ca442ee9ff7f527bc9d21b434a00f932895 /emacs/.emacs.d
parent7ab86f5423578cc86b76ed034e2a79e22a3af727 (diff)
Prefer simpler, more idiomatic project-find-function
This version avoids installed all of the custom `cl-defmethods` for a
`'monorepo` type and instead uses the existing `'transient`.
Diffstat (limited to 'emacs/.emacs.d')
-rw-r--r--emacs/.emacs.d/wpc/wpc-misc.el29
1 files changed, 5 insertions, 24 deletions
diff --git a/emacs/.emacs.d/wpc/wpc-misc.el b/emacs/.emacs.d/wpc/wpc-misc.el
index fd65dc21485c..5b21ec410892 100644
--- a/emacs/.emacs.d/wpc/wpc-misc.el
+++ b/emacs/.emacs.d/wpc/wpc-misc.el
@@ -207,31 +207,12 @@
 (defun project-find-function--briefcase (dir)
   "Find the nearest default.nix file; otherwise, terminate at the .git
   directory."
-  (let ((filenames (->> dir f-files (-map #'f-filename)))
-        (dirnames (->> dir f-directories (-map #'f-dirname))))
-    (if (or (-contains? filenames "default.nix")
-            (-contains? dirnames ".git"))
-        (cons 'monorepo dir)
-      (if (f-parent dir)
-          (project-find-function--briefcase (f-parent dir))
-        nil))))
+  (when (s-starts-with? (getenv "BRIEFCASE") (f-expand dir))
+    (if (f-exists? (f-join dir "default.nix"))
+        (cons 'transient dir)
+      (project-find-function--briefcase (f-parent dir)))))
 
-(cl-defmethod project-root ((project (head monorepo)))
-  (cdr project))
-
-(cl-defmethod project-roots ((project (head monorepo)))
-  (list (cdr project)))
-
-(cl-defmethod project-external-roots ((project (head monorepo)))
-  (project-external-roots (cons 'vc (cdr project))))
-
-(cl-defmethod project-ignores ((project (head monorepo)) dir)
-  (project-ignores (cons 'vc (cdr project)) dir))
-
-(cl-defmethod project-files ((project (head monorepo)) &optional dirs)
-  (project-files (cons 'vc (cdr project)) dirs))
-
-(setq project-find-functions (list #'project-find-function--briefcase))
+(add-to-list 'project-find-functions #'project-find-function--briefcase)
 
 (use-package deadgrep
   :config