diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2025-01-31 21:56:18 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2025-01-31 21:56:18 +0200 |
| commit | 7d5e81689566a507b5602c812426933a6481185c (patch) | |
| tree | 5ecf7a0f846a6e80ba4d6b32677b639026104c0c /projectile.el | |
| parent | 74a4ca36ea28dec920caa7c713aa8632d8d690cc (diff) | |
Speed-up load time by moving known projects initialization
It's now done outside of `projectile-mode`'s init, which should make Projectile
load faster.
* As a side effect the known projects will be initialized properly even if you're not using `projectile-mode`.
* The projects are read from disk the first time you invoke
`projectile-switch-project` or a similar command.
* We no longer do auto-cleanup of known projects when projectile-mode
starts. I'll think about how to handle this in an efficient manner.
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/projectile.el b/projectile.el index 7790f6f..6e09c0e 100644 --- a/projectile.el +++ b/projectile.el @@ -5528,8 +5528,20 @@ An open project is a project with any open buffers." (list (abbreviate-file-name project))) projects)) +(defun projectile--init-known-projects () + "Initialize the known projects. + +This might potentially clean up redundant projects +and discover new ones if `projectile-auto-discover' is enabled." + ;; load the known projects + (unless projectile-known-projects + (projectile-load-known-projects)) + (when projectile-auto-discover + (projectile-discover-projects-in-search-path))) + (defun projectile-relevant-known-projects () "Return a list of known projects." + (projectile--init-known-projects) (pcase projectile-current-project-on-switch ('remove (projectile--remove-current-project projectile-known-projects)) ('move-to-end (projectile--move-current-project-to-end projectile-known-projects)) @@ -6316,12 +6328,6 @@ Otherwise behave as if called interactively. (projectile-mode ;; setup the commander bindings (projectile-commander-bindings) - ;; load the known projects - (projectile-load-known-projects) - ;; update the list of known projects - (projectile--cleanup-known-projects) - (when projectile-auto-discover - (projectile-discover-projects-in-search-path)) (add-hook 'project-find-functions #'project-projectile) (add-hook 'find-file-hook 'projectile-find-file-hook-function) (add-hook 'projectile-find-dir-hook #'projectile-track-known-projects-find-file-hook t) |
