about summary refs log tree commit diff
path: root/users/tazjin/emacs/config/functions.el
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/emacs/config/functions.el')
-rw-r--r--users/tazjin/emacs/config/functions.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el
index e725c23ccf..f64907a591 100644
--- a/users/tazjin/emacs/config/functions.el
+++ b/users/tazjin/emacs/config/functions.el
@@ -293,6 +293,16 @@ the GPG agent correctly."
 
 (add-to-list 'project-find-functions #'find-depot-project)
 
+(defun find-cargo-project (dir)
+  "Attempt to find the current project in `project-find-functions'
+by looking for a `Cargo.toml' file."
+  (unless (equal "/" dir)
+    (if (f-exists-p (f-join dir "Cargo.toml"))
+        (cons 'transient dir)
+      (find-cargo-project (f-parent dir)))))
+
+(add-to-list 'project-find-functions #'find-cargo-project)
+
 (defun magit-find-file-worktree ()
   (interactive)
   "Find a file in the current (ma)git worktree."