minmo : store ignored in minmo--git-directory-table

This commit is contained in:
bth 2026-06-02 23:34:34 -07:00
commit 7d223f91bc

View file

@ -107,16 +107,15 @@ single space.")
(defvar minmo--git-directory-table (make-hash-table) "Store known directories (defvar minmo--git-directory-table (make-hash-table) "Store known directories
with .git") with .git")
(defun minmo--find-git (file &optional force) (defun minmo--under-git-p (file &optional force)
"Walk up the directory tree looking for `.git'. Returns root path or nil. "Walk up the directory tree looking for `.git'. Returns t or nil.
Optional FORCE means ignore the minmo--git-directory-table." Optional FORCE means ignore the minmo--git-directory-table."
(let* ((dir (file-name-directory file)) (let* ((dir (file-name-directory file))
(hash (gethash dir minmo--git-directory-table))) (hash (gethash dir minmo--git-directory-table)))
(if (or force (not hash)) (if (or force (not hash))
;; NOTE: this will store nil for files not under .git, which means the ;; NOTE: store 'ignore for files not under .git
;; check will always fire. consider storing a symbol here. (puthash dir (or (locate-dominating-file file ".git") 'ignore) minmo--git-directory-table)
(puthash dir (locate-dominating-file file ".git") minmo--git-directory-table) (not (eq hash 'ignore)))))
hash)))
(defun minmo--file-exists-locally-p () (defun minmo--file-exists-locally-p ()
"Utility predicate to prevent expensive VC checks remotely." "Utility predicate to prevent expensive VC checks remotely."
@ -152,7 +151,7 @@ Optional FORCE means ignore the minmo--git-directory-table."
(when (minmo--file-exists-locally-p) (when (minmo--file-exists-locally-p)
(let ((old-status minmo--vc-status-cache) (let ((old-status minmo--vc-status-cache)
(old-branch minmo--vc-branch-cache) (old-branch minmo--vc-branch-cache)
(git (minmo--find-git buffer-file-name force))) (git (minmo--under-git-p buffer-file-name force)))
(if git (if git
(progn (progn
@ -247,12 +246,15 @@ Optional FORCE means ignore the minmo--git-directory-table."
"Cache the project name to prevent disk I/O during redisplay." "Cache the project name to prevent disk I/O during redisplay."
(setq minmo--project-cache (setq minmo--project-cache
;; don't show project for help buffers, remote files, etc: ;; don't show project for help buffers, remote files, etc:
(when-let* (((minmo--file-exists-locally-p)) (when-let* ((_ (minmo--file-exists-locally-p))
;; NOTE: taken from project-mode-line-format ;; NOTE: taken from project-mode-line-format
(last-coding-system-used last-coding-system-used) (last-coding-system-used last-coding-system-used)
;; NOTE: project-current calls project--get-cached, which uses ;; NOTE: project-current calls project--get-cached, which uses
;; project-vc-non-essential-cache-timeout when non-essential is t ;; project-vc-non-essential-cache-timeout when non-essential is t
(non-essential t) (non-essential t)
;; TODO: this relies on vc internals. if I'm severing
;; dependence on vc-mode, consider replacing with a simple
;; dir lookup done during minmo--under-git-p
(project (project-current))) (project (project-current)))
(concat " " (project-name project))) (concat " " (project-name project)))
)) ))