diff options
| author | João Távora <joaotavora@gmail.com> | 2026-01-10 11:43:29 +0000 |
|---|---|---|
| committer | João Távora <joaotavora@gmail.com> | 2026-01-10 11:45:39 +0000 |
| commit | c7f57beb72fb8433ce0be0655bbcb9954437a692 (patch) | |
| tree | f0017858eadc8e7919fbefcf96fc3e616c545e76 | |
| parent | dfd1ff57e010a12ba1e6a33fb2dd751981487750 (diff) | |
Fix #18: Add a bc--cached-project-root
Fix #46.
* breadcrumb.el (bc--project-crumbs-1): Tweak.
(bc--cached-project-root): New variable.
| -rw-r--r-- | breadcrumb.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/breadcrumb.el b/breadcrumb.el index 433cd32..0abe57c 100644 --- a/breadcrumb.el +++ b/breadcrumb.el @@ -344,13 +344,24 @@ to ROOT." (define-key m bc--mode-line-key l) m)))) +(defvar-local bc--cached-project-root nil + ;; This is a fairly "dumb" cache, but hopefully good enough for most + ;; cases. A better smarter cache that could realize when certain + ;; project things happened would live in project.el which has much + ;; more project-smarts, but that's apparently very hard, so do it + ;; here (github#18) + "Cache the expensive `project-root' call.") + (defun bc--project-crumbs-1 (bfn) "Helper for `breadcrumb-project-crumbs'. Given BFN, the `buffer-file-name', produce a list of propertized crumbs." (cl-loop with project = (project-current) - with root = (if project (project-root project) default-directory) + with root = (if project (or bc--cached-project-root + (setq bc--cached-project-root + (project-root project))) + default-directory) with pname = (if project (project-name project) (file-name-nondirectory (directory-file-name root))) with relname = (file-relative-name (or bfn default-directory) |
