From 581a64371cfc309a225bedee1d70f7df16b6073e Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 7 Sep 2022 19:02:42 -0700 Subject: feat(project): consider cargo's crate as project Add a helper to define directories that contain a 'Cargo.toml' file as a project. Change-Id: If099172eb6f35ecbea06a06fb39b7f64a5a809b7 --- emacs/custom/my-navigation.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'emacs') diff --git a/emacs/custom/my-navigation.el b/emacs/custom/my-navigation.el index 28c1fa1..5d03f86 100644 --- a/emacs/custom/my-navigation.el +++ b/emacs/custom/my-navigation.el @@ -16,6 +16,14 @@ (?m "Magit status" magit-project-status) (?r "Search" rg-project))) +(defun my/project-find-rust-module (dir) + "Find the Cargo.toml file in a DIR." + (when-let ((root (locate-dominating-file dir "Cargo.toml"))) + (cons 'rust-module root))) + +(cl-defmethod project-root ((project (head rust-module))) + "Set the project root for PROJECT." + (cdr project)) (defun my/project-find-go-module (dir) "Find the go.mod file in a DIR." @@ -27,6 +35,7 @@ (cdr project)) (add-to-list 'project-find-functions #'my/project-find-go-module) +(add-to-list 'project-find-functions #'my/project-find-rust-module) (customize-set-variable 'bookmark-save-flag 1) -- cgit 1.4.1