From 8415a9d58fe90431a599f6f935141885319c40dc Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 15 Feb 2022 16:15:55 +0100 Subject: [PATCH] Some Tramp cleanup * doc/misc/tramp.texi (Remote processes): Add also tramp-sshfs.el. * lisp/net/tramp-adb.el (tramp-adb-handle-make-process): Error-out for multi-byte `default-directory'. * lisp/net/tramp.el (tramp-tolerate-tilde): Move it up. (tramp-handle-abbreviate-file-name): Use it. (tramp-read-passwd): Show literal passphrase prompt. --- doc/misc/tramp.texi | 4 ++-- lisp/net/tramp-adb.el | 6 +++++- lisp/net/tramp-sshfs.el | 2 +- lisp/net/tramp.el | 13 ++++++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 8ee4ab24cd7..ec9f07dc9ee 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -3960,8 +3960,8 @@ Furthermore, this approach has the following limitations: @itemize @item -It works only for connection methods defined in @file{tramp-sh.el} and -@file{tramp-adb.el}. +It works only for connection methods defined in @file{tramp-adb.el}, +@file{tramp-sh.el} and @file{tramp-sshfs.el}. @item It does not support interactive user authentication. With diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index c683f4c6e8a..a61179958ca 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -986,6 +986,10 @@ implementation will be used." (name1 name) (i 0)) + (when (string-match-p "[[:multibyte:]]" command) + (tramp-error + v 'file-error "Cannot apply multi-byte command `%s'" command)) + (while (get-process name1) ;; NAME must be unique as process name. (setq i (1+ i) @@ -1264,7 +1268,7 @@ connection if a previous connection has died for some reason." (if (zerop (length device)) (tramp-error vec 'file-error "Device %s not connected" host)) (with-tramp-progress-reporter vec 3 "Opening adb shell connection" - (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? + (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? (process-connection-type tramp-process-connection-type) (args (if (> (length host) 0) (list "-s" device "shell") diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index 3f23b1a8786..40c02ccea0d 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el @@ -240,7 +240,7 @@ arguments to pass to the OPERATION." (error "Implementation does not handle immediate return")) (with-parsed-tramp-file-name (expand-file-name default-directory) nil - (let ((coding-system-for-read 'utf-8-dos) ; Is this correct? + (let ((coding-system-for-read 'utf-8-dos) ; Is this correct? (command (format "cd %s && exec %s" diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3c06ad1630a..91c0efb4824 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3335,6 +3335,10 @@ User is always nil." (defvar tramp-handle-write-region-hook nil "Normal hook to be run at the end of `tramp-*-handle-write-region'.") +(defvar tramp-tolerate-tilde nil + "Indicator, that not expandable tilde shall be tolerated. +Let-bind it when necessary.") + ;; `directory-abbrev-apply' and `directory-abbrev-make-regexp' exists ;; since Emacs 29.1. Since this handler isn't called for older ;; Emacsen, it is save to invoke them via `tramp-compat-funcall'. @@ -3342,6 +3346,7 @@ User is always nil." "Like `abbreviate-file-name' for Tramp files." (let* ((case-fold-search (file-name-case-insensitive-p filename)) (vec (tramp-dissect-file-name filename)) + (tramp-tolerate-tilde t) (home-dir (if (let ((non-essential t)) (tramp-connectable-p vec)) ;; If a connection has already been established, make @@ -3466,10 +3471,6 @@ User is always nil." (if (file-directory-p dir) dir (file-name-directory dir)) nil (tramp-flush-directory-properties v localname))) -(defvar tramp-tolerate-tilde nil - "Indicator, that not expandable tilde shall be tolerated. -Let-bind it when necessary.") - (defun tramp-handle-expand-file-name (name &optional dir) "Like `expand-file-name' for Tramp files." ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". @@ -5756,7 +5757,9 @@ Consults the auth-source package." (or prompt (with-current-buffer (process-buffer proc) (tramp-check-for-regexp proc tramp-password-prompt-regexp) - (format "%s for %s " (capitalize (match-string 1)) key)))) + (if (string-match-p "passphrase" (match-string 1)) + (match-string 0) + (format "%s for %s " (capitalize (match-string 1)) key))))) (auth-source-creation-prompts `((secret . ,pw-prompt))) ;; Use connection-local value. (auth-sources (buffer-local-value 'auth-sources (process-buffer proc))) -- 2.39.5