about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-23T21·39+0100
committertazjin <mail@tazj.in>2020-08-23T22·48+0000
commit937469509bfcef494ae1b1bc6ba23bfccd28d477 (patch)
tree748802a374a78eb67df02afa58dc56c9ea0fb359
parent7a344fbb5e73701dff8fd15be6ede90d083d424e (diff)
feat(tazjin/emacs): Add depot-aware project.el extension r/1707
If this ends up working well I'll extract it to tvl.el

Change-Id: I83722abf33a3346ccc7957c8d64d6381b15c6ee9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1837
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
-rw-r--r--users/tazjin/emacs/config/functions.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el
index 6478f88cc1c8..df5b1c1239f0 100644
--- a/users/tazjin/emacs/config/functions.el
+++ b/users/tazjin/emacs/config/functions.el
@@ -40,8 +40,6 @@
   (interactive)
   (man "configuration.nix"))
 
-;; Open my monorepo in magit
-
 ;; Get the nix store path for a given derivation.
 ;; If the derivation has not been built before, this will trigger a build.
 (defun nix-store-path (derivation)
@@ -281,4 +279,14 @@
   (interactive)
   (vterm-send-key "x" nil nil t))
 
+(defun find-depot-project (dir)
+  "Function used in the `project-find-functions' hook list to
+  determine the current project root of a depot project."
+  (when (s-starts-with? "/depot" dir)
+    (if (f-exists-p (f-join dir "default.nix"))
+        (cons 'transient dir)
+      (find-depot-project (f-parent dir)))))
+
+(add-to-list 'project-find-functions #'find-depot-project)
+
 (provide 'functions)