Created
June 8, 2018 07:45
-
-
Save reedho/216bf2000edf2f9f2da265dc3bebaffc to your computer and use it in GitHub Desktop.
Monkey patching cider tramp can not connect remote ssh 08-Jun-2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ... | |
(defun cider--infer-ports (host ssh-hosts) | |
"Infer nREPL ports on HOST. | |
Return a list of elements of the form (directory port). SSH-HOSTS is a list | |
of remote SSH hosts." | |
(let ((localp (or (nrepl-local-host-p host) | |
(not (assoc-string host ssh-hosts))))) | |
(if localp | |
;; change dir: current file might be remote | |
(let* ((change-dir-p (file-remote-p default-directory)) | |
(default-directory (if change-dir-p "~/" default-directory))) | |
(cider-locate-running-nrepl-ports (unless change-dir-p default-directory))) | |
(let (;; (vec (vector "sshx" nil host "" nil)) ;; <---- NOT WORK ON EMACS 26.1, TRAMP "2.3.3.26.1" | |
(vec (tramp-dissect-file-name | |
(concat "/" (string-join | |
(remove nil (vector "sshx" nil host "" nil)) | |
":")))) | |
;; change dir: user might want to connect to a different remote | |
(dir (when (file-remote-p default-directory) | |
(with-parsed-tramp-file-name default-directory cur | |
(when (string= cur-host host) default-directory))))) | |
(tramp-maybe-open-connection vec) | |
(with-current-buffer (tramp-get-connection-buffer vec) | |
(cider-locate-running-nrepl-ports dir)))))) | |
;; ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment