Skip to content

Commit

Permalink
Added tramp support
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthverma314 committed Aug 17, 2020
1 parent f5484b0 commit 6a3b2b5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions direnv.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

(defun direnv--detect ()
"Detect the direnv executable."
(executable-find "direnv"))
(executable-find "direnv" t))

(defvar direnv--output-buffer-name "*direnv*"
"Name of the buffer filled with the last direnv output.")
Expand Down Expand Up @@ -101,8 +101,10 @@ use `default-directory', since there is no file name (or directory)."
(with-current-buffer (get-buffer-create direnv--output-buffer-name)
(erase-buffer)
(let* ((default-directory directory)
(process-environment environment)
(exit-code (call-process
(process-environment (if (file-remote-p default-directory)
tramp-remote-process-environment
environment))
(exit-code (process-file
direnv--executable nil
`(t ,stderr-tempfile) nil
"export" "json")))
Expand Down Expand Up @@ -241,8 +243,6 @@ When FORCE-SUMMARY is non-nil or when called interactively, show a summary messa
(items)
(summary)
(show-summary (or force-summary (called-interactively-p 'interactive))))
(when (file-remote-p directory)
(user-error "Cannot use direnv for remote files"))
(setq direnv--active-directory directory
items (direnv--export direnv--active-directory)
summary (direnv--summarise-changes items))
Expand All @@ -252,8 +252,13 @@ When FORCE-SUMMARY is non-nil or when called interactively, show a summary messa
(direnv--show-summary summary old-directory direnv--active-directory))
(dolist (pair items)
(let ((name (car pair))
(value (cdr pair)))
(value (cdr pair))
(process-environment (if (file-remote-p directory)
tramp-remote-process-environment
process-environment)))
(setenv name value)
(when (file-remote-p directory)
(setq tramp-remote-process-environment process-environment))
(when (string-equal name "PATH")
(setq exec-path (append (parse-colon-path value) (list exec-directory)))
;; Prevent `eshell-path-env` getting out-of-sync with $PATH:
Expand All @@ -264,7 +269,7 @@ When FORCE-SUMMARY is non-nil or when called interactively, show a summary messa
(defun direnv-allow ()
"Run ‘direnv allow’ and update the environment afterwards."
(interactive)
(call-process (direnv--detect) nil 0 nil "allow")
(process-file (direnv--detect) nil 0 nil "allow")
(direnv-update-environment))

;;;###autoload
Expand Down

0 comments on commit 6a3b2b5

Please sign in to comment.