From 96d558b01e69b2dd7fef3146291b2a69b999dabb Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 3 Jun 2022 15:38:51 -0700 Subject: feat(project): add `go.mod' to the list of files that define a project In a repository, I might have multiple `go.mod' files, and I want to treat of of the directories as a project, even within the same repository. Change-Id: I09937d9961464bff0f9d673d1eb50484eb8ea10e --- emacs/custom/my-navigation.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'emacs') diff --git a/emacs/custom/my-navigation.el b/emacs/custom/my-navigation.el index c0726ac..28c1fa1 100644 --- a/emacs/custom/my-navigation.el +++ b/emacs/custom/my-navigation.el @@ -6,6 +6,8 @@ (setq help-window-select t) +(require 'project) + (customize-set-variable 'project-switch-commands '((?f "File" project-find-file) (?d "Dired" project-dired) @@ -14,6 +16,18 @@ (?m "Magit status" magit-project-status) (?r "Search" rg-project))) + +(defun my/project-find-go-module (dir) + "Find the go.mod file in a DIR." + (when-let ((root (locate-dominating-file dir "go.mod"))) + (cons 'go-module root))) + +(cl-defmethod project-root ((project (head go-module))) + "Set the project root for PROJECT." + (cdr project)) + +(add-to-list 'project-find-functions #'my/project-find-go-module) + (customize-set-variable 'bookmark-save-flag 1) (global-set-key (kbd "C-x C-b") 'ibuffer) -- cgit 1.4.1