Refactor Project API to reflect changes upstream

projectile-project-root no longer returns `default-directory` if not in
a project (it returns nil). As such, doom-project-* functions (and their
uses) have been refactored.

+ doom-project-p & doom-project-root are aliases for
  projectile-project-p & projectile-project-root.
+ doom-project-{p,root,name,expand} now has a DIR argument (for
  consistency, since projectile-project-name and
  projectile-project-expand do not).
+ The nocache parameter is no longer necessary, as projectile's caching
  behavior is now more sane.
+ Removed some projectile advice/hacks that are no longer necessary.
+ Updated unit tests
This commit is contained in:
Henrik Lissner 2018-09-28 13:54:20 -04:00
parent 3961ba1662
commit 53fe7a1f04
22 changed files with 53 additions and 84 deletions

View file

@ -38,33 +38,23 @@ they are absolute."
;; Library
;;;###autoload
(defun doom-project-p (&optional nocache)
"Return t if this buffer is currently in a project.
If NOCACHE, don't fetch a cached answer."
(if nocache
(without-project-cache! (doom-project-p nil))
(let ((projectile-require-project-root t))
(and (projectile-project-p) t))))
(defalias 'doom-project-p #'projectile-project-p)
;;;###autoload
(defun doom-project-name (&optional nocache)
"Return the name of the current project.
If NOCACHE, don't fetch a cached answer."
(if nocache
(without-project-cache! (doom-project-name nil))
(projectile-project-name)))
(defalias 'doom-project-root #'projectile-project-root)
;;;###autoload
(defun doom-project-root (&optional nocache)
"Returns the root of your project, or `default-directory' if none was found.
If NOCACHE, don't fetch a cached answer."
(if nocache
(without-project-cache! (doom-project-root nil))
(let (projectile-require-project-root)
(projectile-project-root))))
(defun doom-project-name (&optional dir)
"Return the name of the current project."
(let ((project-root (projectile-project-root dir)))
(if project-root
(funcall projectile-project-name-function project-root)
"-")))
;;;###autoload
(defalias 'doom-project-expand #'projectile-expand-root)
(defun doom-project-expand (name &optional dir)
"Expand NAME to project root."
(expand-file-name name (projectile-project-root dir)))
;;;###autoload
(defun doom-project-find-file (dir)