Add ~/Projects to C-x p p switcher

This commit is contained in:
tim.mccarthy committed 2026-09-15 15:08:37 -07:00
1 parent 80ca830bf8
commit 6f4690bba0
1 file changed
+25 -1
+25 -1
View File
@@ -298,6 +298,9 @@ EMACS-ALTERNATIVE is the Emacs equivalent (e.g., 'C-s')."
:init :init
(vertico-mode) (vertico-mode)
(vertico-multiform-mode 1) (vertico-multiform-mode 1)
;; Preserve project.el's most-recently-used order in the project chooser.
(add-to-list 'vertico-multiform-commands
'(project-switch-project (vertico-sort-function . nil)))
(add-to-list 'vertico-multiform-categories (add-to-list 'vertico-multiform-categories
'(jinx grid (vertico-grid-annotate . 20)))) '(jinx grid (vertico-grid-annotate . 20))))
@@ -658,6 +661,7 @@ EMACS-ALTERNATIVE is the Emacs equivalent (e.g., 'C-s')."
;;;; Project ;;;; Project
(use-package project (use-package project
:custom :custom
(project-prompter #'my/project-prompt)
(project-switch-commands (project-switch-commands
'((project-find-file "Find file") '((project-find-file "Find file")
(consult-ripgrep "Ripgrep") (consult-ripgrep "Ripgrep")
@@ -666,7 +670,27 @@ EMACS-ALTERNATIVE is the Emacs equivalent (e.g., 'C-s')."
(project-any-command "Other"))) (project-any-command "Other")))
:config :config
;; Make project.el recognize directories with a .project file as project roots ;; Make project.el recognize directories with a .project file as project roots
(add-to-list 'project-vc-extra-root-markers ".project")) (add-to-list 'project-vc-extra-root-markers ".project")
(defcustom my/project-search-path '("~/Projects/")
"Directories whose immediate children are scanned for projects."
:type '(repeat directory)
:group 'project)
(defun my/project-refresh ()
"Remember recognized projects directly under `my/project-search-path'."
(interactive)
(dolist (directory my/project-search-path)
(let ((directory (expand-file-name directory)))
(when (file-directory-p directory)
(project-remember-projects-under directory)))))
(defun my/project-prompt (&optional prompt predicate require-known)
"Refresh known projects, then prompt using the standard project chooser.
Pass PROMPT, PREDICATE and REQUIRE-KNOWN through to the chooser."
(let ((inhibit-message t))
(my/project-refresh))
(project-prompt-project-dir prompt predicate require-known)))
;;;; hl-todo ;;;; hl-todo
(use-package hl-todo (use-package hl-todo