Why to use separate terminal applications for remote connections when one can use Emacs? Why to run remote Emacs of different version, in different configuration, with echo delays, without your customizations, etc.? Why to pollute your desktop with another window and why to switch between it and Emacs all the time? Why to run multiple editors?
The only reason I didn’t simply use Tramp for remote connections was lack of command line completion. But that can be done with Tramp too, one just must configure it. rlogin.el
doesn’t seem to be directly useful for that purpose, but it’s useful for getting a clue. So I wrote a little hack:
(defun my-shell-directory-tracker (command) (when (string-match "^ssh " command) (make-local-variable 'comint-file-name-prefix) (let ((host (comint-substitute-in-file-name (comint-arguments command nil nil)))) (set (make-local-variable 'comint-file-name-prefix) (format "/%s:" host)) (set (make-local-variable 'comint-process-echoes) t) (cd-absolute (format "%s~" comint-file-name-prefix)) (rename-buffer (format "*shell:%s*" host))))) (add-hook 'comint-input-filter-functions 'my-shell-directory-tracker)
Now I can enjoy remote editing (both editing files and editing command lines) quite comfortably and without echo delays.
This hack is not perfect, but it has good usefulness/effort ratio. If you can improve it or know about a better solution, please tell me.
Leave a Reply