Skip to content
Permalink
d0fbf77291
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
22 lines (17 sloc) 732 Bytes
;;; Project root cache -*- lexical-binding: t -*-
(require 'project)
;; Based on ibuffer-project.el.
(defvar akirak/project-roots-cache (make-hash-table :test 'equal)
"Variable to store cache of project per directory.")
(defun akirak/clear-project-cache ()
(interactive)
(clrhash akirak/project-roots-cache))
(defun akirak/project-root (dir)
"Return the project root of DIR with cache enabled."
(pcase (gethash dir akirak/project-roots-cache 'no-cached)
('no-cached (let* ((project (project-current nil dir))
(root (and project (car (project-roots project)))))
(puthash dir root akirak/project-roots-cache)
root))
(root root)))
(provide 'my/project)