emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/tramp 3704df8: Make Tramp snapshot


From: ELPA Syncer
Subject: [elpa] externals/tramp 3704df8: Make Tramp snapshot
Date: Tue, 21 Sep 2021 14:57:22 -0400 (EDT)

branch: externals/tramp
commit 3704df831dc9bbe75d3a365cf65c7c80a465e861
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Make Tramp snapshot
---
 README              |  15 +++++++-
 README-GIT          |   6 +--
 test/tramp-tests.el | 108 +++++++++++++++++++++++++++-------------------------
 texi/tramp.texi     |   5 ++-
 tramp-adb.el        |  10 +++--
 tramp-archive.el    |   4 +-
 tramp-cmds.el       |   4 +-
 tramp-compat.el     |  19 +++++----
 tramp-crypt.el      |  10 ++---
 tramp-ftp.el        |   6 +--
 tramp-fuse.el       |   6 +--
 tramp-gvfs.el       |  21 +++++-----
 tramp-sh.el         |  59 +++++++++++++++-------------
 tramp-smb.el        |  23 ++++++-----
 tramp-sshfs.el      |   2 +-
 tramp-sudoedit.el   |   5 ++-
 tramp.el            |  74 +++++++++++++++++++++--------------
 trampver.el         |   2 +-
 18 files changed, 216 insertions(+), 163 deletions(-)

diff --git a/README b/README
index 435900b..6ab3411 100644
--- a/README
+++ b/README
@@ -15,7 +15,20 @@ Most of the parts are optional, read the manual for details.
 Tramp must be compiled for the Emacs version you are running.  If you
 experience compatibility error messages for the Tramp package, or if
 you use another major Emacs version than the version Tramp has been
-installed with, you must recompile the package.  Run the command
+installed with, you must recompile the package (<version> is the
+version of the Tramp package):
+
+1. Remove all byte-compiled Tramp files
+
+  # rm -f ~/.emacs.d/elpa/tramp-<version>/tramp*.elc
+
+2. Start Emacs with Tramp's source files
+
+  # emacs -L ~/.emacs.d/elpa/tramp-<version> -l tramp
+
+This should not give you the error.
+
+3. Recompile the Tramp package *with this running Emacs instance*
 
   M-x tramp-recompile-elpa
 
diff --git a/README-GIT b/README-GIT
index 5dab910..76976d0 100644
--- a/README-GIT
+++ b/README-GIT
@@ -1,5 +1,5 @@
-This is the local Tramp repository, branch externals/tramp. It has two
-remotes, "origin" and "elpa". They are pulled/pushed like this:
+This is the local Tramp repository, branch externals/tramp.  It has two
+remotes, "origin" and "elpa".  They are pulled/pushed like this:
 
 # git pull origin
 # git push origin
@@ -7,6 +7,6 @@ remotes, "origin" and "elpa". They are pulled/pushed like this:
 # git pull elpa externals/tramp
 # git push elpa externals/tramp
 
-These commands do not apply to the local ELPA repository. This uses
+These commands do not apply to the local ELPA repository.  This uses
 "git pull; make externals" for a pull; a push for the Tramp part is
 not expected.
diff --git a/test/tramp-tests.el b/test/tramp-tests.el
index a7a8ec8..4c452ed 100644
--- a/test/tramp-tests.el
+++ b/test/tramp-tests.el
@@ -2083,7 +2083,7 @@ Also see `ignore'."
       "/method:host:/:/path//foo"))
 
     ;; Forwhatever reasons, the following tests let Emacs crash for
-    ;; Emacs 25, occasionally. No idea what's up.
+    ;; Emacs 25, occasionally.  No idea what's up.
     (when (tramp--test-emacs26-p)
       (should
        (string-equal
@@ -2772,21 +2772,31 @@ This tests also `file-directory-p' and 
`file-accessible-directory-p'."
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
-          (tmp-name2 (expand-file-name "foo/bar" tmp-name1)))
+          (tmp-name2 (expand-file-name "foo/bar" tmp-name1))
+          (unusual-file-mode-1 #o740)
+          (unusual-file-mode-2 #o710))
       (unwind-protect
          (progn
-           (make-directory tmp-name1)
+           (with-file-modes unusual-file-mode-1
+             (make-directory tmp-name1))
            (should-error
             (make-directory tmp-name1)
             :type 'file-already-exists)
            (should (file-directory-p tmp-name1))
            (should (file-accessible-directory-p tmp-name1))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-1)
+                            (format "%#o" (file-modes tmp-name1)))))
            (should-error
             (make-directory tmp-name2)
             :type 'file-error)
-           (make-directory tmp-name2 'parents)
+           (with-file-modes unusual-file-mode-2
+             (make-directory tmp-name2 'parents))
            (should (file-directory-p tmp-name2))
            (should (file-accessible-directory-p tmp-name2))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-2)
+                            (format "%#o" (file-modes tmp-name2)))))
            ;; If PARENTS is non-nil, `make-directory' shall not
            ;; signal an error when DIR exists already.
            (make-directory tmp-name2 'parents))
@@ -3590,14 +3600,7 @@ They might differ only in time attributes or directory 
size."
   "Check `file-modes'.
 This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
   (skip-unless (tramp--test-enabled))
-  (skip-unless
-   (or (tramp--test-sh-p) (tramp--test-sshfs-p) (tramp--test-sudoedit-p)
-       ;; Not all tramp-gvfs.el methods support changing the file mode.
-       (and
-       (tramp--test-gvfs-p)
-       (string-match-p
-        "ftp" (file-remote-p tramp-test-temporary-file-directory 'method)))))
-
+  (skip-unless (tramp--test-supports-file-modes-p))
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
          (tmp-name2 (tramp--test-make-temp-name nil quoted)))
@@ -4281,12 +4284,8 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
            ;; for completion.  We must refill the cache.
            (tramp-set-connection-property tramp-test-vec "property" nil)
 
-            (let ;; This is needed for the `simplified' syntax.
-                ((method-marker
-                  (if (zerop (length tramp-method-regexp))
-                      "" tramp-default-method-marker))
-                 ;; This is needed for the `separate' syntax.
-                 (prefix-format (substring tramp-prefix-format 1))
+            (let ;; This is needed for the `separate' syntax.
+                ((prefix-format (substring tramp-prefix-format 1))
                 ;; This is needed for the IPv6 host name syntax.
                 (ipv6-prefix
                  (and (string-match-p tramp-ipv6-regexp host)
@@ -4302,22 +4301,6 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
                  (concat prefix-format method tramp-postfix-method-format)
                  (file-name-all-completions
                    (concat prefix-format (substring method 0 1)) "/"))))
-              ;; Complete host name for default method.  With gvfs
-              ;; based methods, host name will be determined as
-              ;; host.local, so we omit the test.
-             (let ((tramp-default-method (or method tramp-default-method)))
-               (unless (or (zerop (length host))
-                           (tramp--test-gvfs-p tramp-default-method))
-                 (should
-                  (member
-                   (concat
-                     prefix-format method-marker tramp-postfix-method-format
-                    ipv6-prefix host ipv6-postfix tramp-postfix-host-format)
-                   (file-name-all-completions
-                    (concat
-                      prefix-format method-marker tramp-postfix-method-format
-                     ipv6-prefix (substring host 0 1))
-                     "/")))))
               ;; Complete host name.
              (unless (or (zerop (length method))
                           (zerop (length tramp-method-regexp))
@@ -4481,7 +4464,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (should (string-equal (format "%s\n" fnnd) (buffer-string)))
              (should-not (get-buffer-window (current-buffer) t))
 
-             ;; Second run. The output must be appended.
+             ;; Second run.  The output must be appended.
              (goto-char (point-max))
              (should (zerop (process-file "ls" nil t t fnnd)))
              ;; `ls' could produce colorized output.
@@ -4579,6 +4562,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
 
       ;; Process connection type.
       (when (and (tramp--test-sh-p)
+                (not (tramp-direct-async-process-p))
                 ;; `executable-find' has changed the number of
                 ;; parameters in Emacs 27.1, so we use `apply' for
                 ;; older Emacsen.
@@ -4604,8 +4588,10 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
                (should
                 (string-match-p
                  (if (memq process-connection-type '(nil pipe))
-                     "66\n6F\n6F\n0D\n0A\n"
-                   "66\n6F\n6F\n0A\n0A\n")
+                     ;; `telnet' converts \r to <CR><NUL> if `crlf'
+                     ;; flag is FALSE.  See telnet(1) man page.
+                     "66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
+                   "66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
                  (buffer-string))))
 
            ;; Cleanup.
@@ -4635,8 +4621,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
   "Define ert test `TEST-direct-async' for direct async processes.
 If UNSTABLE is non-nil, the test is tagged as `:unstable'."
   (declare (indent 1))
-  ;; `make-process' supports file name handlers since Emacs 27.
-  (when (let ((file-name-handler-alist '(("" . #'tramp--test-always))))
+  ;; `make-process' supports file name handlers since Emacs 27.  We
+  ;; cannot use `tramp--test-always' during compilation of the macro.
+  (when (let ((file-name-handler-alist '(("" . (lambda (&rest _) t)))))
          (ignore-errors (make-process :file-handler t)))
     `(ert-deftest ,(intern (concat (symbol-name test) "-direct-async")) ()
        ,docstring
@@ -4769,8 +4756,9 @@ If UNSTABLE is non-nil, the test is tagged as 
`:unstable'."
        ;; Cleanup.
        (ignore-errors (delete-process proc)))
 
-      ;; Process with stderr buffer.
-      (unless (tramp-direct-async-process-p)
+      ;; Process with stderr buffer.  `telnet' does not cooperate with
+      ;; three processes.
+      (unless (or (tramp--test-telnet-p) (tramp-direct-async-process-p))
        (let ((stderr (generate-new-buffer "*stderr*")))
          (unwind-protect
              (with-temp-buffer
@@ -4829,6 +4817,7 @@ If UNSTABLE is non-nil, the test is tagged as 
`:unstable'."
 
       ;; Process connection type.
       (when (and (tramp--test-sh-p)
+                (not (tramp-direct-async-process-p))
                 ;; `executable-find' has changed the number of
                 ;; parameters in Emacs 27.1, so we use `apply' for
                 ;; older Emacsen.
@@ -4865,8 +4854,10 @@ If UNSTABLE is non-nil, the test is tagged as 
`:unstable'."
                   (string-match-p
                    (if (memq (or connection-type process-connection-type)
                              '(nil pipe))
-                       "66\n6F\n6F\n0D\n0A\n"
-                     "66\n6F\n6F\n0A\n0A\n")
+                       ;; `telnet' converts \r to <CR><NUL> if `crlf'
+                       ;; flag is FALSE.  See telnet(1) man page.
+                       "66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
+                     "66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
                    (buffer-string))))
 
              ;; Cleanup.
@@ -5512,9 +5503,9 @@ Use direct async.")
           ;; Ignore trailing newline.
          (setq path (substring (shell-command-to-string "echo $PATH") nil -1))
          ;; The shell doesn't handle such long strings.
-         (unless (<= (length path)
-                     (tramp-get-connection-property
-                      tramp-test-vec "pipe-buf" 4096))
+         (when (<= (length path)
+                   (tramp-get-connection-property
+                    tramp-test-vec "pipe-buf" 4096))
            ;; The last element of `exec-path' is `exec-directory'.
             (should
             (string-equal
@@ -6168,6 +6159,12 @@ This requires restrictions of file name syntax."
   "Check, whether the sudoedit method is used."
   (tramp-sudoedit-file-name-p tramp-test-temporary-file-directory))
 
+(defun tramp--test-telnet-p ()
+  "Check, whether the telnet method is used.
+This does not support special file names."
+  (string-equal
+   "telnet" (file-remote-p tramp-test-temporary-file-directory 'method)))
+
 (defun tramp--test-windows-nt-p ()
   "Check, whether the locale host runs MS Windows."
   (eq system-type 'windows-nt))
@@ -6189,6 +6186,17 @@ This requires restrictions of file name syntax."
 This requires restrictions of file name syntax."
   (tramp-smb-file-name-p tramp-test-temporary-file-directory))
 
+(defun tramp--test-supports-file-modes-p ()
+  "Return whether the method under test supports file modes."
+  ;; "smb" does not unless the SMB server supports "posix" extensions.
+  ;; "adb" does not unless the Android device is rooted.
+  (or (tramp--test-sh-p) (tramp--test-sshfs-p) (tramp--test-sudoedit-p)
+      ;; Not all tramp-gvfs.el methods support changing the file mode.
+      (and
+       (tramp--test-gvfs-p)
+       (string-match-p
+       "ftp" (file-remote-p tramp-test-temporary-file-directory 'method)))))
+
 (defun tramp--test-check-files (&rest files)
   "Run a simple but comprehensive test over every file in FILES."
   ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
@@ -6715,6 +6723,7 @@ process sentinels.  They shall not disturb each other."
                   (tramp--test-sh-p)))
   (skip-unless (not (tramp--test-crypt-p)))
   (skip-unless (not (tramp--test-docker-p)))
+  (skip-unless (not (tramp--test-telnet-p)))
   (skip-unless (not (tramp--test-windows-nt-p)))
 
   (with-timeout
@@ -6752,11 +6761,6 @@ process sentinels.  They shall not disturb each other."
             (cond
              ((getenv "EMACS_HYDRA_CI") 10)
              (t 1)))
-           ;; We must distinguish due to performance reasons.
-           (timer-operation
-            (cond
-             ((tramp--test-mock-p) #'vc-registered)
-             (t #'file-attributes)))
           ;; This is when all timers start.  We check inside the
           ;; timer function, that we don't exceed timeout.
           (timer-start (current-time))
@@ -6792,7 +6796,7 @@ process sentinels.  They shall not disturb each other."
                           (cons 'remote-file-error debug-ignored-errors)))
                       (tramp--test-message
                        "Start timer %s %s" file (current-time-string))
-                     (funcall timer-operation file)
+                     (vc-registered file)
                       (tramp--test-message
                        "Stop timer %s %s" file (current-time-string))
                       ;; Adjust timer if it takes too much time.
diff --git a/texi/tramp.texi b/texi/tramp.texi
index 817cea2..e7b1995 100644
--- a/texi/tramp.texi
+++ b/texi/tramp.texi
@@ -3231,7 +3231,10 @@ directory @file{/sbin} on your local host.
 Type @kbd{s h @value{postfixhop}} for the minibuffer completion to
 @samp{@value{prefix}ssh@value{postfixhop}}.  Typing @kbd{@key{TAB}}
 shows host names @value{tramp} extracts from @file{~/.ssh/config}
-file, for example.
+@c bug#50387
+file, for example@footnote{Some completion styles, like
+@code{substring} or @code{flex}, require to type at least one
+character after the trailing @samp{@value{postfixhop}}.}.
 
 @example
 @group
diff --git a/tramp-adb.el b/tramp-adb.el
index 70dbfdb..d68d4c7 100644
--- a/tramp-adb.el
+++ b/tramp-adb.el
@@ -361,7 +361,7 @@ arguments to pass to the OPERATION."
     (tramp-message vec 5 "Finding a suitable `ls' command")
     (cond
      ;; Support Android derived systems where "ls" command is provided
-     ;; by GNU Coreutils. Force "ls" to print one column and set
+     ;; by GNU Coreutils.  Force "ls" to print one column and set
      ;; time-style to imitate other "ls" flavors.
      ((tramp-adb-send-command-and-check
        vec (concat "ls --time-style=long-iso "
@@ -442,7 +442,9 @@ Emacs dired can't find files."
          (make-directory par parents))))
     (tramp-flush-directory-properties v localname)
     (unless (or (tramp-adb-send-command-and-check
-                v (format "mkdir %s" (tramp-shell-quote-argument localname)))
+                v (format "mkdir -m %#o %s"
+                          (default-file-modes)
+                          (tramp-shell-quote-argument localname)))
                (and parents (file-directory-p dir)))
       (tramp-error v 'file-error "Couldn't make directory %s" dir))))
 
@@ -546,7 +548,7 @@ But handle the case, if the \"test\" command is not 
available."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -1271,7 +1273,7 @@ connection if a previous connection has died for some 
reason."
                           (list "-s" device "shell")
                         (list "shell")))
                 (p (let ((default-directory
-                           (tramp-compat-temporary-file-directory)))
+                           tramp-compat-temporary-file-directory))
                      (apply #'start-process (tramp-get-connection-name vec) buf
                             tramp-adb-program args)))
                 (prompt (md5 (concat (prin1-to-string process-environment)
diff --git a/tramp-archive.el b/tramp-archive.el
index 67798e8..b282359 100644
--- a/tramp-archive.el
+++ b/tramp-archive.el
@@ -190,7 +190,7 @@ It must be supported by libarchive(3).")
 
 ;; In older Emacsen (prior 27.1), `tramp-archive-autoload-file-name-regexp'
 ;; is not autoloaded.  So we cannot expect it to be known in
-;; tramp-loaddefs.el. But it exists, when tramp-archive.el is loaded.
+;; tramp-loaddefs.el.  But it exists, when tramp-archive.el is loaded.
 ;;;###tramp-autoload
 (defconst tramp-archive-file-name-regexp
   (ignore-errors (tramp-archive-autoload-file-name-regexp))
@@ -658,7 +658,7 @@ offered."
   ;; mounted directory, it is returned as it.  Not what we want.
   (with-parsed-tramp-archive-file-name default-directory nil
     (let ((default-directory (file-name-directory archive)))
-      (tramp-compat-temporary-file-directory))))
+      (tramp-compat-temporary-file-directory-function))))
 
 (defun tramp-archive-handle-not-implemented (operation &rest args)
   "Generic handler for operations not implemented for file archives."
diff --git a/tramp-cmds.el b/tramp-cmds.el
index 6278fd3..bfd9287 100644
--- a/tramp-cmds.el
+++ b/tramp-cmds.el
@@ -312,7 +312,7 @@ The remote connection identified by SOURCE is flushed by
      (if (null connections)
         (tramp-user-error nil "There are no remote connections.")
        (setq source
-            ;; Likely, the source remote connection is broken. So we
+            ;; Likely, the source remote connection is broken.  So we
             ;; shall avoid any action on it.
             (let (non-essential)
               (completing-read-default
@@ -717,7 +717,7 @@ the debug buffer(s).")
        (setq buffer-read-only t)
        (goto-char (point-min))
 
-       (when (y-or-n-p "Do you want to append the buffer(s)? ")
+       (when (y-or-n-p "Do you want to append the buffer(s)?")
          ;; OK, let's send.  First we delete the buffer list.
          (kill-buffer nil)
          (switch-to-buffer curbuf)
diff --git a/tramp-compat.el b/tramp-compat.el
index 6ac0b89..d20d3db 100644
--- a/tramp-compat.el
+++ b/tramp-compat.el
@@ -63,25 +63,24 @@
   `(when (functionp ,function)
      (with-no-warnings (funcall ,function ,@arguments))))
 
-(defsubst tramp-compat-temporary-file-directory ()
-  "Return name of directory for temporary files.
-It is the default value of `temporary-file-directory'."
-  ;; We must return a local directory.  If it is remote, we could run
-  ;; into an infloop.
-  (eval (car (get 'temporary-file-directory 'standard-value)) t))
+;; We must use a local directory.  If it is remote, we could run into
+;; an infloop.
+(defconst tramp-compat-temporary-file-directory
+  (eval (car (get 'temporary-file-directory 'standard-value)) t)
+  "The default value of `temporary-file-directory'.")
 
 (defsubst tramp-compat-make-temp-name ()
   "Generate a local temporary file name (compat function)."
   (make-temp-name
    (expand-file-name
-    tramp-temp-name-prefix (tramp-compat-temporary-file-directory))))
+    tramp-temp-name-prefix tramp-compat-temporary-file-directory)))
 
 (defsubst tramp-compat-make-temp-file (f &optional dir-flag)
   "Create a local temporary file (compat function).
 Add the extension of F, if existing."
   (make-temp-file
    (expand-file-name
-    tramp-temp-name-prefix (tramp-compat-temporary-file-directory))
+    tramp-temp-name-prefix tramp-compat-temporary-file-directory)
    dir-flag (file-name-extension f t)))
 
 ;; `temporary-file-directory' as function is introduced with Emacs 26.1.
@@ -384,10 +383,10 @@ CONDITION can also be a list of error conditions."
 (defalias 'tramp-compat-string-replace
   (if (fboundp 'string-replace)
       #'string-replace
-    (lambda (fromstring tostring instring)
+    (lambda (from-string to-string in-string)
       (let ((case-fold-search nil))
         (replace-regexp-in-string
-         (regexp-quote fromstring) tostring instring t t)))))
+         (regexp-quote from-string) to-string in-string t t)))))
 
 ;; Function `string-search' is new in Emacs 28.1.
 (defalias 'tramp-compat-string-search
diff --git a/tramp-crypt.el b/tramp-crypt.el
index fdb2907..5def3a4 100644
--- a/tramp-crypt.el
+++ b/tramp-crypt.el
@@ -247,7 +247,7 @@ Operations not mentioned here will be handled by the 
default Emacs primitives.")
     (unless (tramp-crypt-file-name-p tfnfo)
       (setq tfnfo (apply
                   #'tramp-file-name-for-operation operation
-                  (cons (tramp-compat-temporary-file-directory) (cdr args)))))
+                  (cons tramp-compat-temporary-file-directory (cdr args)))))
     tfnfo))
 
 (defun tramp-crypt-run-real-handler (operation args)
@@ -329,7 +329,7 @@ connection if a previous connection has died for some 
reason."
          (copy-file remote-config local-config 'ok 'keep)
 
        ;; Create local encfs6 config file otherwise.
-       (let* ((default-directory (tramp-compat-temporary-file-directory))
+       (let* ((default-directory tramp-compat-temporary-file-directory)
               (tmpdir1 (file-name-as-directory
                         (tramp-compat-make-temp-file " .crypt" 'dir-flag)))
               (tmpdir2 (file-name-as-directory
@@ -383,7 +383,7 @@ ARGS are the arguments.  It returns t if ran successful, 
and nil otherwise."
   (with-temp-buffer
     (let* (;; Don't check for a proper method.
           (non-essential t)
-          (default-directory (tramp-compat-temporary-file-directory))
+          (default-directory tramp-compat-temporary-file-directory)
           ;; We cannot add it to `process-environment', because
           ;; `tramp-call-process-region' doesn't use it.
           (encfs-config
@@ -427,7 +427,7 @@ Otherwise, return NAME."
              crypt-vec localname (concat (symbol-name op) "-file-name")
            (unless (tramp-crypt-send-command
                     crypt-vec (if (eq op 'encrypt) "encode" "decode")
-                    (tramp-compat-temporary-file-directory) localname)
+                    tramp-compat-temporary-file-directory localname)
              (tramp-error
               crypt-vec 'file-error "%s of file name %s failed."
               (if (eq op 'encrypt) "Encoding" "Decoding") name))
@@ -517,7 +517,7 @@ kept in their encrypted form."
              tramp-crypt-encfs-config
              (directory-files name nil directory-files-no-dot-files-regexp))
             (yes-or-no-p
-             "There exist encrypted files, do you want to continue? "))
+             "There exist encrypted files, do you want to continue?"))
     (setq tramp-crypt-directories (delete name tramp-crypt-directories))
     (tramp-register-file-name-handlers)))
 
diff --git a/tramp-ftp.el b/tramp-ftp.el
index 85af1c0..c5f6153 100644
--- a/tramp-ftp.el
+++ b/tramp-ftp.el
@@ -121,9 +121,9 @@ pass to the OPERATION."
                 (nth 2 tramp-file-name-structure)
                 (nth 4 tramp-file-name-structure)))
          ;; ange-ftp uses `ange-ftp-ftp-name-arg' and `ange-ftp-ftp-name-res'
-         ;; for optimization in `ange-ftp-ftp-name'. If Tramp wasn't active,
+         ;; for optimization in `ange-ftp-ftp-name'.  If Tramp wasn't active,
          ;; there could be incorrect values from previous calls in case the
-         ;; "ftp" method is used in the Tramp file name. So we unset
+         ;; "ftp" method is used in the Tramp file name.  So we unset
          ;; those values.
          (ange-ftp-ftp-name-arg "")
          (ange-ftp-ftp-name-res nil)
@@ -138,7 +138,7 @@ pass to the OPERATION."
 
       (cond
        ;; If argument is a symlink, `file-directory-p' and
-       ;; `file-exists-p' call the traversed file recursively. So we
+       ;; `file-exists-p' call the traversed file recursively.  So we
        ;; cannot disable the file-name-handler this case.  We set the
        ;; connection property "started" in order to put the remote
        ;; location into the cache, which is helpful for further
diff --git a/tramp-fuse.el b/tramp-fuse.el
index 93b184a..8c5afa7 100644
--- a/tramp-fuse.el
+++ b/tramp-fuse.el
@@ -154,7 +154,7 @@
        (when (tramp-file-name-user vec)
          (concat (tramp-file-name-user-domain vec) "@"))
        (tramp-file-name-host-port vec))
-       (tramp-compat-temporary-file-directory))))
+       tramp-compat-temporary-file-directory)))
 
 (defun tramp-fuse-mounted-p (vec)
   "Check, whether fuse volume determined by VEC is mounted."
@@ -163,7 +163,7 @@
     ;; to cache a nil result.
     (or (tramp-get-connection-property
          (tramp-get-connection-process vec) "mounted" nil)
-        (let* ((default-directory (tramp-compat-temporary-file-directory))
+        (let* ((default-directory tramp-compat-temporary-file-directory)
                (command (format "mount -t fuse.%s" (tramp-file-name-method 
vec)))
               (mount (shell-command-to-string command)))
           (tramp-message vec 6 "%s\n%s" command mount)
@@ -177,7 +177,7 @@
 
 (defun tramp-fuse-unmount (vec)
   "Unmount fuse volume determined by VEC."
-  (let ((default-directory (tramp-compat-temporary-file-directory))
+  (let ((default-directory tramp-compat-temporary-file-directory)
         (command (format "fusermount3 -u %s" (tramp-fuse-mount-point vec))))
     (tramp-message vec 6 "%s\n%s" command (shell-command-to-string command))
     (tramp-flush-connection-property
diff --git a/tramp-gvfs.el b/tramp-gvfs.el
index e4f54cf..5f0e7bc 100644
--- a/tramp-gvfs.el
+++ b/tramp-gvfs.el
@@ -1574,10 +1574,13 @@ If FILE-SYSTEM is non-nil, return file system 
attributes."
        (when (and parents (not (file-directory-p ldir)))
          (make-directory ldir parents))
        ;; Just do it.
-       (unless (or (tramp-gvfs-send-command
-                    v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))
-                   (and parents (file-directory-p dir)))
-         (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
+       (or (when-let ((mkdir-succeeded
+                       (tramp-gvfs-send-command
+                        v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
+             (set-file-modes dir (default-file-modes))
+             mkdir-succeeded)
+           (and parents (file-directory-p dir))
+           (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
 
 (defun tramp-gvfs-handle-rename-file
   (filename newname &optional ok-if-already-exists)
@@ -1812,10 +1815,8 @@ a downcased host name only."
                             (message "%s" message)
                           (pop-to-buffer (current-buffer)))
                         (if (yes-or-no-p
-                             (concat
-                              (buffer-substring
-                               (line-beginning-position) (point))
-                              " "))
+                             (buffer-substring
+                              (line-beginning-position) (point)))
                             0 1)))))
 
                ;; When QUIT is raised, we shall return this
@@ -1837,7 +1838,7 @@ a downcased host name only."
   (ignore-errors
     (let ((signal-name (dbus-event-member-name last-input-event))
          (elt mount-info))
-      ;; Jump over the first elements of the mount info. Since there
+      ;; Jump over the first elements of the mount info.  Since there
       ;; were changes in the entries, we cannot access dedicated
       ;; elements.
       (while (stringp (car elt)) (setq elt (cdr elt)))
@@ -1933,7 +1934,7 @@ a downcased host name only."
              :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
              tramp-gvfs-interface-mounttracker tramp-gvfs-listmounts))
          nil)
-       ;; Jump over the first elements of the mount info. Since there
+       ;; Jump over the first elements of the mount info.  Since there
        ;; were changes in the entries, we cannot access dedicated
        ;; elements.
        (while (stringp (car elt)) (setq elt (cdr elt)))
diff --git a/tramp-sh.el b/tramp-sh.el
index a2bf0af..18599f7 100644
--- a/tramp-sh.el
+++ b/tramp-sh.el
@@ -202,7 +202,7 @@ The string is used in `tramp-methods'.")
                 (tramp-copy-program         "rsync")
                 (tramp-copy-args            (("-t" "%k") ("-p") ("-r") ("-s")
                                             ("-c")))
-                (tramp-copy-env             (("RSYNC_RSH") ("ssh" "%c")))
+                (tramp-copy-env             (("RSYNC_RSH") ("ssh") ("%c")))
                 (tramp-copy-keep-date       t)
                 (tramp-copy-keep-tmpfile    t)
                 (tramp-copy-recursive       t)))
@@ -280,13 +280,14 @@ The string is used in `tramp-methods'.")
                 (tramp-connection-timeout   10)))
  (add-to-list 'tramp-methods
               `("sudo"
-                (tramp-login-program        "sudo")
+                (tramp-login-program        "env")
                 ;; The password template must be masked.  Otherwise,
                 ;; it could be interpreted as password prompt if the
                 ;; remote host echoes the command.
-                (tramp-login-args           (("-u" "%u") ("-s") ("-H")
-                                            ("-p" 
"P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":")
-                                             ("%l")))
+               ;; The "-p" argument doesn't work reliably, see Bug#50594.
+                (tramp-login-args           
(("SUDO_PROMPT=P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":")
+                                             ("sudo") ("-u" "%u") ("-s") ("-H")
+                                            ("%l")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
@@ -1063,7 +1064,7 @@ component is used as the target of the symlink."
                         (not
                          (yes-or-no-p
                           (format
-                           "File %s already exists; make it a link anyway? "
+                           "File %s already exists; make it a link anyway?"
                            localname)))))
                (tramp-error v 'file-already-exists localname)
              (delete-file linkname)))
@@ -1072,7 +1073,7 @@ component is used as the target of the symlink."
 
          ;; Right, they are on the same host, regardless of user,
          ;; method, etc.  We now make the link on the remote
-         ;; machine. This will occur as the user that TARGET belongs to.
+         ;; machine.  This will occur as the user that TARGET belongs to.
          (and (tramp-send-command-and-check
                v (format "cd %s" (tramp-shell-quote-argument cwd)))
                (tramp-send-command-and-check
@@ -1824,7 +1825,7 @@ ID-FORMAT valid values are `string' and `integer'."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              v2-localname)))))
              (tramp-error v2 'file-already-exists newname)
            (delete-file newname)))
@@ -2230,7 +2231,7 @@ the uid and gid from FILENAME."
                ;; Save exit.
                (ignore-errors (delete-file tmpfile)))))))))
 
-      ;; Set the time and mode. Mask possible errors.
+      ;; Set the time and mode.  Mask possible errors.
       (ignore-errors
          (when keep-date
            (tramp-compat-set-file-times
@@ -2390,7 +2391,7 @@ The method used must be an out-of-band method."
                 ;; can be handled.  We don't set a timeout, because
                 ;; the copying of large files can last longer than 60
                 ;; secs.
-                p (let ((default-directory 
(tramp-compat-temporary-file-directory)))
+                p (let ((default-directory 
tramp-compat-temporary-file-directory))
                     (apply
                      #'start-process
                      (tramp-get-connection-name v)
@@ -2449,8 +2450,9 @@ The method used must be an out-of-band method."
     (tramp-flush-directory-properties
      v (if parents "/" (file-name-directory localname)))
     (tramp-barf-unless-okay
-     v (format "%s %s"
+     v (format "%s -m %#o %s"
               (if parents "mkdir -p" "mkdir")
+              (default-file-modes)
               (tramp-shell-quote-argument localname))
      "Couldn't make directory %s" dir)))
 
@@ -2738,7 +2740,7 @@ the result will be a local, non-Tramp, file name."
        ;; `expand-file-name' (this does "/./" and "/../").
        ;; `default-directory' is bound, because on Windows there
        ;; would be problems with UNC shares or Cygwin mounts.
-       (let ((default-directory (tramp-compat-temporary-file-directory)))
+       (let ((default-directory tramp-compat-temporary-file-directory))
          (tramp-make-tramp-file-name
           v (tramp-drop-volume-letter
              (tramp-run-real-handler
@@ -2746,7 +2748,7 @@ the result will be a local, non-Tramp, file name."
 
 ;;; Remote commands:
 
-;; We use BUFFER also as connection buffer during setup. Because of
+;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-sh-handle-make-process (&rest args)
@@ -3219,7 +3221,7 @@ implementation will be used."
                  (let (file-name-handler-alist
                        (coding-system-for-write 'binary)
                        (default-directory
-                         (tramp-compat-temporary-file-directory)))
+                         tramp-compat-temporary-file-directory))
                    (with-temp-file tmpfile
                      (set-buffer-multibyte nil)
                      (insert-buffer-substring (tramp-get-buffer v))
@@ -3267,7 +3269,7 @@ implementation will be used."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -3312,8 +3314,7 @@ implementation will be used."
               ;; we use it always because this makes the logic
               ;; simpler.  We must also set `temporary-file-directory',
               ;; because it could point to a remote directory.
-              (temporary-file-directory
-               (tramp-compat-temporary-file-directory))
+              (temporary-file-directory tramp-compat-temporary-file-directory)
               (tmpfile (or tramp-temp-buffer-file-name
                            (tramp-compat-make-temp-file filename))))
 
@@ -3406,7 +3407,7 @@ implementation will be used."
                          ;; question is a tmp file anyway.
                          (let ((coding-system-for-read 'binary)
                                (default-directory
-                                 (tramp-compat-temporary-file-directory)))
+                                 tramp-compat-temporary-file-directory))
                            (insert-file-contents-literally tmpfile)
                            (funcall loc-enc (point-min) (point-max)))
 
@@ -3998,7 +3999,7 @@ Returns the absolute file name of PROGNAME, if found, and 
nil otherwise.
 This function expects to be in the right *tramp* buffer."
   (with-current-buffer (tramp-get-connection-buffer vec)
     (let (result)
-      ;; Check whether the executable is in $PATH. "which(1)" does not
+      ;; Check whether the executable is in $PATH.  "which(1)" does not
       ;; report always a correct error code; therefore we check the
       ;; number of words it returns.  "SunOS 5.10" (and maybe "SunOS
       ;; 5.11") have problems with this command, we disable the call
@@ -4902,6 +4903,8 @@ connection if a previous connection has died for some 
reason."
                 (tramp-error vec 'file-error "`tramp-encoding-shell' not set"))
              (let* ((current-host tramp-system-name)
                     (target-alist (tramp-compute-multi-hops vec))
+                    ;; Needed for `tramp-get-remote-null-device'.
+                    (previous-hop nil)
                     ;; We will apply `tramp-ssh-controlmaster-options'
                     ;; only for the first hop.
                     (options (tramp-ssh-controlmaster-options vec))
@@ -4915,7 +4918,7 @@ connection if a previous connection has died for some 
reason."
                     ;; This must be done in order to avoid our file
                     ;; name handler.
                     (p (let ((default-directory
-                               (tramp-compat-temporary-file-directory)))
+                               tramp-compat-temporary-file-directory))
                          (apply
                           #'start-process
                           (tramp-get-connection-name vec)
@@ -5014,6 +5017,8 @@ connection if a previous connection has died for some 
reason."
                        hop 'tramp-login-args
                        ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
                        ?c (format-spec options (format-spec-make ?t tmpfile))
+                       ?n (concat
+                           "2>" (tramp-get-remote-null-device previous-hop))
                        ?l (concat remote-shell " " extra-args " -i"))
                       ;; A restricted shell does not allow "exec".
                       (when r-shell '("&&" "exit" "||" "exit")))
@@ -5029,10 +5034,12 @@ connection if a previous connection has died for some 
reason."
                     tramp-actions-before-shell
                     (or connection-timeout tramp-connection-timeout))
                    (tramp-message
-                    vec 3 "Found remote shell prompt on `%s'" l-host))
-                 ;; Next hop.
-                 (setq options ""
-                       target-alist (cdr target-alist)))
+                    vec 3 "Found remote shell prompt on `%s'" l-host)
+
+                   ;; Next hop.
+                   (setq options ""
+                         target-alist (cdr target-alist)
+                         previous-hop hop)))
 
                ;; Activate session timeout.
                (when (tramp-get-connection-property p "session-timeout" nil)
@@ -5792,8 +5799,8 @@ This command is returned only if 
`delete-by-moving-to-trash' is non-nil."
 ;; Some predefined connection properties.
 (defun tramp-get-inline-compress (vec prop size)
   "Return the compress command related to PROP.
-PROP is either `inline-compress' or `inline-decompress'. SIZE is
-the length of the file to be compressed.
+PROP is either `inline-compress' or `inline-decompress'.
+SIZE is the length of the file to be compressed.
 
 If no corresponding command is found, nil is returned."
   (when (and (integerp tramp-inline-compress-start-size)
diff --git a/tramp-smb.el b/tramp-smb.el
index 5cfe874..87f3665 100644
--- a/tramp-smb.el
+++ b/tramp-smb.el
@@ -48,7 +48,7 @@
                   ;; Another guess.  We might implement a better check later 
on.
                   (tramp-case-insensitive t)))))
 
-;; Add a default for `tramp-default-user-alist'. Rule: For the SMB method,
+;; Add a default for `tramp-default-user-alist'.  Rule: For the SMB method,
 ;; the anonymous user is chosen.
 ;;;###tramp-autoload
 (tramp--with-startup
@@ -83,7 +83,7 @@ call, letting the SMB client use the default one."
 They are added to the `tramp-smb-program' call via \"--option '...'\".
 
 For example, if the deprecated SMB1 protocol shall be used, add to
-this variable (\"client min protocol=NT1\") ."
+this variable \"client min protocol=NT1\"."
   :group 'tramp
   :type '(repeat string)
   :version "28.1")
@@ -376,7 +376,7 @@ arguments to pass to the OPERATION."
                (and (numberp ok-if-already-exists)
                     (not (yes-or-no-p
                           (format
-                           "File %s already exists; make it a link anyway? "
+                           "File %s already exists; make it a link anyway?"
                            v2-localname)))))
            (tramp-error v2 'file-already-exists newname)
          (delete-file newname)))
@@ -1247,7 +1247,7 @@ component is used as the target of the symlink."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              localname)))))
              (tramp-error v 'file-already-exists localname)
            (delete-file linkname)))
@@ -1526,7 +1526,7 @@ component is used as the target of the symlink."
          (tramp-error
           v 'file-error "Error while changing file's mode %s" filename))))))
 
-;; We use BUFFER also as connection buffer during setup. Because of
+;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-smb-handle-start-file-process (name buffer program &rest args)
@@ -1603,7 +1603,7 @@ errors for shares like \"C$/\", which are common in 
Microsoft Windows."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -1703,7 +1703,7 @@ If VEC has no cifs capabilities, exchange \"/\" by 
\"\\\\\"."
 
       localname)))
 
-;; Share names of a host are cached. It is very unlikely that the
+;; Share names of a host are cached.  It is very unlikely that the
 ;; shares do change during connection.
 (defun tramp-smb-get-file-entries (directory)
   "Read entries which match DIRECTORY.
@@ -1962,7 +1962,7 @@ If ARGUMENT is non-nil, use it as argument for
     ;; Otherwise, we must delete the connection cache, because
     ;; capabilities might have changed.
     (unless (or argument (processp p))
-      (let ((default-directory (tramp-compat-temporary-file-directory))
+      (let ((default-directory tramp-compat-temporary-file-directory)
            (command (concat tramp-smb-program " -V")))
 
        (unless tramp-smb-version
@@ -2049,7 +2049,10 @@ If ARGUMENT is non-nil, use it as argument for
            (let* ((coding-system-for-read nil)
                   (process-connection-type tramp-process-connection-type)
                   (p (let ((default-directory
-                             (tramp-compat-temporary-file-directory)))
+                             tramp-compat-temporary-file-directory)
+                           (process-environment
+                            (cons (concat "TERM=" tramp-terminal-type)
+                                  process-environment)))
                        (apply #'start-process
                               (tramp-get-connection-name vec)
                               (tramp-get-connection-buffer vec)
@@ -2200,5 +2203,7 @@ Removes smb prompt.  Returns nil if an error message has 
appeared."
 ;;
 ;; * Try to remove the inclusion of dummy "" directory.  Seems to be at
 ;;   several places, especially in `tramp-smb-handle-insert-directory'.
+;;
+;; * Keep a separate connection process per share.
 
 ;;; tramp-smb.el ends here
diff --git a/tramp-sshfs.el b/tramp-sshfs.el
index c5b84a6..0019ac0 100644
--- a/tramp-sshfs.el
+++ b/tramp-sshfs.el
@@ -292,7 +292,7 @@ arguments to pass to the OPERATION."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t)))
diff --git a/tramp-sudoedit.el b/tramp-sudoedit.el
index 5895f1d..516d46d 100644
--- a/tramp-sudoedit.el
+++ b/tramp-sudoedit.el
@@ -190,7 +190,7 @@ arguments to pass to the OPERATION."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              v2-localname)))))
              (tramp-error v2 'file-already-exists newname)
            (delete-file newname)))
@@ -597,6 +597,7 @@ the result will be a local, non-Tramp, file name."
      v (if parents "/" (file-name-directory localname)))
     (unless (tramp-sudoedit-send-command
             v (if parents '("mkdir" "-p") "mkdir")
+            "-m" (format "%#o" (default-file-modes))
             (tramp-compat-file-name-unquote localname))
       (tramp-error v 'file-error "Couldn't make directory %s" dir))))
 
@@ -631,7 +632,7 @@ component is used as the target of the symlink."
                       (not
                        (yes-or-no-p
                         (format
-                         "File %s already exists; make it a link anyway? "
+                         "File %s already exists; make it a link anyway?"
                          localname)))))
              (tramp-error v 'file-already-exists localname)
            (delete-file linkname)))
diff --git a/tramp.el b/tramp.el
index 429d1ce..efa28e7 100644
--- a/tramp.el
+++ b/tramp.el
@@ -861,7 +861,7 @@ Used in `tramp-make-tramp-file-name'.")
 
 (defvar tramp-prefix-regexp nil ;Initialized when defining `tramp-syntax'!
   "Regexp matching the very beginning of Tramp file names.
-Should always start with \"^\". Derived from `tramp-prefix-format'.")
+Should always start with \"^\".  Derived from `tramp-prefix-format'.")
 
 (defconst tramp-method-regexp-alist
   '((default    . "[[:alnum:]-]+")
@@ -1899,7 +1899,7 @@ The outline level is equal to the verbosity of the Tramp 
message."
       ;; `(custom-declare-variable outline-minor-mode-prefix ...)'
       ;; raises on error in `(outline-mode)', we don't want to see it
       ;; in the traces.
-      (let ((default-directory (tramp-compat-temporary-file-directory)))
+      (let ((default-directory tramp-compat-temporary-file-directory))
        (outline-mode))
       (setq-local outline-level 'tramp-debug-outline-level)
       (setq-local font-lock-keywords
@@ -1918,7 +1918,7 @@ The outline level is equal to the verbosity of the Tramp 
message."
   "Get the debug file name for VEC."
   (expand-file-name
    (tramp-compat-string-replace "/" " " (tramp-debug-buffer-name vec))
-   (tramp-compat-temporary-file-directory)))
+   tramp-compat-temporary-file-directory))
 
 (put #'tramp-get-debug-file-name 'tramp-suppress-trace t)
 
@@ -1929,7 +1929,7 @@ The outline level is equal to the verbosity of the Tramp 
message."
 (put #'tramp-trace-buffer-name 'tramp-suppress-trace t)
 
 (defvar tramp-trace-functions nil
-  "A list of non-Tramp functions to be traced with tramp-verbose > 10.")
+  "A list of non-Tramp functions to be traced with `tramp-verbose' > 10.")
 
 (defun tramp-debug-message (vec fmt-string &rest arguments)
   "Append message to debug buffer of VEC.
@@ -1960,7 +1960,8 @@ ARGUMENTS to actually emit the message (if applicable)."
            (dolist
                (elt
                 (append
-                 (mapcar #'intern (all-completions "tramp-" obarray 
'functionp))
+                 (mapcar
+                  #'intern (all-completions "tramp-" obarray #'functionp))
                  tramp-trace-functions))
              (unless (get elt 'tramp-suppress-trace)
                (trace-function-background elt))))
@@ -2383,7 +2384,7 @@ For definition of that list see 
`tramp-set-completion-function'."
 
 ;; Inodes don't exist for some file systems.  Therefore we must
 ;; generate virtual ones.  Used in `find-buffer-visiting'.  The method
-;; applied might be not so efficient (Ange-FTP uses hashes). But
+;; applied might be not so efficient (Ange-FTP uses hashes).  But
 ;; performance isn't the major issue given that file transfer will
 ;; take time.
 (defvar tramp-inodes 0
@@ -2611,7 +2612,7 @@ If Emacs is compiled --with-threads, the body is 
protected by a mutex."
                             ;; the bug#9114 for which it was added doesn't
                             ;; clarify the core of the problem.
                            (let ((default-directory
-                                   (tramp-compat-temporary-file-directory))
+                                   tramp-compat-temporary-file-directory)
                                  file-name-handler-alist)
                              (autoload-do-load sf foreign)))
                          ;; (tramp-message
@@ -2855,6 +2856,15 @@ not in completion mode."
   "Like `file-name-all-completions' for partial Tramp files."
   (let ((fullname
         (tramp-drop-volume-letter (expand-file-name filename directory)))
+       ;; When `tramp-syntax' is `simplified', we need a default method.
+       (tramp-default-method
+        (and (zerop (length tramp-postfix-method-format))
+             tramp-default-method))
+       (tramp-default-method-alist
+        (and (zerop (length tramp-postfix-method-format))
+             tramp-default-method-alist))
+       tramp-default-user tramp-default-user-alist
+       tramp-default-host tramp-default-host-alist
        hop result result1)
 
     ;; Suppress hop from completion.
@@ -2933,7 +2943,7 @@ not in completion mode."
 ;; I misuse a little bit the `tramp-file-name' structure in order to
 ;; handle completion possibilities for partial methods / user names /
 ;; host names.  Return value is a list of `tramp-file-name' structures
-;; according to possible completions. If "localname" is non-nil it
+;; according to possible completions.  If "localname" is non-nil it
 ;; means there shouldn't be a completion anymore.
 
 ;; Expected results:
@@ -3040,7 +3050,7 @@ remote host and localname (filename on remote host)."
   "Return all method completions for PARTIAL-METHOD."
   (mapcar
    (lambda (method)
-     (and method (string-prefix-p partial-method method)
+     (and method (string-prefix-p (or partial-method "") method)
          (tramp-completion-make-tramp-file-name method nil nil nil)))
    (mapcar #'car tramp-methods)))
 
@@ -3115,7 +3125,7 @@ User is always nil."
 User is always nil."
   ;; On Windows, there are problems in completion when
   ;; `default-directory' is remote.
-  (let ((default-directory (tramp-compat-temporary-file-directory)))
+  (let ((default-directory tramp-compat-temporary-file-directory))
     (when (file-readable-p filename)
       (with-temp-buffer
        (insert-file-contents-literally filename)
@@ -3169,7 +3179,7 @@ User is always nil."
 User is always nil."
   ;; On Windows, there are problems in completion when
   ;; `default-directory' is remote.
-  (let* ((default-directory (tramp-compat-temporary-file-directory))
+  (let* ((default-directory tramp-compat-temporary-file-directory)
         (files (and (file-directory-p dirname) (directory-files dirname))))
     (cl-loop
      for f in files
@@ -3313,7 +3323,7 @@ User is always nil."
              (and (numberp ok-if-already-exists)
                   (not (yes-or-no-p
                         (format
-                         "File %s already exists; make it a link anyway? "
+                         "File %s already exists; make it a link anyway?"
                          localname)))))
          (tramp-error v 'file-already-exists newname)
        (delete-file newname)))
@@ -3403,7 +3413,7 @@ User is always nil."
       ;; Do normal `expand-file-name' (this does "/./" and "/../").
       ;; `default-directory' is bound, because on Windows there would
       ;; be problems with UNC shares or Cygwin mounts.
-      (let ((default-directory (tramp-compat-temporary-file-directory)))
+      (let ((default-directory tramp-compat-temporary-file-directory))
        (tramp-make-tramp-file-name
         v (tramp-drop-volume-letter
            (tramp-run-real-handler #'expand-file-name (list localname))))))))
@@ -3488,7 +3498,7 @@ User is always nil."
     (or ;; Maybe there is a default value.
      (tramp-get-method-parameter v 'tramp-case-insensitive)
 
-     ;; There isn't. So we must check, in case there's a connection already.
+     ;; There isn't.  So we must check, in case there's a connection already.
      (and (file-remote-p filename nil 'connected)
           (with-tramp-connection-property v "case-insensitive"
            (ignore-errors
@@ -3719,7 +3729,7 @@ User is always nil."
                          (yes-or-no-p
                           (concat
                            "Backup file on local temporary directory, "
-                           "do you want to continue? ")))))
+                           "do you want to continue?")))))
          (tramp-error v 'file-error "Unsafe backup file name"))))))
 
 (defun tramp-handle-insert-directory
@@ -3940,7 +3950,7 @@ Return nil when there is no lockfile."
                            (yes-or-no-p
                             (concat
                              "Lock file on local temporary directory, "
-                             "do you want to continue? ")))))
+                             "do you want to continue?")))))
            (tramp-error v 'file-error "Unsafe lock file name")))
 
        ;; Do the lock.
@@ -4128,7 +4138,7 @@ substitution.  SPEC-LIST is a list of char/value pairs 
used for
   "An alternative `make-process' implementation for Tramp files."
   (when args
     (with-parsed-tramp-file-name (expand-file-name default-directory) nil
-      (let ((default-directory (tramp-compat-temporary-file-directory))
+      (let ((default-directory tramp-compat-temporary-file-directory)
            (name (plist-get args :name))
            (buffer (plist-get args :buffer))
            (command (plist-get args :command))
@@ -4299,13 +4309,13 @@ support symbolic links."
        ((eq async-shell-command-buffer 'confirm-kill-process)
        ;; If will kill a process, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Kill it? ")
+            "A command is running in the default buffer.  Kill it?")
            (kill-process p)
          (tramp-user-error p "Shell command in progress")))
        ((eq async-shell-command-buffer 'confirm-new-buffer)
        ;; If will create a new buffer, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Use a new buffer? ")
+            "A command is running in the default buffer.  Use a new buffer?")
             (setq output-buffer (generate-new-buffer bname))
          (tramp-user-error p "Shell command in progress")))
        ((eq async-shell-command-buffer 'new-buffer)
@@ -4314,7 +4324,7 @@ support symbolic links."
        ((eq async-shell-command-buffer 'confirm-rename-buffer)
        ;; If will rename the buffer, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Rename it? ")
+            "A command is running in the default buffer.  Rename it?")
            (progn
              (with-current-buffer output-buffer
                (rename-uniquely))
@@ -4517,7 +4527,7 @@ of."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -5391,7 +5401,7 @@ This handles also chrooted environments, which are not 
regarded as local."
      ;; The local temp directory must be writable for the other user.
      (file-writable-p
       (tramp-make-tramp-file-name
-       vec (tramp-compat-temporary-file-directory) 'nohop))
+       vec tramp-compat-temporary-file-directory 'nohop))
      ;; On some systems, chown runs only for root.
      (or (zerop (user-uid))
         (zerop (tramp-get-remote-uid vec 'integer))))))
@@ -5453,7 +5463,8 @@ this file, if that variable is non-nil."
     ;; Create directory.
     (unless (or (null tramp-auto-save-directory)
                (file-exists-p tramp-auto-save-directory))
-      (make-directory tramp-auto-save-directory t))
+      (make-directory tramp-auto-save-directory t)
+      (set-file-modes tramp-auto-save-directory #o0700))
 
     (let ((system-type
           (if (and (stringp tramp-auto-save-directory)
@@ -5492,7 +5503,7 @@ this file, if that variable is non-nil."
                          (yes-or-no-p
                           (concat
                            "Autosave file on local temporary directory, "
-                           "do you want to continue? ")))))
+                           "do you want to continue?")))))
          (tramp-error v 'file-error "Unsafe autosave file name"))))))
 
 (defun tramp-subst-strs-in-string (alist string)
@@ -5532,7 +5543,7 @@ ALIST is of the form ((FROM . TO) ...)."
 It always returns a return code.  The Lisp error raised when
 PROGRAM is nil is trapped also, returning 1.  Furthermore, traces
 are written with verbosity of 6."
-  (let ((default-directory (tramp-compat-temporary-file-directory))
+  (let ((default-directory tramp-compat-temporary-file-directory)
        (process-environment (default-toplevel-value 'process-environment))
        (destination (if (eq destination t) (current-buffer) destination))
        (vec (or vec (car tramp-current-connection)))
@@ -5566,7 +5577,7 @@ are written with verbosity of 6."
 It always returns a return code.  The Lisp error raised when
 PROGRAM is nil is trapped also, returning 1.  Furthermore, traces
 are written with verbosity of 6."
-  (let ((default-directory (tramp-compat-temporary-file-directory))
+  (let ((default-directory tramp-compat-temporary-file-directory)
        (process-environment (default-toplevel-value 'process-environment))
        (buffer (if (eq buffer t) (current-buffer) buffer))
        result)
@@ -5596,7 +5607,7 @@ are written with verbosity of 6."
   "Call `process-lines' on the local host.
 If an error occurs, it returns nil.  Traces are written with
 verbosity of 6."
-  (let ((default-directory (tramp-compat-temporary-file-directory))
+  (let ((default-directory tramp-compat-temporary-file-directory)
        (process-environment (default-toplevel-value 'process-environment))
        (vec (or vec (car tramp-current-connection)))
        result)
@@ -5624,6 +5635,9 @@ verbosity of 6."
               (string-prefix-p comm process-name)
               (throw 'result t)))))))
 
+;; When calling "emacs -Q", `auth-source-search' won't be called.  If
+;; you want to debug exactly this case, call "emacs -Q --eval '(setq
+;; tramp-cache-read-persistent-data t)'" instead.
 (defun tramp-read-passwd (proc &optional prompt)
   "Read a password from user (compat function).
 Consults the auth-source package.
@@ -5632,7 +5646,7 @@ Invokes `password-read' if available, `read-passwd' else."
         ;; `exec-path' contains a relative file name like ".", it
         ;; could happen that the "gpg" command is not found.  So we
         ;; adapt `default-directory'.  (Bug#39389, Bug#39489)
-        (default-directory (tramp-compat-temporary-file-directory))
+        (default-directory tramp-compat-temporary-file-directory)
         (case-fold-search t)
         (key (tramp-make-tramp-file-name
               ;; In tramp-sh.el, we must use "password-vector" due to
@@ -5698,6 +5712,10 @@ Invokes `password-read' if available, `read-passwd' 
else."
               ;; Else, get the password interactively w/o cache.
               (read-passwd pw-prompt))
 
+           ;; Workaround.  Prior Emacs 28.1, auth-source has saved
+           ;; empty passwords.  See discussion in Bug#50399.
+           (when (zerop (length auth-passwd))
+             (setq tramp-password-save-function nil))
            (tramp-set-connection-property v "first-password-request" nil)))
 
       ;; Reenable the timers.
diff --git a/trampver.el b/trampver.el
index 8a3793b..1c3acf2 100644
--- a/trampver.el
+++ b/trampver.el
@@ -29,7 +29,7 @@
 
 ;;; Commentary:
 
-;; Convenience functions around the Tramp version. Partly generated
+;; Convenience functions around the Tramp version.  Partly generated
 ;; during Tramp configuration.
 
 ;;; Code:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]