unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: bug-gnu-emacs
	<bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>,
	31355@debbugs.gnu.org
Subject: bug#31355: 26.1; [PATCH] Fix remote-host/tramp directory tracking for shells in `term' buffers
Date: Wed, 09 May 2018 00:52:12 +1200	[thread overview]
Message-ID: <bcf57324ac12f040f31fc0635bd4f010@webmail.orcon.net.nz> (raw)
In-Reply-To: <874ljn6ftt.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

On 2018-05-04 19:27, Michael Albinus wrote:
> And you cannot expect, that for all Tramp methods the default user is
> equal to `user-login-name'. This happened to ange-ftp, but it isn't the
> case in Tramp. See variables `tramp-default-user' and
> `tramp-default-user-alist'.

You're right, the explicit username is more robust.

Attaching a new patch with that fix included.


-Phil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-remote-host-directory-tracking-for-shells-in-ter.patch --]
[-- Type: text/x-diff; name=0001-Fix-remote-host-directory-tracking-for-shells-in-ter.patch, Size: 3292 bytes --]

From 806ab6f4ba730b26c05f3469a64da3a2223b32c5 Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
Date: Fri, 4 May 2018 01:29:42 +1200
Subject: [PATCH] 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'.

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.
---
 lisp/term.el | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index 75c2779..419ddb2 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -233,31 +233,33 @@
 ;;
 ;;  Notice: for directory/host/user tracking you need to have something
 ;; like this in your shell startup script (this is for a POSIXish shell
-;; like Bash but should be quite easy to port to other shells)
+;; like Bash but should be quite easy to port to other shells).
+;;
+;; For troubleshooting in Bash, you can check the definition of the
+;; custom functions with the "type" command.  e.g. "type cd".  If you
+;; do not see the expected definition from the config below, then the
+;; directory tracking will not work.
 ;;
 ;;             ----------------------------------------
 ;;
-;;  # Set HOSTNAME if not already set.
+;;	# Set HOSTNAME if not already set.
 ;;	: ${HOSTNAME=$(uname -n)}
 ;;
-;;  # su does not change this but I'd like it to
-;;
+;;	# su does not change this but I'd like it to
 ;;	USER=$(whoami)
 ;;
-;;  # ...
+;;	# ...
 ;;
 ;;	case $TERM in
 ;;	    eterm*)
 ;;
 ;;		printf '%s\n' \
 ;;		 -------------------------------------------------------------- \
-;;		 "Hello $user" \
+;;		 "Hello $USER" \
 ;;		 "Today is $(date)" \
 ;;		 "We are on $HOSTNAME running $(uname) under Emacs term mode" \
 ;;		 --------------------------------------------------------------
 ;;
-;;		export EDITOR=emacsclient
-;;
 ;;		# The \033 stands for ESC.
 ;;		# There is a space between "AnSiT?" and $whatever.
 ;;
@@ -269,10 +271,11 @@
 ;;		printf '\033AnSiTh %s\n' "$HOSTNAME"
 ;;		printf '\033AnSiTu %s\n' "$USER"
 ;;
-;;		eval $(dircolors $HOME/.emacs_dircolors)
+;;		# Use custom dircolors in term buffers.
+;;		# eval $(dircolors $HOME/.emacs_dircolors)
 ;;	esac
 ;;
-;;  # ...
+;;	# ...
 ;;
 ;;
 
@@ -2750,12 +2753,10 @@ term-handle-ansi-terminal-messages
 	(setq default-directory
 	      (file-name-as-directory
 	       (if (and (string= term-ansi-at-host (system-name))
-					(string= term-ansi-at-user (user-real-login-name)))
+                        (string= term-ansi-at-user (user-real-login-name)))
 		   (expand-file-name term-ansi-at-dir)
-		 (if (string= term-ansi-at-user (user-real-login-name))
-		     (concat "/" term-ansi-at-host ":" term-ansi-at-dir)
-		   (concat "/" term-ansi-at-user "@" term-ansi-at-host ":"
-			   term-ansi-at-dir)))))
+                 (concat "/-:" term-ansi-at-user "@" term-ansi-at-host ":"
+                         term-ansi-at-dir))))
 
 	;; I'm not sure this is necessary,
 	;; but it's best to be on the safe side.
-- 
2.8.3


  reply	other threads:[~2018-05-08 12:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 13:52 bug#31355: 26.1; [PATCH] Fix remote-host/tramp directory tracking for shells in `term' buffers Phil Sainty
2018-05-03 14:00 ` Phil Sainty
2018-05-03 14:04 ` Michael Albinus
2018-05-03 14:47   ` Phil Sainty
2018-05-03 14:59     ` Michael Albinus
2018-05-03 21:01       ` Phil Sainty
2018-05-04  7:27         ` Michael Albinus
2018-05-08 12:52           ` Phil Sainty [this message]
2018-05-08 17:43             ` Michael Albinus
2018-05-08 20:27               ` Phil Sainty
2018-06-03 23:40                 ` Phil Sainty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bcf57324ac12f040f31fc0635bd4f010@webmail.orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=31355@debbugs.gnu.org \
    --cc=bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).