doom-project-find-file: avoid helm-projectile #1274

helm-projectile-find-file misbehaves as a workspace project-switch
handler (likely because it runs asynchronously and misses the lexical
value of `default-directory`), so we avoid it and use
projectile-find-file directly (which still uses helm, just not the
helm-projectile package).
This commit is contained in:
Henrik Lissner 2019-03-26 03:38:37 -04:00
parent 379c01ba1e
commit c2d0cae6a5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -86,19 +86,24 @@ they are absolute."
;;;###autoload ;;;###autoload
(defun doom-project-find-file (dir) (defun doom-project-find-file (dir)
"Fuzzy-find a file under DIR." "Fuzzy-find a file under DIR."
(without-project-cache! (unless (file-directory-p dir)
(let* ((default-directory (file-truename dir)) (error "Directory %S does not exist" dir))
projectile-project-root) (let ((default-directory dir)
(call-interactively projectile-project-root)
;; completion modules may remap this command (call-interactively
(or (command-remapping #'projectile-find-file) ;; Intentionally avoid `helm-projectile-find-file', because it runs
#'projectile-find-file))))) ;; asynchronously, and thus doesn't see the lexical `default-directory'
(if (featurep! :completion ivy)
#'counsel-projectile-find-file
#'projectile-find-file))))
;;;###autoload ;;;###autoload
(defun doom-project-browse (dir) (defun doom-project-browse (dir)
"Traverse a file structure starting linearly from DIR." "Traverse a file structure starting linearly from DIR."
(let ((default-directory (file-truename dir))) (let ((default-directory (file-truename dir)))
(call-interactively (call-interactively
;; completion modules may remap this command (cond ((featurep! :completion ivy)
(or (command-remapping #'find-file) #'counsel-find-file)
#'find-file)))) ((featurep! :completion helm)
#'helm-find-files)
(#'find-file)))))