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

@ -45,30 +45,14 @@
projectile-project-root-files)
projectile-project-root-files-bottom-up nil)))
;; Restores the old behavior of `projectile-project-root', where it returns
;; `default-directory' if not in a project, at least until I update Doom to
;; deal with this.
;; FIXME Check again after https://github.com/bbatsov/projectile/issues/1296
(defun doom*projectile-project-root (project-root)
(or project-root
default-directory))
(advice-add #'projectile-project-root :filter-return #'doom*projectile-project-root)
;; Projectile root-searching functions can cause an infinite loop on TRAMP
;; connections, so disable them.
;; TODO Is this still necessary?
(defun doom*projectile-locate-dominating-file (orig-fn file name)
"Don't traverse the file system if on a remote connection."
(unless (file-remote-p default-directory)
(funcall orig-fn file name)))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
(defun doom*projectile-cache-current-file (orig-fn)
"Don't cache ignored files."
(unless (cl-loop for path in (projectile-ignored-directories)
if (string-prefix-p (or buffer-file-name "") (expand-file-name path))
return t)
(funcall orig-fn)))
(advice-add #'projectile-cache-current-file :around #'doom*projectile-cache-current-file))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file))
;;