commit c7cf5cc4e59ee6da1129011d3b2b7dbcbfc801d0 parent eea68560a01a08bc88c6033b3058494dbbf785f5 Author: Vincent Demeester <vincent@sbr.pm> Date: Mon, 3 Jan 2022 16:25:38 +0100 tools/emacs: detect more project than just vcs. Mainly useful for my org-mode "project" but even for more possible use without VCS. Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | tools/emacs/config/config-projects.el | | | 23 | ++++++++++++++++++++--- |
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tools/emacs/config/config-projects.el b/tools/emacs/config/config-projects.el @@ -1,14 +1,31 @@ ;;; config-projects.el --- -*- lexical-binding: t; -*- ;;; Commentary: ;;; Project related configuration. -;;; This is mainly using projectile now, but built-in projects module seems promising for long-term. -;;; Note: this file is autogenerated from an org-mode file. ;;; Code: - (use-package project :bind (("C-x p v" . vde-project-magit-status) ("C-x p s" . vde-project-vterm)) + :config + + (setq vde/project-local-identifier '(".project" "go.mod" "Cargo.toml" + "Makefile" "README.org" "README.md")) + + (defun vde/project-try-local (dir) + "Determine if DIR is a non-VC project." + (if-let ((root (if (listp vde/project-local-identifier) + (seq-some (lambda (n) + (locate-dominating-file dir n)) + vde/project-local-identifier) + (locate-dominating-file dir vde/project-local-identifier)))) + (cons 'local root))) + (cl-defmethod project-root ((project (head local))) + (cdr project)) + + (cl-defmethod project-root ((project (eql nil))) nil) + + (add-hook 'project-find-functions #'vde/project-try-local) + :init (setq-default project-compilation-buffer-name-function 'project-prefixed-buffer-name) (defun vde-project-magit-status ()