Skip to content

Commit

Permalink
Fix TRAMP issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Silex committed Apr 6, 2017
1 parent 0c307c8 commit 814e97a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@

### Changes

* [#1129](https://github.com/bbatsov/projectile/pull/1129): Fix TRAMP issues.
* Add R DESCRIPTION file to `projectile-project-root-files`.
* Ignore backup files in `projectile-get-other-files`.
* Ignore Ensime cache directory, `.ensime_cache`.
Expand Down
32 changes: 18 additions & 14 deletions projectile.el
Expand Up @@ -863,17 +863,23 @@ topmost sequence of matched directories. Nil otherwise."
(defun projectile-project-root ()
"Retrieves the root directory of a project if available.
The current directory is assumed to be the project's root otherwise."
(let ((dir default-directory))
(or (cl-some
(lambda (func)
(let* ((cache-key (format "%s-%s" func dir))
(cache-value (gethash cache-key projectile-project-root-cache)))
(if (and cache-value (file-exists-p cache-value))
cache-value
(let ((value (funcall func (file-truename dir))))
(puthash cache-key value projectile-project-root-cache)
value))))
projectile-project-root-files-functions)
;; The `is-local' and `is-connected' variables are used to fix the behavior where Emacs hangs
;; because of Projectile when you open a file over TRAMP. It basically prevents Projectile from trying
;; to find information about files for which it's not possible to get that information right now.
(let* ((dir default-directory)
(is-local (not (file-remote-p dir))) ;; `true' if the file is local
(is-connected (file-remote-p dir nil t))) ;; `true' if the file is remote AND we are connected to the remote
(or (when (or is-local is-connected)
(cl-some
(lambda (func)
(let* ((cache-key (format "%s-%s" func dir))
(cache-value (gethash cache-key projectile-project-root-cache)))
(if (and cache-value (file-exists-p cache-value))
cache-value
(let ((value (funcall func (file-truename dir))))
(puthash cache-key value projectile-project-root-cache)
value))))
projectile-project-root-files-functions))
(if projectile-require-project-root
(error "You're not in a project")
default-directory))))
Expand Down Expand Up @@ -3475,9 +3481,7 @@ is chosen."

;;;###autoload
(defcustom projectile-mode-line
'(:eval (if (file-remote-p default-directory)
" Projectile"
(format " Projectile[%s]" (projectile-project-name))))
'(:eval (format " Projectile[%s]" (projectile-project-name)))
"Mode line lighter for Projectile.
The value of this variable is a mode line template as in
Expand Down

0 comments on commit 814e97a

Please sign in to comment.