aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sainty2018-05-04 01:29:42 +1200
committerPhil Sainty2018-06-04 11:10:21 +1200
commit03697e648c080f6b007b6ef8443fd4448bc52364 (patch)
treeba7d9eae1d5d21fa13d2ba9103289b0d0d6c10e3
parent16e8541b743a6beb1926fef53cf1bfaed9c346db (diff)
downloademacs-03697e648c080f6b007b6ef8443fd4448bc52364.tar.gz
emacs-03697e648c080f6b007b6ef8443fd4448bc52364.zip
Fix remote-host directory tracking for shells in `term' buffers
* lisp/term.el (term-handle-ansi-terminal-messages): Use an explicit tramp method when constructing the tramp path for a non-local host, as this is now mandatory. "-" is a pseudo-method for the user's `tramp-default-method'. (Bug#31355) Specify the remote username explicitly in all cases, as `tramp-default-user' and `tramp-default-user-alist' could cause the previous logic to fail. Minor related improvements to the commentary.
-rw-r--r--lisp/term.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/term.el b/lisp/term.el
index 75c27797838..419ddb2db5c 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -233,31 +233,33 @@
233;; 233;;
234;; Notice: for directory/host/user tracking you need to have something 234;; Notice: for directory/host/user tracking you need to have something
235;; like this in your shell startup script (this is for a POSIXish shell 235;; like this in your shell startup script (this is for a POSIXish shell
236;; like Bash but should be quite easy to port to other shells) 236;; like Bash but should be quite easy to port to other shells).
237;;
238;; For troubleshooting in Bash, you can check the definition of the
239;; custom functions with the "type" command. e.g. "type cd". If you
240;; do not see the expected definition from the config below, then the
241;; directory tracking will not work.
237;; 242;;
238;; ---------------------------------------- 243;; ----------------------------------------
239;; 244;;
240;; # Set HOSTNAME if not already set. 245;; # Set HOSTNAME if not already set.
241;; : ${HOSTNAME=$(uname -n)} 246;; : ${HOSTNAME=$(uname -n)}
242;; 247;;
243;; # su does not change this but I'd like it to 248;; # su does not change this but I'd like it to
244;;
245;; USER=$(whoami) 249;; USER=$(whoami)
246;; 250;;
247;; # ... 251;; # ...
248;; 252;;
249;; case $TERM in 253;; case $TERM in
250;; eterm*) 254;; eterm*)
251;; 255;;
252;; printf '%s\n' \ 256;; printf '%s\n' \
253;; -------------------------------------------------------------- \ 257;; -------------------------------------------------------------- \
254;; "Hello $user" \ 258;; "Hello $USER" \
255;; "Today is $(date)" \ 259;; "Today is $(date)" \
256;; "We are on $HOSTNAME running $(uname) under Emacs term mode" \ 260;; "We are on $HOSTNAME running $(uname) under Emacs term mode" \
257;; -------------------------------------------------------------- 261;; --------------------------------------------------------------
258;; 262;;
259;; export EDITOR=emacsclient
260;;
261;; # The \033 stands for ESC. 263;; # The \033 stands for ESC.
262;; # There is a space between "AnSiT?" and $whatever. 264;; # There is a space between "AnSiT?" and $whatever.
263;; 265;;
@@ -269,10 +271,11 @@
269;; printf '\033AnSiTh %s\n' "$HOSTNAME" 271;; printf '\033AnSiTh %s\n' "$HOSTNAME"
270;; printf '\033AnSiTu %s\n' "$USER" 272;; printf '\033AnSiTu %s\n' "$USER"
271;; 273;;
272;; eval $(dircolors $HOME/.emacs_dircolors) 274;; # Use custom dircolors in term buffers.
275;; # eval $(dircolors $HOME/.emacs_dircolors)
273;; esac 276;; esac
274;; 277;;
275;; # ... 278;; # ...
276;; 279;;
277;; 280;;
278 281
@@ -2750,12 +2753,10 @@ See `term-prompt-regexp'."
2750 (setq default-directory 2753 (setq default-directory
2751 (file-name-as-directory 2754 (file-name-as-directory
2752 (if (and (string= term-ansi-at-host (system-name)) 2755 (if (and (string= term-ansi-at-host (system-name))
2753 (string= term-ansi-at-user (user-real-login-name))) 2756 (string= term-ansi-at-user (user-real-login-name)))
2754 (expand-file-name term-ansi-at-dir) 2757 (expand-file-name term-ansi-at-dir)
2755 (if (string= term-ansi-at-user (user-real-login-name)) 2758 (concat "/-:" term-ansi-at-user "@" term-ansi-at-host ":"
2756 (concat "/" term-ansi-at-host ":" term-ansi-at-dir) 2759 term-ansi-at-dir))))
2757 (concat "/" term-ansi-at-user "@" term-ansi-at-host ":"
2758 term-ansi-at-dir)))))
2759 2760
2760 ;; I'm not sure this is necessary, 2761 ;; I'm not sure this is necessary,
2761 ;; but it's best to be on the safe side. 2762 ;; but it's best to be on the safe side.