Make doom-project-{p,root} functions simpler

+ doom-project-root and doom-project-p no longer takes arguments
+ Remove doom*project-root advice
This commit is contained in:
Henrik Lissner 2017-09-20 01:33:25 +02:00
parent 77836e08b1
commit 3fcbdae441
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 10 additions and 16 deletions

View file

@ -53,7 +53,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
If no project is active, return all buffers."
(let ((buffers (doom-buffer-list)))
(if-let (project-root (doom-project-root t))
(if-let (project-root (if (doom-project-p) (doom-project-root)))
(cl-loop for buf in buffers
if (projectile-project-buffer-p buf project-root)
collect buf)

View file

@ -63,22 +63,17 @@ state are passed in.")
(dolist (fn projectile-project-root-files-functions)
(remhash (format "%s-%s" fn default-directory) projectile-project-root-cache)))
(defun doom-project-p (&optional strict-p)
(defun doom-project-p ()
"Whether or not this buffer is currently in a project or not."
(let ((projectile-require-project-root strict-p))
(let ((projectile-require-project-root t))
(projectile-project-p)))
(defun doom-project-root (&optional strict-p)
(defun doom-project-root ()
"Get the path to the root of your project.
If STRICT-P, return nil if no project was found, otherwise return
`default-directory'."
(let ((projectile-require-project-root strict-p))
(ignore-errors (projectile-project-root))))
(defun doom*project-root (&rest _)
"An advice function used to replace project-root-detection functions in other
libraries."
(doom-project-root))
(let (projectile-require-project-root)
(projectile-project-root)))
(defmacro doom-project-has! (files)
"Checks if the project has the specified FILES, relative to the project root,

View file

@ -88,7 +88,7 @@
:commands tern-mode
:init (add-hook 'js2-mode-hook #'tern-mode)
:config
(advice-add #'tern-project-dir :override #'doom*project-root))
(advice-add #'tern-project-dir :override #'doom-project-root))
(def-package! company-tern

View file

@ -41,8 +41,7 @@
(equal (file-name-extension buffer-file-name) "tsx")))
(tide-setup)
(flycheck-mode +1)
(eldoc-mode +1)))
(add-hook! (typescript-mode web-mode) #'+typescript|init-tide)
(advice-add #'tide-project-root :override #'doom*project-root))
(eldoc-mode +1)
(setq tide-project-root (doom-project-root))))
(add-hook! (typescript-mode web-mode) #'+typescript|init-tide))