diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-15 17:08:41 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-15 17:08:41 +0200 |
| commit | 35449313f308564dd96781fc81f061a1cf7bdd14 (patch) | |
| tree | 8c6e727bdb9c6fcf56fa9e0e421663beea2ddaef | |
| parent | dd06dfd912656d41f2c63066aa8bacb898ddf7a2 (diff) | |
Add projectile-last-known-project variablefeature/1809-last-known-project
Closes #1809
Track the most recently accessed project root in
projectile-last-known-project, set automatically by
projectile-acquire-root. This allows users to reference
the last project even from non-project buffers.
| -rw-r--r-- | projectile.el | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/projectile.el b/projectile.el index 6c5306b..6e6f2e9 100644 --- a/projectile.el +++ b/projectile.el @@ -662,6 +662,11 @@ See also `projectile-remove-known-project', Contains a copy of `projectile-known-projects' when it was last synchronized with `projectile-known-projects-file'.") +(defvar projectile-last-known-project nil + "The root of the most recently accessed project. +This is set automatically by `projectile-acquire-root' and can be +used to reference the last project from non-project buffers.") + (defcustom projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld" user-emacs-directory) @@ -1456,7 +1461,9 @@ See also `projectile-acquire-root'." "Find the current project root, and prompts the user for it if that fails. Provides the common idiom (projectile-ensure-project (projectile-project-root)). Starts the search for the project with DIR." - (projectile-ensure-project (projectile-project-root dir))) + (let ((root (projectile-ensure-project (projectile-project-root dir)))) + (setq projectile-last-known-project root) + root)) (defun projectile-project-p (&optional dir) "Check if DIR is a project. |
