aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-01-19 14:11:07 +0100
committerMichael Albinus2020-01-19 14:11:07 +0100
commit0ad895df50ec2ed0d322520a92f7ad45f22eddaa (patch)
tree7e4aa3f9d2777685f15a2eaa0fd53735788e459a
parent35a1a007bb7506c72ee6d9757a79014c679e7bae (diff)
downloademacs-0ad895df50ec2ed0d322520a92f7ad45f22eddaa.tar.gz
emacs-0ad895df50ec2ed0d322520a92f7ad45f22eddaa.zip
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}. (GVFS-based methods): Move "GNOME Online Accounts" index. (Customizing Methods, Android shell setup, File name completion) (Frequently Asked Questions): Fix typos. * doc/misc/trampver.texi: Change version to "2.5.0-pre". * lisp/net/trampver.el: Change version to "2.5.0-pre". (inhibit-message): Don't declare. * lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1. (tramp-debug-message): Simplify. (tramp-message): Don't use `tramp-message-show-message'. (tramp-with-demoted-errors, with-parsed-tramp-file-name) (with-tramp-file-property, with-tramp-connection-property): Adapt `declare' form. (with-tramp-progress-reporter): Suppress progress reporter when noninteractive. (tramp-completion-mode, tramp-completion-mode-p): Remove. * lisp/net/tramp-compat.el (tramp-compat-process-running-p) (format-message): Remove compatibility code. (tramp-compat-directory-name-p) (tramp-compat-tramp-file-name-slots): Remove. * lisp/net/tramp.el (tramp-debug-message, tramp-message) (tramp-backtrace, tramp-error, tramp-error-with-buffer) (tramp-user-error, tramp-with-demoted-errors) (tramp-signal-hook-function): * lisp/net/tramp-compat.el (tramp-compat-funcall) * lisp/net/tramp-gvfs.el (tramp-dbus-function): Add `tramp-suppress-trace' property. * lisp/net/tramp.el (tramp-get-method-parameter) (tramp-dissect-file-name, tramp-error, tramp-error-with-buffer) (tramp-user-error, with-parsed-tramp-file-name) (with-tramp-progress-reporter, tramp-file-name-handler) (tramp-completion-file-name-handler, tramp-autoload-file-name-handler) (tramp-register-file-name-handlers, tramp-connectable-p) (tramp-handle-file-modes, tramp-handle-file-regular-p) (tramp-handle-file-truename, tramp-handle-insert-directory) (tramp-handle-load, tramp-set-file-uid-gid): * lisp/net/tramp-adb.el (tramp-adb-file-name-handler) (tramp-adb-handle-file-truename, tramp-adb-handle-copy-file) (tramp-adb-handle-rename-file): * lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name): * lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print): * lisp/net/tramp-compat.el (tramp-compat-process-running-p) (tramp-compat-exec-path): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler) (tramp-gvfs-dbus-byte-array-to-string) (tramp-gvfs-do-copy-or-rename-file): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler) (tramp-rclone-do-copy-or-rename-file): * lisp/net/tramp-sh.el (tramp-sh-handle-file-truename) (tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file) (tramp-sh-handle-insert-directory, tramp-sh-file-name-handler) (tramp-maybe-open-connection): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler) (tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory) (tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory) (tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler) (tramp-sudoedit-do-copy-or-rename-file) (tramp-sudoedit-handle-file-truename): Use `if-let', `when-let', `directory-name-p', `inhibit-message', `non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'. * test/lisp/net/tramp-archive-tests.el (tramp-message-show-message): Don't set. * test/lisp/net/tramp-tests.el (inhibit-message): Don't declare. (tramp-message-show-message): Don't set. (tramp-test06-directory-file-name): Use `non-essential'. (tramp-test10-write-region): Use `inhibit-message'. (tramp-test36-vc-registered): No special handling for old Emacsen. (tramp--test-emacs25-p): Remove. (tramp-test45-unload): Special case of `tramp-completion-mode'.
-rw-r--r--doc/misc/tramp.texi40
-rw-r--r--doc/misc/trampver.texi4
-rw-r--r--lisp/net/tramp-adb.el78
-rw-r--r--lisp/net/tramp-archive.el21
-rw-r--r--lisp/net/tramp-cache.el30
-rw-r--r--lisp/net/tramp-compat.el85
-rw-r--r--lisp/net/tramp-gvfs.el32
-rw-r--r--lisp/net/tramp-rclone.el9
-rw-r--r--lisp/net/tramp-sh.el52
-rw-r--r--lisp/net/tramp-smb.el88
-rw-r--r--lisp/net/tramp-sudoedit.el12
-rw-r--r--lisp/net/tramp-uu.el5
-rw-r--r--lisp/net/tramp.el236
-rw-r--r--lisp/net/trampver.el14
-rw-r--r--test/lisp/net/tramp-archive-tests.el2
-rw-r--r--test/lisp/net/tramp-tests.el40
16 files changed, 304 insertions, 444 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 049b240b602..602d62c3201 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -46,7 +46,7 @@ copy and modify this GNU manual.''
46@node Top, Overview, (dir), (dir) 46@node Top, Overview, (dir), (dir)
47@top @value{tramp} @value{trampver} User Manual 47@top @value{tramp} @value{trampver} User Manual
48 48
49This file documents @value{tramp} @value{trampver}, a remote file 49This file documents @w{@value{tramp} @value{trampver}}, a remote file
50editing package for Emacs. 50editing package for Emacs.
51 51
52@value{tramp} stands for ``Transparent Remote (file) Access, Multiple 52@value{tramp} stands for ``Transparent Remote (file) Access, Multiple
@@ -312,7 +312,7 @@ behind the scenes when you open a file with @value{tramp}.
312@cindex GNU ELPA 312@cindex GNU ELPA
313@vindex tramp-version 313@vindex tramp-version
314 314
315@value{tramp} is included as part of Emacs (since Emacs 22.1). 315@value{tramp} is included as part of Emacs (since @w{Emacs 22.1}).
316 316
317@value{tramp} is also freely packaged for download on the Internet at 317@value{tramp} is also freely packaged for download on the Internet at
318@uref{https://ftp.gnu.org/gnu/tramp/}. The version number of 318@uref{https://ftp.gnu.org/gnu/tramp/}. The version number of
@@ -324,9 +324,9 @@ A @value{tramp} release, which is packaged with Emacs, could differ
324slightly from the corresponding standalone release. This is because 324slightly from the corresponding standalone release. This is because
325it isn't always possible to synchronize release dates between Emacs 325it isn't always possible to synchronize release dates between Emacs
326and @value{tramp}. Such version numbers have the Emacs version number 326and @value{tramp}. Such version numbers have the Emacs version number
327as suffix, like ``2.3.5.26.3''. This means @value{tramp} 2.3.5 as 327as suffix, like ``2.3.5.26.3''. This means @w{@value{tramp} 2.3.5} as
328integrated in Emacs 26.3. A complete list of @value{tramp} versions 328integrated in @w{Emacs 26.3}. A complete list of @value{tramp}
329packaged with Emacs can be retrieved by 329versions packaged with Emacs can be retrieved by
330 330
331@vindex customize-package-emacs-version-alist 331@vindex customize-package-emacs-version-alist
332@lisp 332@lisp
@@ -1227,6 +1227,7 @@ supported by these methods. See method @option{nextcloud} for
1227handling them. 1227handling them.
1228 1228
1229@item @option{gdrive} 1229@item @option{gdrive}
1230@cindex @acronym{GNOME} Online Accounts
1230@cindex method @option{gdrive} 1231@cindex method @option{gdrive}
1231@cindex @option{gdrive} method 1232@cindex @option{gdrive} method
1232@cindex google drive 1233@cindex google drive
@@ -1243,7 +1244,6 @@ could produce unexpected behavior in case two files in the same
1243directory have the same @code{display-name}, such a situation must be avoided. 1244directory have the same @code{display-name}, such a situation must be avoided.
1244 1245
1245@item @option{nextcloud} 1246@item @option{nextcloud}
1246@cindex @acronym{GNOME} Online Accounts
1247@cindex method @option{nextcloud} 1247@cindex method @option{nextcloud}
1248@cindex @option{nextcloud} method 1248@cindex @option{nextcloud} method
1249@cindex nextcloud 1249@cindex nextcloud
@@ -1642,7 +1642,7 @@ suitable settings. Refer to the Lisp documentation of that variable,
1642accessible with @kbd{C-h v tramp-methods @key{RET}}. 1642accessible with @kbd{C-h v tramp-methods @key{RET}}.
1643 1643
1644In the ELPA archives, there are several examples of such extensions. 1644In the ELPA archives, there are several examples of such extensions.
1645They can be installed with Emacs' Package Manager. This includes 1645They can be installed with Emacs's Package Manager. This includes
1646 1646
1647@table @samp 1647@table @samp
1648@c @item anything-tramp 1648@c @item anything-tramp
@@ -2095,8 +2095,8 @@ preserves the path value, which can be used to update
2095shell supports the login argument @samp{-l}. 2095shell supports the login argument @samp{-l}.
2096@end defopt 2096@end defopt
2097 2097
2098Starting with Emacs 26, @code{tramp-remote-path} can be set per host 2098Starting with @w{Emacs 26}, @code{tramp-remote-path} can be set per
2099via connection-local 2099host via connection-local
2100@ifinfo 2100@ifinfo
2101variables, @xref{Connection Variables, , , emacs}. 2101variables, @xref{Connection Variables, , , emacs}.
2102@end ifinfo 2102@end ifinfo
@@ -2450,7 +2450,7 @@ where @samp{192.168.0.1} is the remote host IP address
2450Android devices provide a restricted shell access through an USB 2450Android devices provide a restricted shell access through an USB
2451connection. The local host must have the @command{adb} program 2451connection. The local host must have the @command{adb} program
2452installed. Usually, it is sufficient to open the file 2452installed. Usually, it is sufficient to open the file
2453@file{@trampfn{adb,,/}}. Then you can navigate in the filesystem via 2453@file{@trampfn{adb,,/}}. Then you can navigate in the file system via
2454@code{dired}. 2454@code{dired}.
2455 2455
2456Alternatively, applications such as @code{Termux} or @code{SSHDroid} 2456Alternatively, applications such as @code{Termux} or @code{SSHDroid}
@@ -2937,10 +2937,10 @@ Example:
2937@end example 2937@end example
2938 2938
2939During file name completion, remote directory contents are re-read 2939During file name completion, remote directory contents are re-read
2940regularly to account for any changes in the filesystem that may affect 2940regularly to account for any changes in the file system that may
2941the completion candidates. Such re-reads can account for changes to 2941affect the completion candidates. Such re-reads can account for
2942the file system by applications outside Emacs (@pxref{Connection 2942changes to the file system by applications outside Emacs
2943caching}). 2943(@pxref{Connection caching}).
2944 2944
2945@defopt tramp-completion-reread-directory-timeout 2945@defopt tramp-completion-reread-directory-timeout
2946The timeout is number of seconds since last remote command for 2946The timeout is number of seconds since last remote command for
@@ -3161,8 +3161,8 @@ ensures the correct name of the remote shell program.
3161When @code{explicit-shell-file-name} is equal to @code{nil}, calling 3161When @code{explicit-shell-file-name} is equal to @code{nil}, calling
3162@code{shell} interactively will prompt for a shell name. 3162@code{shell} interactively will prompt for a shell name.
3163 3163
3164Starting with Emacs 26, you could use connection-local variables for 3164Starting with @w{Emacs 26}, you could use connection-local variables
3165setting different values of @code{explicit-shell-file-name} for 3165for setting different values of @code{explicit-shell-file-name} for
3166different remote hosts. 3166different remote hosts.
3167@ifinfo 3167@ifinfo
3168@xref{Connection Variables, , , emacs}. 3168@xref{Connection Variables, , , emacs}.
@@ -3231,7 +3231,7 @@ variables.
3231@vindex async-shell-command-width 3231@vindex async-shell-command-width
3232@vindex COLUMNS@r{, environment variable} 3232@vindex COLUMNS@r{, environment variable}
3233If Emacs supports the variable @code{async-shell-command-width} (since 3233If Emacs supports the variable @code{async-shell-command-width} (since
3234Emacs 27.1), @value{tramp} cares about its value for asynchronous 3234@w{Emacs 27.1}), @value{tramp} cares about its value for asynchronous
3235shell commands. It specifies the number of display columns for 3235shell commands. It specifies the number of display columns for
3236command output. For synchronous shell commands, a similar effect can 3236command output. For synchronous shell commands, a similar effect can
3237be achieved by adding the environment variable @env{COLUMNS} to 3237be achieved by adding the environment variable @env{COLUMNS} to
@@ -3840,8 +3840,8 @@ Where is the latest @value{tramp}?
3840@item 3840@item
3841Which systems does it work on? 3841Which systems does it work on?
3842 3842
3843The package works successfully on Emacs 24, Emacs 25, Emacs 26, Emacs 3843The package works successfully on @w{Emacs 25}, @w{Emacs 26}, @w{Emacs
384427, and Emacs 28. 384427}, and @w{Emacs 28}.
3845 3845
3846While Unix and Unix-like systems are the primary remote targets, 3846While Unix and Unix-like systems are the primary remote targets,
3847@value{tramp} has equal success connecting to other platforms, such as 3847@value{tramp} has equal success connecting to other platforms, such as
@@ -4178,7 +4178,7 @@ Host indication in the mode line?
4178 4178
4179@cindex @value{tramp} theme 4179@cindex @value{tramp} theme
4180@vindex tramp-theme-face-remapping-alist 4180@vindex tramp-theme-face-remapping-alist
4181Install @file{tramp-theme} from GNU ELPA via Emacs' Package Manager. 4181Install @file{tramp-theme} from GNU ELPA via Emacs's Package Manager.
4182Enable it via @kbd{M-x load-theme @key{RET} tramp @key{RET}}. Further 4182Enable it via @kbd{M-x load-theme @key{RET} tramp @key{RET}}. Further
4183customization is explained in user option 4183customization is explained in user option
4184@code{tramp-theme-face-remapping-alist}. 4184@code{tramp-theme-face-remapping-alist}.
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index 02a99ebde83..aabb2f8acc3 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -8,9 +8,9 @@
8@c In the Tramp GIT, the version numbers are auto-frobbed from 8@c In the Tramp GIT, the version numbers are auto-frobbed from
9@c tramp.el, and the bug report address is auto-frobbed from 9@c tramp.el, and the bug report address is auto-frobbed from
10@c configure.ac. 10@c configure.ac.
11@set trampver 2.4.4-pre 11@set trampver 2.5.0-pre
12@set tramp-bug-report-address tramp-devel@@gnu.org 12@set tramp-bug-report-address tramp-devel@@gnu.org
13@set emacsver 24.4 13@set emacsver 25.1
14 14
15@c Other flags from configuration. 15@c Other flags from configuration.
16@set instprefix /usr/local 16@set instprefix /usr/local
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index efe89344216..194dd2d308f 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -181,10 +181,9 @@ It is used for TCP/IP devices."
181 "Invoke the ADB handler for OPERATION. 181 "Invoke the ADB handler for OPERATION.
182First arg specifies the OPERATION, second arg is a list of 182First arg specifies the OPERATION, second arg is a list of
183ARGUMENTS to pass to the OPERATION." 183ARGUMENTS to pass to the OPERATION."
184 (let ((fn (assoc operation tramp-adb-file-name-handler-alist))) 184 (if-let ((fn (assoc operation tramp-adb-file-name-handler-alist)))
185 (if fn 185 (save-match-data (apply (cdr fn) arguments))
186 (save-match-data (apply (cdr fn) arguments)) 186 (tramp-run-real-handler operation arguments)))
187 (tramp-run-real-handler operation arguments))))
188 187
189;;;###tramp-autoload 188;;;###tramp-autoload
190(tramp--with-startup 189(tramp--with-startup
@@ -234,8 +233,7 @@ ARGUMENTS to pass to the OPERATION."
234 "Like `file-truename' for Tramp files." 233 "Like `file-truename' for Tramp files."
235 ;; Preserve trailing "/". 234 ;; Preserve trailing "/".
236 (funcall 235 (funcall
237 (if (tramp-compat-directory-name-p filename) 236 (if (directory-name-p filename) #'file-name-as-directory #'identity)
238 #'file-name-as-directory #'identity)
239 ;; Quote properly. 237 ;; Quote properly.
240 (funcall 238 (funcall
241 (if (tramp-compat-file-name-quoted-p filename) 239 (if (tramp-compat-file-name-quoted-p filename)
@@ -719,7 +717,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
719 (when (and (not ok-if-already-exists) (file-exists-p newname)) 717 (when (and (not ok-if-already-exists) (file-exists-p newname))
720 (tramp-error v 'file-already-exists newname)) 718 (tramp-error v 'file-already-exists newname))
721 (when (and (file-directory-p newname) 719 (when (and (file-directory-p newname)
722 (not (tramp-compat-directory-name-p newname))) 720 (not (directory-name-p newname)))
723 (tramp-error v 'file-error "File is a directory %s" newname)) 721 (tramp-error v 'file-error "File is a directory %s" newname))
724 722
725 (with-tramp-progress-reporter 723 (with-tramp-progress-reporter
@@ -739,39 +737,37 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
739 (tramp-shell-quote-argument l2)) 737 (tramp-shell-quote-argument l2))
740 "Error copying %s to %s" filename newname)) 738 "Error copying %s to %s" filename newname))
741 739
742 (let ((tmpfile (file-local-copy filename))) 740 (if-let ((tmpfile (file-local-copy filename)))
743 741 ;; Remote filename.
744 (if tmpfile 742 (condition-case err
745 ;; Remote filename. 743 (rename-file tmpfile newname ok-if-already-exists)
746 (condition-case err 744 ((error quit)
747 (rename-file tmpfile newname ok-if-already-exists) 745 (delete-file tmpfile)
748 ((error quit) 746 (signal (car err) (cdr err))))
749 (delete-file tmpfile) 747
750 (signal (car err) (cdr err)))) 748 ;; Remote newname.
751 749 (when (and (file-directory-p newname)
752 ;; Remote newname. 750 (directory-name-p newname))
753 (when (and (file-directory-p newname) 751 (setq newname
754 (tramp-compat-directory-name-p newname)) 752 (expand-file-name
755 (setq newname 753 (file-name-nondirectory filename) newname)))
756 (expand-file-name 754
757 (file-name-nondirectory filename) newname))) 755 (with-parsed-tramp-file-name newname nil
758 756 (when (and (not ok-if-already-exists)
759 (with-parsed-tramp-file-name newname nil 757 (file-exists-p newname))
760 (when (and (not ok-if-already-exists) 758 (tramp-error v 'file-already-exists newname))
761 (file-exists-p newname)) 759
762 (tramp-error v 'file-already-exists newname)) 760 ;; We must also flush the cache of the directory,
763 761 ;; because `file-attributes' reads the values from
764 ;; We must also flush the cache of the directory, 762 ;; there.
765 ;; because `file-attributes' reads the values from 763 (tramp-flush-file-properties v localname)
766 ;; there. 764 (when (tramp-adb-execute-adb-command
767 (tramp-flush-file-properties v localname) 765 v "push"
768 (when (tramp-adb-execute-adb-command 766 (tramp-compat-file-name-unquote filename)
769 v "push" 767 (tramp-compat-file-name-unquote localname))
770 (tramp-compat-file-name-unquote filename) 768 (tramp-error
771 (tramp-compat-file-name-unquote localname)) 769 v 'file-error
772 (tramp-error 770 "Cannot copy `%s' `%s'" filename newname))))))))
773 v 'file-error
774 "Cannot copy `%s' `%s'" filename newname)))))))))
775 771
776 ;; KEEP-DATE handling. 772 ;; KEEP-DATE handling.
777 (when keep-date 773 (when keep-date
@@ -801,7 +797,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
801 (when (and (not ok-if-already-exists) (file-exists-p newname)) 797 (when (and (not ok-if-already-exists) (file-exists-p newname))
802 (tramp-error v 'file-already-exists newname)) 798 (tramp-error v 'file-already-exists newname))
803 (when (and (file-directory-p newname) 799 (when (and (file-directory-p newname)
804 (not (tramp-compat-directory-name-p newname))) 800 (not (directory-name-p newname)))
805 (tramp-error v 'file-error "File is a directory %s" newname)) 801 (tramp-error v 'file-error "File is a directory %s" newname))
806 802
807 (with-tramp-progress-reporter 803 (with-tramp-progress-reporter
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index b9bf6180a5d..95cbfb8c22a 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -350,7 +350,7 @@ arguments to pass to the OPERATION."
350 (add-to-list 'file-name-handler-alist 350 (add-to-list 'file-name-handler-alist
351 (cons (tramp-archive-autoload-file-name-regexp) 351 (cons (tramp-archive-autoload-file-name-regexp)
352 #'tramp-archive-autoload-file-name-handler)) 352 #'tramp-archive-autoload-file-name-handler))
353 (put 'tramp-archive-autoload-file-name-handler 'safe-magic t)))) 353 (put #'tramp-archive-autoload-file-name-handler 'safe-magic t))))
354 354
355;;;###autoload 355;;;###autoload
356(progn 356(progn
@@ -366,7 +366,7 @@ arguments to pass to the OPERATION."
366(tramp-register-archive-file-name-handler) 366(tramp-register-archive-file-name-handler)
367 367
368;; Mark `operations' the handler is responsible for. 368;; Mark `operations' the handler is responsible for.
369(put 'tramp-archive-file-name-handler 'operations 369(put #'tramp-archive-file-name-handler 'operations
370 (mapcar #'car tramp-archive-file-name-handler-alist)) 370 (mapcar #'car tramp-archive-file-name-handler-alist))
371 371
372;; `tramp-archive-file-name-handler' must be placed before `url-file-handler'. 372;; `tramp-archive-file-name-handler' must be placed before `url-file-handler'.
@@ -517,13 +517,16 @@ offered."
517 (declare (debug (form symbolp body)) 517 (declare (debug (form symbolp body))
518 (indent 2)) 518 (indent 2))
519 (let ((bindings 519 (let ((bindings
520 (mapcar (lambda (elem) 520 (mapcar
521 `(,(if var (intern (format "%s-%s" var elem)) elem) 521 (lambda (elem)
522 (,(intern (format "tramp-file-name-%s" elem)) 522 `(,(if var (intern (format "%s-%s" var elem)) elem)
523 ,(or var 'v)))) 523 (,(intern (format "tramp-file-name-%s" elem))
524 `,(cons 524 ,(or var 'v))))
525 'archive 525 (cons
526 (delete 'hop (tramp-compat-tramp-file-name-slots)))))) 526 'archive
527 (delete
528 'hop
529 (cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name))))))))
527 `(let* ((,(or var 'v) (tramp-archive-dissect-file-name ,filename)) 530 `(let* ((,(or var 'v) (tramp-archive-dissect-file-name ,filename))
528 ,@bindings) 531 ,@bindings)
529 ;; We don't know which of those vars will be used, so we bind them all, 532 ;; We don't know which of those vars will be used, so we bind them all,
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index b81a1a23d5f..f8325a16892 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -130,13 +130,8 @@ Returns DEFAULT if not set."
130 (or (null remote-file-name-inhibit-cache) 130 (or (null remote-file-name-inhibit-cache)
131 (and (integerp remote-file-name-inhibit-cache) 131 (and (integerp remote-file-name-inhibit-cache)
132 (time-less-p 132 (time-less-p
133 ;; `current-time' can be nil once we get rid of Emacs 24. 133 nil
134 (current-time) 134 (time-add (car value) remote-file-name-inhibit-cache)))
135 (time-add
136 (car value)
137 ;; `seconds-to-time' can be removed once we get
138 ;; rid of Emacs 24.
139 (seconds-to-time remote-file-name-inhibit-cache))))
140 (and (consp remote-file-name-inhibit-cache) 135 (and (consp remote-file-name-inhibit-cache)
141 (time-less-p 136 (time-less-p
142 remote-file-name-inhibit-cache (car value))))) 137 remote-file-name-inhibit-cache (car value)))))
@@ -386,20 +381,15 @@ used to cache connection properties of the local machine."
386 (maphash 381 (maphash
387 (lambda (key value) 382 (lambda (key value)
388 ;; Remove text properties from KEY and VALUE. 383 ;; Remove text properties from KEY and VALUE.
389 ;; `cl-struct-slot-*' functions exist since Emacs 25 only; we
390 ;; ignore errors.
391 (when (tramp-file-name-p key) 384 (when (tramp-file-name-p key)
392 ;; (dolist 385 (dolist
393 ;; (slot 386 (slot
394 ;; (mapcar #'car (cdr (cl-struct-slot-info 'tramp-file-name)))) 387 (mapcar #'car (cdr (cl-struct-slot-info 'tramp-file-name))))
395 ;; (when (stringp (cl-struct-slot-value 'tramp-file-name slot key)) 388 (when (stringp (cl-struct-slot-value 'tramp-file-name slot key))
396 ;; (setf (cl-struct-slot-value 'tramp-file-name slot key) 389 (setf (cl-struct-slot-value 'tramp-file-name slot key)
397 ;; (substring-no-properties 390 (substring-no-properties
398 ;; (cl-struct-slot-value 'tramp-file-name slot key)))))) 391 (cl-struct-slot-value 'tramp-file-name slot key))))))
399 (dotimes (i (length key)) 392 (when (stringp key)
400 (when (stringp (elt key i))
401 (setf (elt key i) (substring-no-properties (elt key i))))))
402 (when (stringp key)
403 (setq key (substring-no-properties key))) 393 (setq key (substring-no-properties key)))
404 (when (stringp value) 394 (when (stringp value)
405 (setq value (substring-no-properties value))) 395 (setq value (substring-no-properties value)))
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 3f25afedb99..ba1cb9e4310 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -23,15 +23,15 @@
23 23
24;;; Commentary: 24;;; Commentary:
25 25
26;; Tramp's main Emacs version for development is Emacs 27. This 26;; Tramp's main Emacs version for development is Emacs 28. This
27;; package provides compatibility functions for Emacs 24, Emacs 25 and 27;; package provides compatibility functions for Emacs 25, Emacs 26 and
28;; Emacs 26. 28;; Emacs 27.
29 29
30;;; Code: 30;;; Code:
31 31
32;; In Emacs 24 and 25, `tramp-unload-file-name-handlers' is not 32;; In Emacs 25, `tramp-unload-file-name-handlers' is not autoloaded.
33;; autoloaded. So we declare it here in order to avoid recursive 33;; So we declare it here in order to avoid recursive load. This will
34;; load. This will be overwritten in tramp.el. 34;; be overwritten in tramp.el.
35(defun tramp-unload-file-name-handlers () ".") 35(defun tramp-unload-file-name-handlers () ".")
36 36
37(require 'auth-source) 37(require 'auth-source)
@@ -52,6 +52,8 @@
52 `(when (functionp ,function) 52 `(when (functionp ,function)
53 (with-no-warnings (funcall ,function ,@arguments)))) 53 (with-no-warnings (funcall ,function ,@arguments))))
54 54
55(put #'tramp-compat-funcall 'tramp-suppress-trace t)
56
55(defsubst tramp-compat-temporary-file-directory () 57(defsubst tramp-compat-temporary-file-directory ()
56 "Return name of directory for temporary files. 58 "Return name of directory for temporary files.
57It is the default value of `temporary-file-directory'." 59It is the default value of `temporary-file-directory'."
@@ -78,28 +80,18 @@ Add the extension of F, if existing."
78(defun tramp-compat-process-running-p (process-name) 80(defun tramp-compat-process-running-p (process-name)
79 "Return t if system process PROCESS-NAME is running for `user-login-name'." 81 "Return t if system process PROCESS-NAME is running for `user-login-name'."
80 (when (stringp process-name) 82 (when (stringp process-name)
81 (cond 83 (let (result)
82 ;; GNU Emacs 22 on w32. 84 (dolist (pid (tramp-compat-funcall 'list-system-processes) result)
83 ((fboundp 'w32-window-exists-p) 85 (let ((attributes (process-attributes pid)))
84 (tramp-compat-funcall 'w32-window-exists-p process-name process-name)) 86 (and (string-equal (cdr (assoc 'user attributes)) (user-login-name))
85 87 (when-let ((comm (cdr (assoc 'comm attributes))))
86 ;; GNU Emacs 23+. 88 ;; The returned command name could be truncated to 15
87 ((and (fboundp 'list-system-processes) (fboundp 'process-attributes)) 89 ;; characters. Therefore, we cannot check for
88 (let (result) 90 ;; `string-equal'.
89 (dolist (pid (tramp-compat-funcall 'list-system-processes) result) 91 (string-match-p (concat "^" (regexp-quote comm)) process-name))
90 (let ((attributes (process-attributes pid))) 92 (setq result t)))))))
91 (when (and (string-equal 93
92 (cdr (assoc 'user attributes)) (user-login-name)) 94;; `file-attribute-*' are introduced in Emacs 26.1.
93 (let ((comm (cdr (assoc 'comm attributes))))
94 ;; The returned command name could be truncated
95 ;; to 15 characters. Therefore, we cannot check
96 ;; for `string-equal'.
97 (and comm (string-match-p
98 (concat "^" (regexp-quote comm))
99 process-name))))
100 (setq result t)))))))))
101
102;; `file-attribute-*' are introduced in Emacs 25.1.
103 95
104(defalias 'tramp-compat-file-attribute-type 96(defalias 'tramp-compat-file-attribute-type
105 (if (fboundp 'file-attribute-type) 97 (if (fboundp 'file-attribute-type)
@@ -181,24 +173,6 @@ and later, and is a float in Emacs 26 and earlier."
181This is a string of ten letters or dashes as in ls -l." 173This is a string of ten letters or dashes as in ls -l."
182 (nth 8 attributes)))) 174 (nth 8 attributes))))
183 175
184;; `format-message' is new in Emacs 25.1.
185(unless (fboundp 'format-message)
186 (defalias 'format-message #'format))
187
188;; `directory-name-p' is new in Emacs 25.1.
189(defalias 'tramp-compat-directory-name-p
190 (if (fboundp 'directory-name-p)
191 #'directory-name-p
192 (lambda (name)
193 "Return non-nil if NAME ends with a directory separator character."
194 (let ((len (length name))
195 (lastc ?.))
196 (if (> len 0)
197 (setq lastc (aref name (1- len))))
198 (or (= lastc ?/)
199 (and (memq system-type '(windows-nt ms-dos))
200 (= lastc ?\\)))))))
201
202;; `file-missing' is introduced in Emacs 26.1. 176;; `file-missing' is introduced in Emacs 26.1.
203(defconst tramp-file-missing 177(defconst tramp-file-missing
204 (if (get 'file-missing 'error-conditions) 'file-missing 'file-error) 178 (if (get 'file-missing 'error-conditions) 'file-missing 'file-error)
@@ -266,13 +240,6 @@ NAME is unquoted."
266 ((eq tramp-syntax 'sep) 'separate) 240 ((eq tramp-syntax 'sep) 'separate)
267 (t tramp-syntax))) 241 (t tramp-syntax)))
268 242
269;; `cl-struct-slot-info' has been introduced with Emacs 25.
270(defmacro tramp-compat-tramp-file-name-slots ()
271 "Return a list of slot names."
272 (if (fboundp 'cl-struct-slot-info)
273 '(cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name)))
274 '(cdr (mapcar #'car (get 'tramp-file-name 'cl-struct-slots)))))
275
276;; The signature of `tramp-make-tramp-file-name' has been changed. 243;; The signature of `tramp-make-tramp-file-name' has been changed.
277;; Therefore, we cannot use `url-tramp-convert-url-to-tramp' prior 244;; Therefore, we cannot use `url-tramp-convert-url-to-tramp' prior
278;; Emacs 26.1. We use `temporary-file-directory' as indicator. 245;; Emacs 26.1. We use `temporary-file-directory' as indicator.
@@ -285,10 +252,9 @@ NAME is unquoted."
285 #'exec-path 252 #'exec-path
286 (lambda () 253 (lambda ()
287 "List of directories to search programs to run in remote subprocesses." 254 "List of directories to search programs to run in remote subprocesses."
288 (let ((handler (find-file-name-handler default-directory 'exec-path))) 255 (if-let ((handler (find-file-name-handler default-directory 'exec-path)))
289 (if handler 256 (funcall handler 'exec-path)
290 (funcall handler 'exec-path) 257 exec-path))))
291 exec-path)))))
292 258
293;; `time-equal-p' has appeared in Emacs 27.1. 259;; `time-equal-p' has appeared in Emacs 27.1.
294(defalias 'tramp-compat-time-equal-p 260(defalias 'tramp-compat-time-equal-p
@@ -328,11 +294,6 @@ A nil value for either argument stands for the current time."
328 (unload-feature 'tramp-loaddefs 'force) 294 (unload-feature 'tramp-loaddefs 'force)
329 (unload-feature 'tramp-compat 'force))) 295 (unload-feature 'tramp-compat 'force)))
330 296
331;;; TODO:
332;;
333;; * Starting with Emacs 25.1, replace `tramp-message-show-message' by
334;; the reverse of `inhibit-message'.
335
336(provide 'tramp-compat) 297(provide 'tramp-compat)
337 298
338;;; tramp-compat.el ends here 299;;; tramp-compat.el ends here
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 34a234c47f0..67135e30d64 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -457,7 +457,7 @@ It has been changed in GVFS 1.14.")
457;; </interface> 457;; </interface>
458 458
459;; The basic structure for GNOME Online Accounts. We use a list :type, 459;; The basic structure for GNOME Online Accounts. We use a list :type,
460;; in order to be compatible with Emacs 24 and 25. 460;; in order to be compatible with Emacs 25.
461(cl-defstruct (tramp-goa-name (:type list) :named) method user host port) 461(cl-defstruct (tramp-goa-name (:type list) :named) method user host port)
462 462
463;; "gvfs-<command>" utilities have been deprecated in GVFS 1.31.1. We 463;; "gvfs-<command>" utilities have been deprecated in GVFS 1.31.1. We
@@ -625,10 +625,9 @@ First arg specifies the OPERATION, second arg is a list of arguments to
625pass to the OPERATION." 625pass to the OPERATION."
626 (unless tramp-gvfs-enabled 626 (unless tramp-gvfs-enabled
627 (tramp-user-error nil "Package `tramp-gvfs' not supported")) 627 (tramp-user-error nil "Package `tramp-gvfs' not supported"))
628 (let ((fn (assoc operation tramp-gvfs-file-name-handler-alist))) 628 (if-let ((fn (assoc operation tramp-gvfs-file-name-handler-alist)))
629 (if fn 629 (save-match-data (apply (cdr fn) args))
630 (save-match-data (apply (cdr fn) args)) 630 (tramp-run-real-handler operation args)))
631 (tramp-run-real-handler operation args))))
632 631
633;;;###tramp-autoload 632;;;###tramp-autoload
634(when (featurep 'dbusbind) 633(when (featurep 'dbusbind)
@@ -649,13 +648,12 @@ pass to the OPERATION."
649 "Like `dbus-byte-array-to-string' but remove trailing \\0 if exists. 648 "Like `dbus-byte-array-to-string' but remove trailing \\0 if exists.
650Return nil for null BYTE-ARRAY." 649Return nil for null BYTE-ARRAY."
651 ;; The byte array could be a variant. Take care. 650 ;; The byte array could be a variant. Take care.
652 (let ((byte-array 651 (when-let ((byte-array
653 (if (and (consp byte-array) (atom (car byte-array))) 652 (if (and (consp byte-array) (atom (car byte-array)))
654 byte-array (car byte-array)))) 653 byte-array (car byte-array))))
655 (and byte-array 654 (dbus-byte-array-to-string
656 (dbus-byte-array-to-string 655 (if (and (consp byte-array) (zerop (car (last byte-array))))
657 (if (and (consp byte-array) (zerop (car (last byte-array)))) 656 (butlast byte-array) byte-array))))
658 (butlast byte-array) byte-array)))))
659 657
660(defun tramp-gvfs-stringify-dbus-message (message) 658(defun tramp-gvfs-stringify-dbus-message (message)
661 "Convert a D-Bus MESSAGE into readable UTF8 strings, used for traces." 659 "Convert a D-Bus MESSAGE into readable UTF8 strings, used for traces."
@@ -680,6 +678,8 @@ The call will be traced by Tramp with trace level 6."
680 (tramp-message vec 6 "%s" result(tramp-gvfs-stringify-dbus-message result)) 678 (tramp-message vec 6 "%s" result(tramp-gvfs-stringify-dbus-message result))
681 result)) 679 result))
682 680
681(put #'tramp-dbus-function 'tramp-suppress-trace t)
682
683(defmacro with-tramp-dbus-call-method 683(defmacro with-tramp-dbus-call-method
684 (vec synchronous bus service path interface method &rest args) 684 (vec synchronous bus service path interface method &rest args)
685 "Apply a D-Bus call on bus BUS. 685 "Apply a D-Bus call on bus BUS.
@@ -689,14 +689,13 @@ it is an asynchronous call, with `ignore' as callback function.
689 689
690The other arguments have the same meaning as with `dbus-call-method' 690The other arguments have the same meaning as with `dbus-call-method'
691or `dbus-call-method-asynchronously'." 691or `dbus-call-method-asynchronously'."
692 (declare (indent 2) (debug t))
692 `(let ((func (if ,synchronous 693 `(let ((func (if ,synchronous
693 #'dbus-call-method #'dbus-call-method-asynchronously)) 694 #'dbus-call-method #'dbus-call-method-asynchronously))
694 (args (append (list ,bus ,service ,path ,interface ,method) 695 (args (append (list ,bus ,service ,path ,interface ,method)
695 (if ,synchronous (list ,@args) (list 'ignore ,@args))))) 696 (if ,synchronous (list ,@args) (list 'ignore ,@args)))))
696 (tramp-dbus-function ,vec func args))) 697 (tramp-dbus-function ,vec func args)))
697 698
698(put 'with-tramp-dbus-call-method 'lisp-indent-function 2)
699(put 'with-tramp-dbus-call-method 'edebug-form-spec '(form symbolp body))
700(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-dbus-call-method\\>")) 699(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-dbus-call-method\\>"))
701 700
702(defmacro with-tramp-dbus-get-all-properties 701(defmacro with-tramp-dbus-get-all-properties
@@ -704,6 +703,7 @@ or `dbus-call-method-asynchronously'."
704 "Return all properties of INTERFACE. 703 "Return all properties of INTERFACE.
705The call will be traced by Tramp with trace level 6." 704The call will be traced by Tramp with trace level 6."
706 ;; Check, that interface exists at object path. Retrieve properties. 705 ;; Check, that interface exists at object path. Retrieve properties.
706 (declare (indent 1) (debug t))
707 `(when (member 707 `(when (member
708 ,interface 708 ,interface
709 (tramp-dbus-function 709 (tramp-dbus-function
@@ -712,8 +712,6 @@ The call will be traced by Tramp with trace level 6."
712 (tramp-dbus-function 712 (tramp-dbus-function
713 ,vec #'dbus-get-all-properties (list ,bus ,service ,path ,interface)))) 713 ,vec #'dbus-get-all-properties (list ,bus ,service ,path ,interface))))
714 714
715(put 'with-tramp-dbus-get-all-properties 'lisp-indent-function 1)
716(put 'with-tramp-dbus-get-all-properties 'edebug-form-spec '(form symbolp body))
717(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-dbus-get-all-properties\\>")) 715(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-dbus-get-all-properties\\>"))
718 716
719(defvar tramp-gvfs-dbus-event-vector nil 717(defvar tramp-gvfs-dbus-event-vector nil
@@ -772,7 +770,7 @@ file names."
772 (when (and (not ok-if-already-exists) (file-exists-p newname)) 770 (when (and (not ok-if-already-exists) (file-exists-p newname))
773 (tramp-error v 'file-already-exists newname)) 771 (tramp-error v 'file-already-exists newname))
774 (when (and (file-directory-p newname) 772 (when (and (file-directory-p newname)
775 (not (tramp-compat-directory-name-p newname))) 773 (not (directory-name-p newname)))
776 (tramp-error v 'file-error "File is a directory %s" newname)) 774 (tramp-error v 'file-error "File is a directory %s" newname))
777 775
778 (if (or (and equal-remote 776 (if (or (and equal-remote
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 0d1ef0f0e91..3e029e44ff5 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -157,10 +157,9 @@ Operations not mentioned here will be handled by the default Emacs primitives.")
157 "Invoke the rclone handler for OPERATION and ARGS. 157 "Invoke the rclone handler for OPERATION and ARGS.
158First arg specifies the OPERATION, second arg is a list of arguments to 158First arg specifies the OPERATION, second arg is a list of arguments to
159pass to the OPERATION." 159pass to the OPERATION."
160 (let ((fn (assoc operation tramp-rclone-file-name-handler-alist))) 160 (if-let ((fn (assoc operation tramp-rclone-file-name-handler-alist)))
161 (if fn 161 (save-match-data (apply (cdr fn) args))
162 (save-match-data (apply (cdr fn) args)) 162 (tramp-run-real-handler operation args)))
163 (tramp-run-real-handler operation args))))
164 163
165;;;###tramp-autoload 164;;;###tramp-autoload
166(tramp--with-startup 165(tramp--with-startup
@@ -220,7 +219,7 @@ file names."
220 (when (and (not ok-if-already-exists) (file-exists-p newname)) 219 (when (and (not ok-if-already-exists) (file-exists-p newname))
221 (tramp-error v 'file-already-exists newname)) 220 (tramp-error v 'file-already-exists newname))
222 (when (and (file-directory-p newname) 221 (when (and (file-directory-p newname)
223 (not (tramp-compat-directory-name-p newname))) 222 (not (directory-name-p newname)))
224 (tramp-error v 'file-error "File is a directory %s" newname)) 223 (tramp-error v 'file-error "File is a directory %s" newname))
225 224
226 (if (or (and t1 (not (tramp-rclone-file-name-p filename))) 225 (if (or (and t1 (not (tramp-rclone-file-name-p filename)))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 4ca1f651734..5f2c1ad3d56 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1114,8 +1114,7 @@ component is used as the target of the symlink."
1114 "Like `file-truename' for Tramp files." 1114 "Like `file-truename' for Tramp files."
1115 ;; Preserve trailing "/". 1115 ;; Preserve trailing "/".
1116 (funcall 1116 (funcall
1117 (if (tramp-compat-directory-name-p filename) 1117 (if (directory-name-p filename) #'file-name-as-directory #'identity)
1118 #'file-name-as-directory #'identity)
1119 ;; Quote properly. 1118 ;; Quote properly.
1120 (funcall 1119 (funcall
1121 (if (tramp-compat-file-name-quoted-p filename) 1120 (if (tramp-compat-file-name-quoted-p filename)
@@ -1273,8 +1272,8 @@ component is used as the target of the symlink."
1273(defun tramp-do-file-attributes-with-ls (vec localname &optional id-format) 1272(defun tramp-do-file-attributes-with-ls (vec localname &optional id-format)
1274 "Implement `file-attributes' for Tramp files using the ls(1) command." 1273 "Implement `file-attributes' for Tramp files using the ls(1) command."
1275 (let (symlinkp dirp 1274 (let (symlinkp dirp
1276 res-inode res-filemodes res-numlinks 1275 res-inode res-filemodes res-numlinks
1277 res-uid res-gid res-size res-symlink-target) 1276 res-uid res-gid res-size res-symlink-target)
1278 (tramp-message vec 5 "file attributes with ls: %s" localname) 1277 (tramp-message vec 5 "file attributes with ls: %s" localname)
1279 ;; We cannot send all three commands combined, it could exceed 1278 ;; We cannot send all three commands combined, it could exceed
1280 ;; NAME_MAX or PATH_MAX. Happened on macOS, for example. 1279 ;; NAME_MAX or PATH_MAX. Happened on macOS, for example.
@@ -1958,7 +1957,7 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1958 ;; scp or rsync DTRT. 1957 ;; scp or rsync DTRT.
1959 (progn 1958 (progn
1960 (when (and (file-directory-p newname) 1959 (when (and (file-directory-p newname)
1961 (not (tramp-compat-directory-name-p newname))) 1960 (not (directory-name-p newname)))
1962 (tramp-error v 'file-already-exists newname)) 1961 (tramp-error v 'file-already-exists newname))
1963 (setq dirname (directory-file-name (expand-file-name dirname)) 1962 (setq dirname (directory-file-name (expand-file-name dirname))
1964 newname (directory-file-name (expand-file-name newname))) 1963 newname (directory-file-name (expand-file-name newname)))
@@ -2040,7 +2039,7 @@ file names."
2040 (when (and (not ok-if-already-exists) (file-exists-p newname)) 2039 (when (and (not ok-if-already-exists) (file-exists-p newname))
2041 (tramp-error v 'file-already-exists newname)) 2040 (tramp-error v 'file-already-exists newname))
2042 (when (and (file-directory-p newname) 2041 (when (and (file-directory-p newname)
2043 (not (tramp-compat-directory-name-p newname))) 2042 (not (directory-name-p newname)))
2044 (tramp-error v 'file-error "File is a directory %s" newname)) 2043 (tramp-error v 'file-error "File is a directory %s" newname))
2045 2044
2046 (with-tramp-progress-reporter 2045 (with-tramp-progress-reporter
@@ -2724,7 +2723,7 @@ The method used must be an out-of-band method."
2724 (when (file-symlink-p filename) 2723 (when (file-symlink-p filename)
2725 (goto-char (search-backward "->" beg 'noerror))) 2724 (goto-char (search-backward "->" beg 'noerror)))
2726 (search-backward 2725 (search-backward
2727 (if (tramp-compat-directory-name-p filename) 2726 (if (directory-name-p filename)
2728 "." 2727 "."
2729 (file-name-nondirectory filename)) 2728 (file-name-nondirectory filename))
2730 beg 'noerror) 2729 beg 'noerror)
@@ -2734,12 +2733,11 @@ The method used must be an out-of-band method."
2734 (goto-char (point-min)) 2733 (goto-char (point-min))
2735 ;; First find the line to put it on. 2734 ;; First find the line to put it on.
2736 (when (re-search-forward "^\\([[:space:]]*total\\)" nil t) 2735 (when (re-search-forward "^\\([[:space:]]*total\\)" nil t)
2737 (let ((available (get-free-disk-space "."))) 2736 (when-let ((available (get-free-disk-space ".")))
2738 (when available 2737 ;; Replace "total" with "total used", to avoid confusion.
2739 ;; Replace "total" with "total used", to avoid confusion. 2738 (replace-match "\\1 used in directory")
2740 (replace-match "\\1 used in directory") 2739 (end-of-line)
2741 (end-of-line) 2740 (insert " available " available)))
2742 (insert " available " available))))
2743 2741
2744 (goto-char (point-max))))))) 2742 (goto-char (point-max)))))))
2745 2743
@@ -3501,8 +3499,7 @@ STDERR can also be a file name."
3501(defun tramp-sh-handle-vc-registered (file) 3499(defun tramp-sh-handle-vc-registered (file)
3502 "Like `vc-registered' for Tramp files." 3500 "Like `vc-registered' for Tramp files."
3503 (when vc-handled-backends 3501 (when vc-handled-backends
3504 (let ((tramp-message-show-message 3502 (let ((inhibit-message (or revert-buffer-in-progress-p inhibit-message))
3505 (and (not revert-buffer-in-progress-p) tramp-message-show-message))
3506 (temp-message (unless revert-buffer-in-progress-p ""))) 3503 (temp-message (unless revert-buffer-in-progress-p "")))
3507 (with-temp-message temp-message 3504 (with-temp-message temp-message
3508 (with-parsed-tramp-file-name file nil 3505 (with-parsed-tramp-file-name file nil
@@ -3592,10 +3589,9 @@ STDERR can also be a file name."
3592(defun tramp-sh-file-name-handler (operation &rest args) 3589(defun tramp-sh-file-name-handler (operation &rest args)
3593 "Invoke remote-shell Tramp file name handler. 3590 "Invoke remote-shell Tramp file name handler.
3594Fall back to normal file name handler if no Tramp handler exists." 3591Fall back to normal file name handler if no Tramp handler exists."
3595 (let ((fn (assoc operation tramp-sh-file-name-handler-alist))) 3592 (if-let ((fn (assoc operation tramp-sh-file-name-handler-alist)))
3596 (if fn 3593 (save-match-data (apply (cdr fn) args))
3597 (save-match-data (apply (cdr fn) args)) 3594 (tramp-run-real-handler operation args)))
3598 (tramp-run-real-handler operation args))))
3599 3595
3600;; This must be the last entry, because `identity' always matches. 3596;; This must be the last entry, because `identity' always matches.
3601;;;###tramp-autoload 3597;;;###tramp-autoload
@@ -4883,11 +4879,8 @@ connection if a previous connection has died for some reason."
4883 (not (tramp-file-name-equal-p 4879 (not (tramp-file-name-equal-p
4884 vec (car tramp-current-connection))) 4880 vec (car tramp-current-connection)))
4885 (time-less-p 4881 (time-less-p
4886 ;; `current-time' can be removed once we get rid of Emacs 24. 4882 (time-since (cdr tramp-current-connection))
4887 (time-since (or (cdr tramp-current-connection) (current-time))) 4883 (or tramp-connection-min-time-diff 0)))
4888 ;; `seconds-to-time' can be removed once we get rid
4889 ;; of Emacs 24.
4890 (seconds-to-time (or tramp-connection-min-time-diff 0))))
4891 (throw 'suppress 'suppress)) 4884 (throw 'suppress 'suppress))
4892 4885
4893 ;; If too much time has passed since last command was sent, look 4886 ;; If too much time has passed since last command was sent, look
@@ -4898,11 +4891,9 @@ connection if a previous connection has died for some reason."
4898 ;; try to send a command from time to time, then look again 4891 ;; try to send a command from time to time, then look again
4899 ;; whether the process is really alive. 4892 ;; whether the process is really alive.
4900 (condition-case nil 4893 (condition-case nil
4901 ;; `seconds-to-time' can be removed once we get rid of Emacs 24. 4894 (when (and (time-less-p
4902 (when (and (time-less-p (seconds-to-time 60) 4895 60 (time-since
4903 (time-since 4896 (tramp-get-connection-property p "last-cmd-time" 0)))
4904 (tramp-get-connection-property
4905 p "last-cmd-time" (seconds-to-time 0))))
4906 (process-live-p p)) 4897 (process-live-p p))
4907 (tramp-send-command vec "echo are you awake" t t) 4898 (tramp-send-command vec "echo are you awake" t t)
4908 (unless (and (process-live-p p) 4899 (unless (and (process-live-p p)
@@ -5995,9 +5986,6 @@ function cell is returned to be applied on a buffer."
5995;; likely to produce long command lines, and some shells choke on 5986;; likely to produce long command lines, and some shells choke on
5996;; long command lines. 5987;; long command lines.
5997;; 5988;;
5998;; * Don't search for perl5 and perl. Instead, only search for perl and
5999;; then look if it's the right version (with `perl -v').
6000;;
6001;; * When editing a remote CVS controlled file as a different user, VC 5989;; * When editing a remote CVS controlled file as a different user, VC
6002;; gets confused about the file locking status. Try to find out why 5990;; gets confused about the file locking status. Try to find out why
6003;; the workaround doesn't work. 5991;; the workaround doesn't work.
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index d233af124e8..f02be394a7b 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -329,10 +329,9 @@ This can be used to disable echo etc."
329 "Invoke the SMB related OPERATION and ARGS. 329 "Invoke the SMB related OPERATION and ARGS.
330First arg specifies the OPERATION, second arg is a list of arguments to 330First arg specifies the OPERATION, second arg is a list of arguments to
331pass to the OPERATION." 331pass to the OPERATION."
332 (let ((fn (assoc operation tramp-smb-file-name-handler-alist))) 332 (if-let ((fn (assoc operation tramp-smb-file-name-handler-alist)))
333 (if fn 333 (save-match-data (apply (cdr fn) args))
334 (save-match-data (apply (cdr fn) args)) 334 (tramp-run-real-handler operation args)))
335 (tramp-run-real-handler operation args))))
336 335
337;;;###tramp-autoload 336;;;###tramp-autoload
338(unless (memq system-type '(cygwin windows-nt)) 337(unless (memq system-type '(cygwin windows-nt))
@@ -420,7 +419,7 @@ pass to the OPERATION."
420 v tramp-file-missing 419 v tramp-file-missing
421 "Copying directory" "No such file or directory" dirname)) 420 "Copying directory" "No such file or directory" dirname))
422 (when (and (file-directory-p newname) 421 (when (and (file-directory-p newname)
423 (not (tramp-compat-directory-name-p newname))) 422 (not (directory-name-p newname)))
424 (tramp-error v 'file-already-exists newname)) 423 (tramp-error v 'file-already-exists newname))
425 (cond 424 (cond
426 ;; We must use a local temporary directory. 425 ;; We must use a local temporary directory.
@@ -581,40 +580,39 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
581 tramp-file-missing 580 tramp-file-missing
582 "Copying file" "No such file or directory" filename)) 581 "Copying file" "No such file or directory" filename))
583 582
584 (let ((tmpfile (file-local-copy filename))) 583 (if-let ((tmpfile (file-local-copy filename)))
585 (if tmpfile 584 ;; Remote filename.
586 ;; Remote filename. 585 (condition-case err
587 (condition-case err 586 (rename-file tmpfile newname ok-if-already-exists)
588 (rename-file tmpfile newname ok-if-already-exists) 587 ((error quit)
589 ((error quit) 588 (delete-file tmpfile)
590 (delete-file tmpfile) 589 (signal (car err) (cdr err))))
591 (signal (car err) (cdr err)))) 590
592 591 ;; Remote newname.
593 ;; Remote newname. 592 (when (and (file-directory-p newname)
593 (directory-name-p newname))
594 (setq newname
595 (expand-file-name (file-name-nondirectory filename) newname)))
596
597 (with-parsed-tramp-file-name newname nil
598 (when (and (not ok-if-already-exists) (file-exists-p newname))
599 (tramp-error v 'file-already-exists newname))
594 (when (and (file-directory-p newname) 600 (when (and (file-directory-p newname)
595 (tramp-compat-directory-name-p newname)) 601 (not (directory-name-p newname)))
596 (setq newname 602 (tramp-error v 'file-error "File is a directory %s" newname))
597 (expand-file-name (file-name-nondirectory filename) newname)))
598 603
599 (with-parsed-tramp-file-name newname nil 604 ;; We must also flush the cache of the directory, because
600 (when (and (not ok-if-already-exists) (file-exists-p newname)) 605 ;; `file-attributes' reads the values from there.
601 (tramp-error v 'file-already-exists newname)) 606 (tramp-flush-file-properties v localname)
602 (when (and (file-directory-p newname) 607 (unless (tramp-smb-get-share v)
603 (not (tramp-compat-directory-name-p newname))) 608 (tramp-error
604 (tramp-error v 'file-error "File is a directory %s" newname)) 609 v 'file-error "Target `%s' must contain a share name" newname))
605 610 (unless (tramp-smb-send-command
606 ;; We must also flush the cache of the directory, because 611 v (format "put \"%s\" \"%s\""
607 ;; `file-attributes' reads the values from there. 612 (tramp-compat-file-name-unquote filename)
608 (tramp-flush-file-properties v localname) 613 (tramp-smb-get-localname v)))
609 (unless (tramp-smb-get-share v) 614 (tramp-error
610 (tramp-error 615 v 'file-error "Cannot copy `%s' to `%s'" filename newname)))))
611 v 'file-error "Target `%s' must contain a share name" newname))
612 (unless (tramp-smb-send-command
613 v (format "put \"%s\" \"%s\""
614 (tramp-compat-file-name-unquote filename)
615 (tramp-smb-get-localname v)))
616 (tramp-error
617 v 'file-error "Cannot copy `%s' to `%s'" filename newname))))))
618 616
619 ;; KEEP-DATE handling. 617 ;; KEEP-DATE handling.
620 (when keep-date 618 (when keep-date
@@ -1003,7 +1001,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1003 (setq filename (expand-file-name filename)) 1001 (setq filename (expand-file-name filename))
1004 (unless switches (setq switches "")) 1002 (unless switches (setq switches ""))
1005 ;; Mark trailing "/". 1003 ;; Mark trailing "/".
1006 (when (and (tramp-compat-directory-name-p filename) 1004 (when (and (directory-name-p filename)
1007 (not full-directory-p)) 1005 (not full-directory-p))
1008 (setq switches (concat switches "F"))) 1006 (setq switches (concat switches "F")))
1009 (if full-directory-p 1007 (if full-directory-p
@@ -1355,7 +1353,7 @@ component is used as the target of the symlink."
1355 (when (and (not ok-if-already-exists) (file-exists-p newname)) 1353 (when (and (not ok-if-already-exists) (file-exists-p newname))
1356 (tramp-error v 'file-already-exists newname)) 1354 (tramp-error v 'file-already-exists newname))
1357 (when (and (file-directory-p newname) 1355 (when (and (file-directory-p newname)
1358 (not (tramp-compat-directory-name-p newname))) 1356 (not (directory-name-p newname)))
1359 (tramp-error v 'file-error "File is a directory %s" newname)) 1357 (tramp-error v 'file-error "File is a directory %s" newname))
1360 1358
1361 (with-tramp-progress-reporter 1359 (with-tramp-progress-reporter
@@ -1922,11 +1920,9 @@ If ARGUMENT is non-nil, use it as argument for
1922 ;; connection timeout. 1920 ;; connection timeout.
1923 (with-current-buffer buf 1921 (with-current-buffer buf
1924 (goto-char (point-min)) 1922 (goto-char (point-min))
1925 ;; `seconds-to-time' can be removed once we get rid of Emacs 24. 1923 (when (and (time-less-p
1926 (when (and (time-less-p (seconds-to-time 60) 1924 60 (time-since
1927 (time-since 1925 (tramp-get-connection-property p "last-cmd-time" 0)))
1928 (tramp-get-connection-property
1929 p "last-cmd-time" (seconds-to-time 0))))
1930 (process-live-p p) 1926 (process-live-p p)
1931 (re-search-forward tramp-smb-errors nil t)) 1927 (re-search-forward tramp-smb-errors nil t))
1932 (delete-process p) 1928 (delete-process p)
@@ -1992,7 +1988,7 @@ If ARGUMENT is non-nil, use it as argument for
1992 (set-process-query-on-exit-flag p nil) 1988 (set-process-query-on-exit-flag p nil)
1993 1989
1994 (condition-case err 1990 (condition-case err
1995 (let (tramp-message-show-message) 1991 (let ((inhibit-message t))
1996 ;; Play login scenario. 1992 ;; Play login scenario.
1997 (tramp-process-actions 1993 (tramp-process-actions
1998 p vec nil 1994 p vec nil
@@ -2130,7 +2126,5 @@ Removes smb prompt. Returns nil if an error message has appeared."
2130;; 2126;;
2131;; * Try to remove the inclusion of dummy "" directory. Seems to be at 2127;; * Try to remove the inclusion of dummy "" directory. Seems to be at
2132;; several places, especially in `tramp-smb-handle-insert-directory'. 2128;; several places, especially in `tramp-smb-handle-insert-directory'.
2133;;
2134;; * Ignore case in file names.
2135 2129
2136;;; tramp-smb.el ends here 2130;;; tramp-smb.el ends here
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index e5590b8cf6c..9f08d5f1e64 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -153,10 +153,9 @@ See `tramp-actions-before-shell' for more info.")
153 "Invoke the SUDOEDIT handler for OPERATION and ARGS. 153 "Invoke the SUDOEDIT handler for OPERATION and ARGS.
154First arg specifies the OPERATION, second arg is a list of arguments to 154First arg specifies the OPERATION, second arg is a list of arguments to
155pass to the OPERATION." 155pass to the OPERATION."
156 (let ((fn (assoc operation tramp-sudoedit-file-name-handler-alist))) 156 (if-let ((fn (assoc operation tramp-sudoedit-file-name-handler-alist)))
157 (if fn 157 (save-match-data (apply (cdr fn) args))
158 (save-match-data (apply (cdr fn) args)) 158 (tramp-run-real-handler operation args)))
159 (tramp-run-real-handler operation args))))
160 159
161;;;###tramp-autoload 160;;;###tramp-autoload
162(tramp--with-startup 161(tramp--with-startup
@@ -248,7 +247,7 @@ absolute file names."
248 (when (and (not ok-if-already-exists) (file-exists-p newname)) 247 (when (and (not ok-if-already-exists) (file-exists-p newname))
249 (tramp-error v 'file-already-exists newname)) 248 (tramp-error v 'file-already-exists newname))
250 (when (and (file-directory-p newname) 249 (when (and (file-directory-p newname)
251 (not (tramp-compat-directory-name-p newname))) 250 (not (directory-name-p newname)))
252 (tramp-error v 'file-error "File is a directory %s" newname)) 251 (tramp-error v 'file-error "File is a directory %s" newname))
253 252
254 (if (or (and (file-remote-p filename) (not t1)) 253 (if (or (and (file-remote-p filename) (not t1))
@@ -541,8 +540,7 @@ the result will be a local, non-Tramp, file name."
541 "Like `file-truename' for Tramp files." 540 "Like `file-truename' for Tramp files."
542 ;; Preserve trailing "/". 541 ;; Preserve trailing "/".
543 (funcall 542 (funcall
544 (if (tramp-compat-directory-name-p filename) 543 (if (directory-name-p filename) #'file-name-as-directory #'identity)
545 #'file-name-as-directory #'identity)
546 ;; Quote properly. 544 ;; Quote properly.
547 (funcall 545 (funcall
548 (if (tramp-compat-file-name-quoted-p filename) 546 (if (tramp-compat-file-name-quoted-p filename)
diff --git a/lisp/net/tramp-uu.el b/lisp/net/tramp-uu.el
index 6a044e58840..f368f72a8dc 100644
--- a/lisp/net/tramp-uu.el
+++ b/lisp/net/tramp-uu.el
@@ -94,8 +94,3 @@
94(provide 'tramp-uu) 94(provide 'tramp-uu)
95 95
96;;; tramp-uu.el ends here 96;;; tramp-uu.el ends here
97
98;; Local Variables:
99;; mode: Emacs-Lisp
100;; coding: utf-8
101;; End:
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a7c9b34d29d..900c15ffae9 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -7,8 +7,8 @@
7;; Maintainer: Michael Albinus <michael.albinus@gmx.de> 7;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
8;; Keywords: comm, processes 8;; Keywords: comm, processes
9;; Package: tramp 9;; Package: tramp
10;; Version: 2.4.4-pre 10;; Version: 2.5.0-pre
11;; Package-Requires: ((emacs "24.4")) 11;; Package-Requires: ((emacs "25.1"))
12;; Package-Type: multi 12;; Package-Type: multi
13;; URL: https://savannah.gnu.org/projects/tramp 13;; URL: https://savannah.gnu.org/projects/tramp
14 14
@@ -1258,7 +1258,7 @@ calling HANDLER.")
1258;; data structure. 1258;; data structure.
1259 1259
1260;; The basic structure for remote file names. We use a list :type, 1260;; The basic structure for remote file names. We use a list :type,
1261;; in order to be compatible with Emacs 24 and 25. 1261;; in order to be compatible with Emacs 25.
1262(cl-defstruct (tramp-file-name (:type list) :named) 1262(cl-defstruct (tramp-file-name (:type list) :named)
1263 method user domain host port localname hop) 1263 method user domain host port localname hop)
1264 1264
@@ -1306,9 +1306,10 @@ entry does not exist, return nil."
1306 ;; We use the cached property. 1306 ;; We use the cached property.
1307 (tramp-get-connection-property vec hash-entry nil) 1307 (tramp-get-connection-property vec hash-entry nil)
1308 ;; Use the static value from `tramp-methods'. 1308 ;; Use the static value from `tramp-methods'.
1309 (let ((methods-entry 1309 (when-let ((methods-entry
1310 (assoc param (assoc (tramp-file-name-method vec) tramp-methods)))) 1310 (assoc
1311 (when methods-entry (cadr methods-entry)))))) 1311 param (assoc (tramp-file-name-method vec) tramp-methods))))
1312 (cadr methods-entry)))))
1312 1313
1313;; The localname can be quoted with "/:". Extract this. 1314;; The localname can be quoted with "/:". Extract this.
1314(defun tramp-file-name-unquote-localname (vec) 1315(defun tramp-file-name-unquote-localname (vec)
@@ -1473,7 +1474,7 @@ default values are used."
1473 :method method :user user :domain domain :host host 1474 :method method :user user :domain domain :host host
1474 :port port :localname localname :hop hop)) 1475 :port port :localname localname :hop hop))
1475 ;; The method must be known. 1476 ;; The method must be known.
1476 (unless (or nodefault (tramp-completion-mode-p) 1477 (unless (or nodefault non-essential
1477 (string-equal method tramp-default-method-marker) 1478 (string-equal method tramp-default-method-marker)
1478 (assoc method tramp-methods)) 1479 (assoc method tramp-methods))
1479 (tramp-user-error 1480 (tramp-user-error
@@ -1749,29 +1750,10 @@ ARGUMENTS to actually emit the message (if applicable)."
1749 (setq btf (nth 1 (backtrace-frame btn))) 1750 (setq btf (nth 1 (backtrace-frame btn)))
1750 (if (not btf) 1751 (if (not btf)
1751 (setq fn "") 1752 (setq fn "")
1752 (when (symbolp btf) 1753 (and (symbolp btf) (setq fn (symbol-name btf))
1753 (setq fn (symbol-name btf)) 1754 (or (not (string-match-p "^tramp" fn))
1754 (unless 1755 (get btf 'tramp-suppress-trace))
1755 (and 1756 (setq fn nil))
1756 (string-match-p "^tramp" fn)
1757 (not
1758 (string-match-p
1759 (eval-when-compile
1760 (concat
1761 "^"
1762 (regexp-opt
1763 '("tramp-backtrace"
1764 "tramp-compat-funcall"
1765 "tramp-debug-message"
1766 "tramp-error"
1767 "tramp-error-with-buffer"
1768 "tramp-message"
1769 "tramp-signal-hook-function"
1770 "tramp-user-error")
1771 t)
1772 "$"))
1773 fn)))
1774 (setq fn nil)))
1775 (setq btn (1+ btn)))) 1757 (setq btn (1+ btn))))
1776 ;; The following code inserts filename and line number. Should 1758 ;; The following code inserts filename and line number. Should
1777 ;; be inactive by default, because it is time consuming. 1759 ;; be inactive by default, because it is time consuming.
@@ -1786,11 +1768,7 @@ ARGUMENTS to actually emit the message (if applicable)."
1786 ;; The message. 1768 ;; The message.
1787 (insert (apply #'format-message fmt-string arguments)))) 1769 (insert (apply #'format-message fmt-string arguments))))
1788 1770
1789(defvar tramp-message-show-message (null noninteractive) 1771(put #'tramp-debug-message 'tramp-suppress-trace t)
1790 "Show Tramp message in the minibuffer.
1791This variable is used to suppress progress reporter output, and
1792to disable messages from `tramp-error'. Those messages are
1793visible anyway, because an error is raised.")
1794 1772
1795(defsubst tramp-message (vec-or-proc level fmt-string &rest arguments) 1773(defsubst tramp-message (vec-or-proc level fmt-string &rest arguments)
1796 "Emit a message depending on verbosity level. 1774 "Emit a message depending on verbosity level.
@@ -1808,7 +1786,7 @@ applicable)."
1808 (ignore-errors 1786 (ignore-errors
1809 (when (<= level tramp-verbose) 1787 (when (<= level tramp-verbose)
1810 ;; Display only when there is a minimum level. 1788 ;; Display only when there is a minimum level.
1811 (when (and tramp-message-show-message (<= level 3)) 1789 (when (<= level 3)
1812 (apply #'message 1790 (apply #'message
1813 (concat 1791 (concat
1814 (cond 1792 (cond
@@ -1840,6 +1818,8 @@ applicable)."
1840 (concat (format "(%d) # " level) fmt-string) 1818 (concat (format "(%d) # " level) fmt-string)
1841 arguments)))))) 1819 arguments))))))
1842 1820
1821(put #'tramp-message 'tramp-suppress-trace t)
1822
1843(defsubst tramp-backtrace (&optional vec-or-proc) 1823(defsubst tramp-backtrace (&optional vec-or-proc)
1844 "Dump a backtrace into the debug buffer. 1824 "Dump a backtrace into the debug buffer.
1845If VEC-OR-PROC is nil, the buffer *debug tramp* is used. This 1825If VEC-OR-PROC is nil, the buffer *debug tramp* is used. This
@@ -1850,13 +1830,16 @@ function is meant for debugging purposes."
1850 vec-or-proc 10 "\n%s" (with-output-to-string (backtrace))) 1830 vec-or-proc 10 "\n%s" (with-output-to-string (backtrace)))
1851 (with-output-to-temp-buffer "*debug tramp*" (backtrace))))) 1831 (with-output-to-temp-buffer "*debug tramp*" (backtrace)))))
1852 1832
1833(put #'tramp-backtrace 'tramp-suppress-trace t)
1834
1853(defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments) 1835(defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments)
1854 "Emit an error. 1836 "Emit an error.
1855VEC-OR-PROC identifies the connection to use, SIGNAL is the 1837VEC-OR-PROC identifies the connection to use, SIGNAL is the
1856signal identifier to be raised, remaining arguments passed to 1838signal identifier to be raised, remaining arguments passed to
1857`tramp-message'. Finally, signal SIGNAL is raised with 1839`tramp-message'. Finally, signal SIGNAL is raised with
1858FMT-STRING and ARGUMENTS." 1840FMT-STRING and ARGUMENTS."
1859 (let (tramp-message-show-message signal-hook-function) 1841 (let ((inhibit-message t)
1842 signal-hook-function)
1860 (tramp-backtrace vec-or-proc) 1843 (tramp-backtrace vec-or-proc)
1861 (unless arguments 1844 (unless arguments
1862 ;; FMT-STRING could be just a file name, as in 1845 ;; FMT-STRING could be just a file name, as in
@@ -1874,6 +1857,8 @@ FMT-STRING and ARGUMENTS."
1874 (signal signal (list (substring-no-properties 1857 (signal signal (list (substring-no-properties
1875 (apply #'format-message fmt-string arguments)))))) 1858 (apply #'format-message fmt-string arguments))))))
1876 1859
1860(put #'tramp-error 'tramp-suppress-trace t)
1861
1877(defsubst tramp-error-with-buffer 1862(defsubst tramp-error-with-buffer
1878 (buf vec-or-proc signal fmt-string &rest arguments) 1863 (buf vec-or-proc signal fmt-string &rest arguments)
1879 "Emit an error, and show BUF. 1864 "Emit an error, and show BUF.
@@ -1891,13 +1876,13 @@ an input event arrives. The other arguments are passed to `tramp-error'."
1891 (apply #'tramp-error vec-or-proc signal fmt-string arguments) 1876 (apply #'tramp-error vec-or-proc signal fmt-string arguments)
1892 ;; Save exit. 1877 ;; Save exit.
1893 (when (and buf 1878 (when (and buf
1894 tramp-message-show-message
1895 (not (zerop tramp-verbose)) 1879 (not (zerop tramp-verbose))
1896 ;; Do not show when flagged from outside. 1880 ;; Do not show when flagged from outside.
1897 (not (tramp-completion-mode-p)) 1881 (not non-essential)
1898 ;; Show only when Emacs has started already. 1882 ;; Show only when Emacs has started already.
1899 (current-message)) 1883 (current-message))
1900 (let ((enable-recursive-minibuffers t)) 1884 (let ((enable-recursive-minibuffers t)
1885 inhibit-message)
1901 ;; `tramp-error' does not show messages. So we must do it 1886 ;; `tramp-error' does not show messages. So we must do it
1902 ;; ourselves. 1887 ;; ourselves.
1903 (apply #'message fmt-string arguments) 1888 (apply #'message fmt-string arguments)
@@ -1909,19 +1894,21 @@ an input event arrives. The other arguments are passed to `tramp-error'."
1909 (when (tramp-file-name-equal-p vec (car tramp-current-connection)) 1894 (when (tramp-file-name-equal-p vec (car tramp-current-connection))
1910 (setcdr tramp-current-connection (current-time))))))) 1895 (setcdr tramp-current-connection (current-time)))))))
1911 1896
1897(put #'tramp-error-with-buffer 'tramp-suppress-trace t)
1898
1912;; We must make it a defun, because it is used earlier already. 1899;; We must make it a defun, because it is used earlier already.
1913(defun tramp-user-error (vec-or-proc fmt-string &rest arguments) 1900(defun tramp-user-error (vec-or-proc fmt-string &rest arguments)
1914 "Signal a user error (or \"pilot error\")." 1901 "Signal a user error (or \"pilot error\")."
1915 (unwind-protect 1902 (unwind-protect
1916 (apply #'tramp-error vec-or-proc 'user-error fmt-string arguments) 1903 (apply #'tramp-error vec-or-proc 'user-error fmt-string arguments)
1917 ;; Save exit. 1904 ;; Save exit.
1918 (when (and tramp-message-show-message 1905 (when (and (not (zerop tramp-verbose))
1919 (not (zerop tramp-verbose))
1920 ;; Do not show when flagged from outside. 1906 ;; Do not show when flagged from outside.
1921 (not (tramp-completion-mode-p)) 1907 (not non-essential)
1922 ;; Show only when Emacs has started already. 1908 ;; Show only when Emacs has started already.
1923 (current-message)) 1909 (current-message))
1924 (let ((enable-recursive-minibuffers t)) 1910 (let ((enable-recursive-minibuffers t)
1911 inhibit-message)
1925 ;; `tramp-error' does not show messages. So we must do it ourselves. 1912 ;; `tramp-error' does not show messages. So we must do it ourselves.
1926 (apply #'message fmt-string arguments) 1913 (apply #'message fmt-string arguments)
1927 (discard-input) 1914 (discard-input)
@@ -1931,18 +1918,21 @@ an input event arrives. The other arguments are passed to `tramp-error'."
1931 (tramp-file-name-equal-p vec-or-proc (car tramp-current-connection)) 1918 (tramp-file-name-equal-p vec-or-proc (car tramp-current-connection))
1932 (setcdr tramp-current-connection (current-time))))))) 1919 (setcdr tramp-current-connection (current-time)))))))
1933 1920
1921(put #'tramp-user-error 'tramp-suppress-trace t)
1922
1934(defmacro tramp-with-demoted-errors (vec-or-proc format &rest body) 1923(defmacro tramp-with-demoted-errors (vec-or-proc format &rest body)
1935 "Execute BODY while redirecting the error message to `tramp-message'. 1924 "Execute BODY while redirecting the error message to `tramp-message'.
1936BODY is executed like wrapped by `with-demoted-errors'. FORMAT 1925BODY is executed like wrapped by `with-demoted-errors'. FORMAT
1937is a format-string containing a %-sequence meaning to substitute 1926is a format-string containing a %-sequence meaning to substitute
1938the resulting error message." 1927the resulting error message."
1939 (declare (debug (symbolp body)) 1928 (declare (indent 2) (debug (symbolp form body)))
1940 (indent 2))
1941 (let ((err (make-symbol "err"))) 1929 (let ((err (make-symbol "err")))
1942 `(condition-case-unless-debug ,err 1930 `(condition-case-unless-debug ,err
1943 (progn ,@body) 1931 (progn ,@body)
1944 (error (tramp-message ,vec-or-proc 3 ,format ,err) nil)))) 1932 (error (tramp-message ,vec-or-proc 3 ,format ,err) nil))))
1945 1933
1934(put #'tramp-with-demoted-errors 'tramp-suppress-trace t)
1935
1946;; This function provides traces in case of errors not triggered by 1936;; This function provides traces in case of errors not triggered by
1947;; Tramp functions. 1937;; Tramp functions.
1948(defun tramp-signal-hook-function (error-symbol data) 1938(defun tramp-signal-hook-function (error-symbol data)
@@ -1954,6 +1944,8 @@ the resulting error message."
1954 (car tramp-current-connection) error-symbol 1944 (car tramp-current-connection) error-symbol
1955 "%s" (mapconcat (lambda (x) (format "%s" x)) data " ")))) 1945 "%s" (mapconcat (lambda (x) (format "%s" x)) data " "))))
1956 1946
1947(put #'tramp-signal-hook-function 'tramp-suppress-trace t)
1948
1957(defmacro with-parsed-tramp-file-name (filename var &rest body) 1949(defmacro with-parsed-tramp-file-name (filename var &rest body)
1958 "Parse a Tramp filename and make components available in the body. 1950 "Parse a Tramp filename and make components available in the body.
1959 1951
@@ -1970,12 +1962,14 @@ Remaining args are Lisp expressions to be evaluated (inside an implicit
1970 1962
1971If VAR is nil, then we bind `v' to the structure and `method', `user', 1963If VAR is nil, then we bind `v' to the structure and `method', `user',
1972`domain', `host', `port', `localname', `hop' to the components." 1964`domain', `host', `port', `localname', `hop' to the components."
1965 (declare (indent 2) (debug (form symbolp body)))
1973 (let ((bindings 1966 (let ((bindings
1974 (mapcar (lambda (elem) 1967 (mapcar
1975 `(,(if var (intern (format "%s-%s" var elem)) elem) 1968 (lambda (elem)
1976 (,(intern (format "tramp-file-name-%s" elem)) 1969 `(,(if var (intern (format "%s-%s" var elem)) elem)
1977 ,(or var 'v)))) 1970 (,(intern (format "tramp-file-name-%s" elem))
1978 `,(tramp-compat-tramp-file-name-slots)))) 1971 ,(or var 'v))))
1972 (cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name))))))
1979 `(let* ((,(or var 'v) (tramp-dissect-file-name ,filename)) 1973 `(let* ((,(or var 'v) (tramp-dissect-file-name ,filename))
1980 ,@bindings) 1974 ,@bindings)
1981 ;; We don't know which of those vars will be used, so we bind them all, 1975 ;; We don't know which of those vars will be used, so we bind them all,
@@ -1984,8 +1978,6 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1984 (ignore ,@(mapcar #'car bindings)) 1978 (ignore ,@(mapcar #'car bindings))
1985 ,@body))) 1979 ,@body)))
1986 1980
1987(put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
1988(put 'with-parsed-tramp-file-name 'edebug-form-spec '(form symbolp body))
1989(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>")) 1981(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>"))
1990 1982
1991(defun tramp-progress-reporter-update (reporter &optional value suffix) 1983(defun tramp-progress-reporter-update (reporter &optional value suffix)
@@ -1996,22 +1988,20 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1996 (tramp-compat-progress-reporter-update reporter value suffix)))) 1988 (tramp-compat-progress-reporter-update reporter value suffix))))
1997 1989
1998(defmacro with-tramp-progress-reporter (vec level message &rest body) 1990(defmacro with-tramp-progress-reporter (vec level message &rest body)
1999 "Execute BODY, spinning a progress reporter with MESSAGE. 1991 "Execute BODY, spinning a progress reporter with MESSAGE in interactive mode.
2000If LEVEL does not fit for visible messages, there are only traces 1992If LEVEL does not fit for visible messages, there are only traces
2001without a visible progress reporter." 1993without a visible progress reporter."
2002 (declare (indent 3) (debug t)) 1994 (declare (indent 3) (debug t))
2003 `(progn 1995 `(if (or noninteractive inhibit-message)
1996 (progn ,@body)
2004 (tramp-message ,vec ,level "%s..." ,message) 1997 (tramp-message ,vec ,level "%s..." ,message)
2005 (let ((cookie "failed") 1998 (let ((cookie "failed")
2006 (tm 1999 (tm
2007 ;; We start a pulsing progress reporter after 3 seconds. 2000 ;; We start a pulsing progress reporter after 3
2008 (when (and tramp-message-show-message 2001 ;; seconds. Display only when there is a minimum level.
2009 ;; Display only when there is a minimum level. 2002 (when (<= ,level (min tramp-verbose 3))
2010 (<= ,level (min tramp-verbose 3))) 2003 (when-let ((pr (make-progress-reporter ,message nil nil)))
2011 (let ((pr (make-progress-reporter ,message nil nil))) 2004 (run-at-time 3 0.1 #'tramp-progress-reporter-update pr)))))
2012 (when pr
2013 (run-at-time
2014 3 0.1 #'tramp-progress-reporter-update pr))))))
2015 (unwind-protect 2005 (unwind-protect
2016 ;; Execute the body. 2006 ;; Execute the body.
2017 (prog1 (progn ,@body) (setq cookie "done")) 2007 (prog1 (progn ,@body) (setq cookie "done"))
@@ -2025,6 +2015,7 @@ without a visible progress reporter."
2025(defmacro with-tramp-file-property (vec file property &rest body) 2015(defmacro with-tramp-file-property (vec file property &rest body)
2026 "Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache. 2016 "Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache.
2027FILE must be a local file name on a connection identified via VEC." 2017FILE must be a local file name on a connection identified via VEC."
2018 (declare (indent 3) (debug t))
2028 `(if (file-name-absolute-p ,file) 2019 `(if (file-name-absolute-p ,file)
2029 (let ((value (tramp-get-file-property ,vec ,file ,property 'undef))) 2020 (let ((value (tramp-get-file-property ,vec ,file ,property 'undef)))
2030 (when (eq value 'undef) 2021 (when (eq value 'undef)
@@ -2036,12 +2027,11 @@ FILE must be a local file name on a connection identified via VEC."
2036 value) 2027 value)
2037 ,@body)) 2028 ,@body))
2038 2029
2039(put 'with-tramp-file-property 'lisp-indent-function 3)
2040(put 'with-tramp-file-property 'edebug-form-spec t)
2041(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-file-property\\>")) 2030(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-tramp-file-property\\>"))
2042 2031
2043(defmacro with-tramp-connection-property (key property &rest body) 2032(defmacro with-tramp-connection-property (key property &rest body)
2044 "Check in Tramp for property PROPERTY, otherwise execute BODY and set." 2033 "Check in Tramp for property PROPERTY, otherwise execute BODY and set."
2034 (declare (indent 2) (debug t))
2045 `(let ((value (tramp-get-connection-property ,key ,property 'undef))) 2035 `(let ((value (tramp-get-connection-property ,key ,property 'undef)))
2046 (when (eq value 'undef) 2036 (when (eq value 'undef)
2047 ;; We cannot pass ,@body as parameter to 2037 ;; We cannot pass ,@body as parameter to
@@ -2051,8 +2041,6 @@ FILE must be a local file name on a connection identified via VEC."
2051 (tramp-set-connection-property ,key ,property value)) 2041 (tramp-set-connection-property ,key ,property value))
2052 value)) 2042 value))
2053 2043
2054(put 'with-tramp-connection-property 'lisp-indent-function 2)
2055(put 'with-tramp-connection-property 'edebug-form-spec t)
2056(font-lock-add-keywords 2044(font-lock-add-keywords
2057 'emacs-lisp-mode '("\\<with-tramp-connection-property\\>")) 2045 'emacs-lisp-mode '("\\<with-tramp-connection-property\\>"))
2058 2046
@@ -2106,7 +2094,7 @@ Example:
2106 ;; Zeroconf service type. 2094 ;; Zeroconf service type.
2107 ((string-match-p 2095 ((string-match-p
2108 "^_[[:alpha:]]+\\._[[:alpha:]]+$" (nth 1 (car v)))) 2096 "^_[[:alpha:]]+\\._[[:alpha:]]+$" (nth 1 (car v))))
2109 ;; Configuration file. 2097 ;; Configuration file or empty string.
2110 (t (file-exists-p (nth 1 (car v)))))) 2098 (t (file-exists-p (nth 1 (car v))))))
2111 (setq r (delete (car v) r))) 2099 (setq r (delete (car v) r)))
2112 (setq v (cdr v))) 2100 (setq v (cdr v)))
@@ -2272,10 +2260,7 @@ Must be handled by the callers."
2272 exec-path make-process)) 2260 exec-path make-process))
2273 default-directory) 2261 default-directory)
2274 ;; PROC. 2262 ;; PROC.
2275 ((member operation 2263 ((member operation '(file-notify-rm-watch file-notify-valid-p))
2276 '(file-notify-rm-watch
2277 ;; Emacs 25+ only.
2278 file-notify-valid-p))
2279 (when (processp (nth 0 args)) 2264 (when (processp (nth 0 args))
2280 (with-current-buffer (process-buffer (nth 0 args)) 2265 (with-current-buffer (process-buffer (nth 0 args))
2281 default-directory))) 2266 default-directory)))
@@ -2395,7 +2380,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
2395 (cons operation args)) 2380 (cons operation args))
2396 (tramp-run-real-handler operation args)) 2381 (tramp-run-real-handler operation args))
2397 ((eq result 'suppress) 2382 ((eq result 'suppress)
2398 (let (tramp-message-show-message) 2383 (let ((inhibit-message t))
2399 (tramp-message 2384 (tramp-message
2400 v 1 "Suppress received in operation %s" 2385 v 1 "Suppress received in operation %s"
2401 (cons operation args)) 2386 (cons operation args))
@@ -2424,8 +2409,8 @@ Fall back to normal file name handler if no Tramp file name handler exists."
2424(defun tramp-completion-file-name-handler (operation &rest args) 2409(defun tramp-completion-file-name-handler (operation &rest args)
2425 "Invoke Tramp file name completion handler for OPERATION and ARGS. 2410 "Invoke Tramp file name completion handler for OPERATION and ARGS.
2426Falls back to normal file name handler if no Tramp file name handler exists." 2411Falls back to normal file name handler if no Tramp file name handler exists."
2427 (let ((fn (assoc operation tramp-completion-file-name-handler-alist))) 2412 (when tramp-mode
2428 (if (and fn tramp-mode) 2413 (if-let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
2429 (save-match-data (apply (cdr fn) args)) 2414 (save-match-data (apply (cdr fn) args))
2430 (tramp-run-real-handler operation args)))) 2415 (tramp-run-real-handler operation args))))
2431 2416
@@ -2433,9 +2418,9 @@ Falls back to normal file name handler if no Tramp file name handler exists."
2433(progn (defun tramp-autoload-file-name-handler (operation &rest args) 2418(progn (defun tramp-autoload-file-name-handler (operation &rest args)
2434 "Load Tramp file name handler, and perform OPERATION." 2419 "Load Tramp file name handler, and perform OPERATION."
2435 (tramp-unload-file-name-handlers) 2420 (tramp-unload-file-name-handlers)
2436 (if tramp-mode 2421 (when tramp-mode
2437 (let ((default-directory temporary-file-directory)) 2422 (let ((default-directory temporary-file-directory))
2438 (load "tramp" 'noerror 'nomessage))) 2423 (load "tramp" 'noerror 'nomessage)))
2439 (apply operation args))) 2424 (apply operation args)))
2440 2425
2441;; `tramp-autoload-file-name-handler' must be registered before 2426;; `tramp-autoload-file-name-handler' must be registered before
@@ -2447,7 +2432,7 @@ Falls back to normal file name handler if no Tramp file name handler exists."
2447 (add-to-list 'file-name-handler-alist 2432 (add-to-list 'file-name-handler-alist
2448 (cons tramp-autoload-file-name-regexp 2433 (cons tramp-autoload-file-name-regexp
2449 'tramp-autoload-file-name-handler)) 2434 'tramp-autoload-file-name-handler))
2450 (put 'tramp-autoload-file-name-handler 'safe-magic t))) 2435 (put #'tramp-autoload-file-name-handler 'safe-magic t)))
2451 2436
2452;;;###autoload (tramp-register-autoload-file-name-handlers) 2437;;;###autoload (tramp-register-autoload-file-name-handlers)
2453 2438
@@ -2488,29 +2473,28 @@ remote file names."
2488 ;; respective foreign handlers. 2473 ;; respective foreign handlers.
2489 (add-to-list 'file-name-handler-alist 2474 (add-to-list 'file-name-handler-alist
2490 (cons tramp-file-name-regexp #'tramp-file-name-handler)) 2475 (cons tramp-file-name-regexp #'tramp-file-name-handler))
2491 (put 'tramp-file-name-handler 'safe-magic t) 2476 (put #'tramp-file-name-handler 'safe-magic t)
2492 2477
2493 (add-to-list 'file-name-handler-alist 2478 (add-to-list 'file-name-handler-alist
2494 (cons tramp-completion-file-name-regexp 2479 (cons tramp-completion-file-name-regexp
2495 #'tramp-completion-file-name-handler)) 2480 #'tramp-completion-file-name-handler))
2496 (put 'tramp-completion-file-name-handler 'safe-magic t) 2481 (put #'tramp-completion-file-name-handler 'safe-magic t)
2497 ;; Mark `operations' the handler is responsible for. 2482 ;; Mark `operations' the handler is responsible for.
2498 (put 'tramp-completion-file-name-handler 'operations 2483 (put #'tramp-completion-file-name-handler 'operations
2499 (mapcar #'car tramp-completion-file-name-handler-alist)) 2484 (mapcar #'car tramp-completion-file-name-handler-alist))
2500 2485
2501 (when (bound-and-true-p tramp-archive-enabled) 2486 (when (bound-and-true-p tramp-archive-enabled)
2502 (add-to-list 'file-name-handler-alist 2487 (add-to-list 'file-name-handler-alist
2503 (cons tramp-archive-file-name-regexp 2488 (cons tramp-archive-file-name-regexp
2504 #'tramp-archive-file-name-handler)) 2489 #'tramp-archive-file-name-handler))
2505 (put 'tramp-archive-file-name-handler 'safe-magic t)) 2490 (put #'tramp-archive-file-name-handler 'safe-magic t))
2506 2491
2507 ;; If jka-compr or epa-file are already loaded, move them to the 2492 ;; If jka-compr or epa-file are already loaded, move them to the
2508 ;; front of `file-name-handler-alist'. 2493 ;; front of `file-name-handler-alist'.
2509 (dolist (fnh '(epa-file-handler jka-compr-handler)) 2494 (dolist (fnh '(epa-file-handler jka-compr-handler))
2510 (let ((entry (rassoc fnh file-name-handler-alist))) 2495 (when-let ((entry (rassoc fnh file-name-handler-alist)))
2511 (when entry 2496 (setq file-name-handler-alist
2512 (setq file-name-handler-alist 2497 (cons entry (delete entry file-name-handler-alist))))))
2513 (cons entry (delete entry file-name-handler-alist)))))))
2514 2498
2515(tramp--with-startup (tramp-register-file-name-handlers)) 2499(tramp--with-startup (tramp-register-file-name-handlers))
2516 2500
@@ -2522,7 +2506,7 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'."
2522 (add-to-list 2506 (add-to-list
2523 'tramp-foreign-file-name-handler-alist `(,func . ,handler) append) 2507 'tramp-foreign-file-name-handler-alist `(,func . ,handler) append)
2524 ;; Mark `operations' the handler is responsible for. 2508 ;; Mark `operations' the handler is responsible for.
2525 (put 'tramp-file-name-handler 2509 (put #'tramp-file-name-handler
2526 'operations 2510 'operations
2527 (delete-dups 2511 (delete-dups
2528 (append 2512 (append
@@ -2563,19 +2547,6 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'."
2563 2547
2564;;; File name handler functions for completion mode: 2548;;; File name handler functions for completion mode:
2565 2549
2566;;;###autoload
2567(defvar tramp-completion-mode nil
2568 "If non-nil, external packages signal that they are in file name completion.")
2569(make-obsolete-variable 'tramp-completion-mode 'non-essential "26.1")
2570
2571(defun tramp-completion-mode-p ()
2572 "Check, whether method / user name / host name completion is active."
2573 (or
2574 ;; Signal from outside.
2575 non-essential
2576 ;; This variable has been obsoleted in Emacs 26.
2577 tramp-completion-mode))
2578
2579(defun tramp-connectable-p (vec-or-filename) 2550(defun tramp-connectable-p (vec-or-filename)
2580 "Check, whether it is possible to connect the remote host w/o side-effects. 2551 "Check, whether it is possible to connect the remote host w/o side-effects.
2581This is true, if either the remote host is already connected, or if we are 2552This is true, if either the remote host is already connected, or if we are
@@ -2590,7 +2561,7 @@ not in completion mode."
2590 ;; `tramp-buffer-name'; otherwise `start-file-process' 2561 ;; `tramp-buffer-name'; otherwise `start-file-process'
2591 ;; wouldn't run ever when `non-essential' is non-nil. 2562 ;; wouldn't run ever when `non-essential' is non-nil.
2592 (and vec (process-live-p (get-process (tramp-buffer-name vec)))) 2563 (and vec (process-live-p (get-process (tramp-buffer-name vec))))
2593 (not (tramp-completion-mode-p))))) 2564 (not non-essential))))
2594 2565
2595;; Method, host name and user name completion. 2566;; Method, host name and user name completion.
2596;; `tramp-completion-dissect-file-name' returns a list of 2567;; `tramp-completion-dissect-file-name' returns a list of
@@ -2881,7 +2852,7 @@ Either user or host may be nil."
2881(defun tramp-parse-rhosts-group () 2852(defun tramp-parse-rhosts-group ()
2882 "Return a (user host) tuple allowed to access. 2853 "Return a (user host) tuple allowed to access.
2883Either user or host may be nil." 2854Either user or host may be nil."
2884 (let ((result) 2855 (let (result
2885 (regexp 2856 (regexp
2886 (concat 2857 (concat
2887 "^\\(" tramp-host-regexp "\\)" 2858 "^\\(" tramp-host-regexp "\\)"
@@ -2966,7 +2937,7 @@ Host is always \"localhost\"."
2966(defun tramp-parse-passwd-group () 2937(defun tramp-parse-passwd-group ()
2967 "Return a (user host) tuple allowed to access. 2938 "Return a (user host) tuple allowed to access.
2968Host is always \"localhost\"." 2939Host is always \"localhost\"."
2969 (let ((result) 2940 (let (result
2970 (regexp (concat "^\\(" tramp-user-regexp "\\):"))) 2941 (regexp (concat "^\\(" tramp-user-regexp "\\):")))
2971 (when (re-search-forward regexp (point-at-eol) t) 2942 (when (re-search-forward regexp (point-at-eol) t)
2972 (setq result (list (match-string 1) "localhost"))) 2943 (setq result (list (match-string 1) "localhost")))
@@ -2988,7 +2959,7 @@ Host is always \"localhost\"."
2988(defun tramp-parse-etc-group-group () 2959(defun tramp-parse-etc-group-group ()
2989 "Return a (group host) tuple allowed to access. 2960 "Return a (group host) tuple allowed to access.
2990Host is always \"localhost\"." 2961Host is always \"localhost\"."
2991 (let ((result) 2962 (let (result
2992 (split (split-string (buffer-substring (point) (point-at-eol)) ":"))) 2963 (split (split-string (buffer-substring (point) (point-at-eol)) ":")))
2993 (when (member (user-login-name) (split-string (nth 3 split) "," 'omit)) 2964 (when (member (user-login-name) (split-string (nth 3 split) "," 'omit))
2994 (setq result (list (nth 0 split) "localhost"))) 2965 (setq result (list (nth 0 split) "localhost")))
@@ -3025,7 +2996,7 @@ User is always nil."
3025(defun tramp-parse-putty-group (registry) 2996(defun tramp-parse-putty-group (registry)
3026 "Return a (user host) tuple allowed to access. 2997 "Return a (user host) tuple allowed to access.
3027User is always nil." 2998User is always nil."
3028 (let ((result) 2999 (let (result
3029 (regexp (concat (regexp-quote registry) "\\\\\\(.+\\)"))) 3000 (regexp (concat (regexp-quote registry) "\\\\\\(.+\\)")))
3030 (when (re-search-forward regexp (point-at-eol) t) 3001 (when (re-search-forward regexp (point-at-eol) t)
3031 (setq result (list nil (match-string 1)))) 3002 (setq result (list nil (match-string 1))))
@@ -3206,10 +3177,8 @@ User is always nil."
3206 3177
3207(defun tramp-handle-file-modes (filename) 3178(defun tramp-handle-file-modes (filename)
3208 "Like `file-modes' for Tramp files." 3179 "Like `file-modes' for Tramp files."
3209 ;; Starting with Emacs 25.1, `when-let' can be used. 3180 (when-let ((attrs (file-attributes (or (file-truename filename) filename))))
3210 (let ((attrs (file-attributes (or (file-truename filename) filename)))) 3181 (tramp-mode-string-to-int (tramp-compat-file-attribute-modes attrs))))
3211 (when attrs
3212 (tramp-mode-string-to-int (tramp-compat-file-attribute-modes attrs)))))
3213 3182
3214;; Localname manipulation functions that grok Tramp localnames... 3183;; Localname manipulation functions that grok Tramp localnames...
3215(defun tramp-handle-file-name-as-directory (file) 3184(defun tramp-handle-file-name-as-directory (file)
@@ -3327,21 +3296,18 @@ User is always nil."
3327 (cond 3296 (cond
3328 ((not (file-exists-p file1)) nil) 3297 ((not (file-exists-p file1)) nil)
3329 ((not (file-exists-p file2)) t) 3298 ((not (file-exists-p file2)) t)
3330 (t (time-less-p (tramp-compat-file-attribute-modification-time 3299 (t (time-less-p
3331 (file-attributes file2)) 3300 (tramp-compat-file-attribute-modification-time (file-attributes file2))
3332 (tramp-compat-file-attribute-modification-time 3301 (tramp-compat-file-attribute-modification-time
3333 (file-attributes file1)))))) 3302 (file-attributes file1))))))
3334 3303
3335(defun tramp-handle-file-regular-p (filename) 3304(defun tramp-handle-file-regular-p (filename)
3336 "Like `file-regular-p' for Tramp files." 3305 "Like `file-regular-p' for Tramp files."
3337 (and (file-exists-p filename) 3306 (and (file-exists-p filename)
3338 ;; Sometimes, `file-attributes' does not return a proper value 3307 ;; Sometimes, `file-attributes' does not return a proper value
3339 ;; even if `file-exists-p' does. 3308 ;; even if `file-exists-p' does.
3340 (ignore-errors 3309 (when-let ((attr (file-attributes filename)))
3341 (eq ?- 3310 (eq ?- (aref (tramp-compat-file-attribute-modes attr) 0)))))
3342 (aref
3343 (tramp-compat-file-attribute-modes (file-attributes filename))
3344 0)))))
3345 3311
3346(defun tramp-handle-file-remote-p (filename &optional identification connected) 3312(defun tramp-handle-file-remote-p (filename &optional identification connected)
3347 "Like `file-remote-p' for Tramp files." 3313 "Like `file-remote-p' for Tramp files."
@@ -3380,8 +3346,7 @@ User is always nil."
3380 "Like `file-truename' for Tramp files." 3346 "Like `file-truename' for Tramp files."
3381 ;; Preserve trailing "/". 3347 ;; Preserve trailing "/".
3382 (funcall 3348 (funcall
3383 (if (tramp-compat-directory-name-p filename) 3349 (if (directory-name-p filename) #'file-name-as-directory #'identity)
3384 #'file-name-as-directory #'identity)
3385 ;; Quote properly. 3350 ;; Quote properly.
3386 (funcall 3351 (funcall
3387 (if (tramp-compat-file-name-quoted-p filename) 3352 (if (tramp-compat-file-name-quoted-p filename)
@@ -3452,7 +3417,7 @@ User is always nil."
3452 "Like `insert-directory' for Tramp files." 3417 "Like `insert-directory' for Tramp files."
3453 (unless switches (setq switches "")) 3418 (unless switches (setq switches ""))
3454 ;; Mark trailing "/". 3419 ;; Mark trailing "/".
3455 (when (and (tramp-compat-directory-name-p filename) 3420 (when (and (directory-name-p filename)
3456 (not full-directory-p)) 3421 (not full-directory-p))
3457 (setq switches (concat switches "F"))) 3422 (setq switches (concat switches "F")))
3458 ;; Check, whether directory is accessible. 3423 ;; Check, whether directory is accessible.
@@ -3621,7 +3586,7 @@ User is always nil."
3621 v tramp-file-missing "Cannot load nonexistent file `%s'" file)) 3586 v tramp-file-missing "Cannot load nonexistent file `%s'" file))
3622 (if (not (file-exists-p file)) 3587 (if (not (file-exists-p file))
3623 nil 3588 nil
3624 (let ((tramp-message-show-message (not nomessage))) 3589 (let ((inhibit-message nomessage))
3625 (with-tramp-progress-reporter v 0 (format "Loading %s" file) 3590 (with-tramp-progress-reporter v 0 (format "Loading %s" file)
3626 (let ((local-copy (file-local-copy file))) 3591 (let ((local-copy (file-local-copy file)))
3627 (unwind-protect 3592 (unwind-protect
@@ -4505,16 +4470,15 @@ If FILENAME is remote, a file name handler is called."
4505 (when (and modes (not (zerop (logand modes #o2000)))) 4470 (when (and modes (not (zerop (logand modes #o2000))))
4506 (setq gid (tramp-compat-file-attribute-group-id (file-attributes dir))))) 4471 (setq gid (tramp-compat-file-attribute-group-id (file-attributes dir)))))
4507 4472
4508 (let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid))) 4473 (if-let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid)))
4509 (if handler 4474 (funcall handler #'tramp-set-file-uid-gid filename uid gid)
4510 (funcall handler #'tramp-set-file-uid-gid filename uid gid) 4475 ;; On W32 systems, "chown" does not work.
4511 ;; On W32 systems, "chown" does not work. 4476 (unless (memq system-type '(ms-dos windows-nt))
4512 (unless (memq system-type '(ms-dos windows-nt)) 4477 (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
4513 (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer))) 4478 (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
4514 (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer)))) 4479 (tramp-call-process
4515 (tramp-call-process 4480 nil "chown" nil nil nil (format "%d:%d" uid gid)
4516 nil "chown" nil nil nil (format "%d:%d" uid gid) 4481 (tramp-unquote-shell-quote-argument filename))))))
4517 (tramp-unquote-shell-quote-argument filename)))))))
4518 4482
4519(defun tramp-get-local-uid (id-format) 4483(defun tramp-get-local-uid (id-format)
4520 "The uid of the local user, in ID-FORMAT. 4484 "The uid of the local user, in ID-FORMAT.
@@ -5058,10 +5022,4 @@ name of a process or buffer, or nil to default to the current buffer."
5058;; `start-file-process-shell-command', which is sufficient due to 5022;; `start-file-process-shell-command', which is sufficient due to
5059;; connection-local `shell-file-name'. 5023;; connection-local `shell-file-name'.
5060 5024
5061
5062;;; tramp.el ends here 5025;;; tramp.el ends here
5063
5064;; Local Variables:
5065;; mode: Emacs-Lisp
5066;; coding: utf-8
5067;; End:
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index b31f0e0fd26..0a92e0d3202 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -35,11 +35,8 @@
35;; Emacs version check is defined in macro AC_EMACS_INFO of 35;; Emacs version check is defined in macro AC_EMACS_INFO of
36;; aclocal.m4; should be changed only there. 36;; aclocal.m4; should be changed only there.
37 37
38;; Needed for Emacs 24.
39(defvar inhibit-message)
40
41;;;###tramp-autoload 38;;;###tramp-autoload
42(defconst tramp-version "2.4.4-pre" 39(defconst tramp-version "2.5.0-pre"
43 "This version of Tramp.") 40 "This version of Tramp.")
44 41
45;;;###tramp-autoload 42;;;###tramp-autoload
@@ -71,9 +68,9 @@
71 "The repository revision of the Tramp sources.") 68 "The repository revision of the Tramp sources.")
72 69
73;; Check for Emacs version. 70;; Check for Emacs version.
74(let ((x (if (not (string-lessp emacs-version "24.4")) 71(let ((x (if (not (string-lessp emacs-version "25.1"))
75 "ok" 72 "ok"
76 (format "Tramp 2.4.4-pre is not fit for %s" 73 (format "Tramp 2.5.0-pre is not fit for %s"
77 (replace-regexp-in-string "\n" "" (emacs-version)))))) 74 (replace-regexp-in-string "\n" "" (emacs-version))))))
78 (unless (string-equal "ok" x) (error "%s" x))) 75 (unless (string-equal "ok" x) (error "%s" x)))
79 76
@@ -102,8 +99,3 @@
102(provide 'trampver) 99(provide 'trampver)
103 100
104;;; trampver.el ends here 101;;; trampver.el ends here
105
106;; Local Variables:
107;; mode: Emacs-Lisp
108;; coding: utf-8
109;; End:
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 3229d2b6506..b3fc129ef08 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -60,7 +60,6 @@
60(setq password-cache-expiry nil 60(setq password-cache-expiry nil
61 tramp-cache-read-persistent-data t ;; For auth-sources. 61 tramp-cache-read-persistent-data t ;; For auth-sources.
62 tramp-copy-size-limit nil 62 tramp-copy-size-limit nil
63 tramp-message-show-message nil
64 tramp-persistency-file-name nil 63 tramp-persistency-file-name nil
65 tramp-verbose 0) 64 tramp-verbose 0)
66 65
@@ -971,4 +970,5 @@ If INTERACTIVE is non-nil, the tests are run interactively."
971 "^tramp-archive")) 970 "^tramp-archive"))
972 971
973(provide 'tramp-archive-tests) 972(provide 'tramp-archive-tests)
973
974;;; tramp-archive-tests.el ends here 974;;; tramp-archive-tests.el ends here
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 549fb70aa92..247f878d3c5 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -67,8 +67,6 @@
67(defvar tramp-remote-path) 67(defvar tramp-remote-path)
68(defvar tramp-remote-process-environment) 68(defvar tramp-remote-process-environment)
69 69
70;; Needed for Emacs 24.
71(defvar inhibit-message)
72;; Needed for Emacs 25. 70;; Needed for Emacs 25.
73(defvar connection-local-criteria-alist) 71(defvar connection-local-criteria-alist)
74(defvar connection-local-profile-alist) 72(defvar connection-local-profile-alist)
@@ -100,8 +98,8 @@
100 (add-to-list 98 (add-to-list
101 'tramp-default-host-alist 99 'tramp-default-host-alist
102 `("\\`mock\\'" nil ,(system-name))) 100 `("\\`mock\\'" nil ,(system-name)))
103 ;; Emacs' Makefile sets $HOME to a nonexistent value. Needed in 101 ;; Emacs's Makefile sets $HOME to a nonexistent value. Needed
104 ;; batch mode only, therefore. 102 ;; in batch mode only, therefore.
105 (unless (and (null noninteractive) (file-directory-p "~/")) 103 (unless (and (null noninteractive) (file-directory-p "~/"))
106 (setenv "HOME" temporary-file-directory)) 104 (setenv "HOME" temporary-file-directory))
107 (format "/mock::%s" temporary-file-directory))) 105 (format "/mock::%s" temporary-file-directory)))
@@ -112,7 +110,6 @@
112 remote-file-name-inhibit-cache nil 110 remote-file-name-inhibit-cache nil
113 tramp-cache-read-persistent-data t ;; For auth-sources. 111 tramp-cache-read-persistent-data t ;; For auth-sources.
114 tramp-copy-size-limit nil 112 tramp-copy-size-limit nil
115 tramp-message-show-message nil
116 tramp-persistency-file-name nil 113 tramp-persistency-file-name nil
117 tramp-verbose 0) 114 tramp-verbose 0)
118 115
@@ -177,7 +174,6 @@ Print the content of the Tramp connection and debug buffers, if
177properly. BODY shall not contain a timeout." 174properly. BODY shall not contain a timeout."
178 (declare (indent 1) (debug (natnump body))) 175 (declare (indent 1) (debug (natnump body)))
179 `(let ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0))) 176 `(let ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0)))
180 (tramp-message-show-message t)
181 (debug-ignored-errors 177 (debug-ignored-errors
182 (append 178 (append
183 '("^make-symbolic-link not supported$" 179 '("^make-symbolic-link not supported$"
@@ -2039,7 +2035,7 @@ properly. BODY shall not contain a timeout."
2039 "/method:host:/:/path//foo")) 2035 "/method:host:/:/path//foo"))
2040 2036
2041 ;; Forwhatever reasons, the following tests let Emacs crash for 2037 ;; Forwhatever reasons, the following tests let Emacs crash for
2042 ;; Emacs 24 and Emacs 25, occasionally. No idea what's up. 2038 ;; Emacs 25, occasionally. No idea what's up.
2043 (when (tramp--test-emacs26-p) 2039 (when (tramp--test-emacs26-p)
2044 (should 2040 (should
2045 (string-equal (substitute-in-file-name "/method:host://~foo") "/~foo")) 2041 (string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))
@@ -2238,7 +2234,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2238 (should 2234 (should
2239 (string-equal 2235 (string-equal
2240 (file-name-as-directory file) 2236 (file-name-as-directory file)
2241 (if (tramp-completion-mode-p) 2237 (if non-essential
2242 file (concat file (if (tramp--test-ange-ftp-p) "/" "./"))))) 2238 file (concat file (if (tramp--test-ange-ftp-p) "/" "./")))))
2243 (should (string-equal (file-name-directory file) file)) 2239 (should (string-equal (file-name-directory file) file))
2244 (should (string-equal (file-name-nondirectory file) ""))))))) 2240 (should (string-equal (file-name-nondirectory file) "")))))))
@@ -2376,7 +2372,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2376 ;; Check message. 2372 ;; Check message.
2377 ;; Macro `ert-with-message-capture' was introduced in Emacs 26.1. 2373 ;; Macro `ert-with-message-capture' was introduced in Emacs 26.1.
2378 (with-no-warnings (when (symbol-plist 'ert-with-message-capture) 2374 (with-no-warnings (when (symbol-plist 'ert-with-message-capture)
2379 (let ((tramp-message-show-message t)) 2375 (let (inhibit-message)
2380 (dolist 2376 (dolist
2381 (noninteractive (unless (tramp--test-ange-ftp-p) '(nil t))) 2377 (noninteractive (unless (tramp--test-ange-ftp-p) '(nil t)))
2382 (dolist (visit '(nil t "string" no-message)) 2378 (dolist (visit '(nil t "string" no-message))
@@ -4242,8 +4238,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4242 :tags '(:expensive-test) 4238 :tags '(:expensive-test)
4243 (skip-unless (tramp--test-enabled)) 4239 (skip-unless (tramp--test-enabled))
4244 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 4240 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
4245 ;; `make-process' has been inserted in Emacs 25.1. It supports file 4241 ;; `make-process' supports file name handlers since Emacs 27.
4246 ;; name handlers since Emacs 27.
4247 (skip-unless (tramp--test-emacs27-p)) 4242 (skip-unless (tramp--test-emacs27-p))
4248 4243
4249 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 4244 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
@@ -4965,13 +4960,9 @@ INPUT, if non-nil, is a string sent to the process."
4965 (error (ert-skip "`vc-create-repo' not supported"))) 4960 (error (ert-skip "`vc-create-repo' not supported")))
4966 ;; The structure of VC-FILESET is not documented. Let's 4961 ;; The structure of VC-FILESET is not documented. Let's
4967 ;; hope it won't change. 4962 ;; hope it won't change.
4968 (condition-case nil 4963 (vc-register
4969 (vc-register 4964 (list (car vc-handled-backends)
4970 (list (car vc-handled-backends) 4965 (list (file-name-nondirectory tmp-name2))))
4971 (list (file-name-nondirectory tmp-name2))))
4972 ;; `vc-register' has changed its arguments in Emacs
4973 ;; 25.1. Let's skip it for older Emacsen.
4974 (error (skip-unless (tramp--test-emacs25-p))))
4975 ;; vc-git uses an own process sentinel, Tramp's sentinel 4966 ;; vc-git uses an own process sentinel, Tramp's sentinel
4976 ;; for flushing the cache isn't used. 4967 ;; for flushing the cache isn't used.
4977 (dired-uncache (concat (file-remote-p default-directory) "/")) 4968 (dired-uncache (concat (file-remote-p default-directory) "/"))
@@ -5228,12 +5219,6 @@ INPUT, if non-nil, is a string sent to the process."
5228 (delete-directory tmp-file) 5219 (delete-directory tmp-file)
5229 (should-not (file-exists-p tmp-file)))) 5220 (should-not (file-exists-p tmp-file))))
5230 5221
5231(defun tramp--test-emacs25-p ()
5232 "Check for Emacs version >= 25.1.
5233Some semantics has been changed for there, w/o new functions or
5234variables, so we check the Emacs version directly."
5235 (>= emacs-major-version 25))
5236
5237(defun tramp--test-emacs26-p () 5222(defun tramp--test-emacs26-p ()
5238 "Check for Emacs version >= 26.1. 5223 "Check for Emacs version >= 26.1.
5239Some semantics has been changed for there, w/o new functions or 5224Some semantics has been changed for there, w/o new functions or
@@ -6162,12 +6147,14 @@ Since it unloads Tramp, it shall be the last test to run."
6162 (and (or (and (boundp x) (null (local-variable-if-set-p x))) 6147 (and (or (and (boundp x) (null (local-variable-if-set-p x)))
6163 (and (functionp x) (null (autoloadp (symbol-function x))))) 6148 (and (functionp x) (null (autoloadp (symbol-function x)))))
6164 (string-match "^tramp" (symbol-name x)) 6149 (string-match "^tramp" (symbol-name x))
6150 ;; `tramp-completion-mode' is autoloaded in Emacs < 28.1.
6151 (not (eq 'tramp-completion-mode x))
6165 (not (string-match "^tramp\\(-archive\\)?--?test" (symbol-name x))) 6152 (not (string-match "^tramp\\(-archive\\)?--?test" (symbol-name x)))
6166 (not (string-match "unload-hook$" (symbol-name x))) 6153 (not (string-match "unload-hook$" (symbol-name x)))
6167 (ert-fail (format "`%s' still bound" x))))) 6154 (ert-fail (format "`%s' still bound" x)))))
6168 ;; The defstruct `tramp-file-name' and all its internal functions 6155 ;; The defstruct `tramp-file-name' and all its internal functions
6169 ;; shall be purged. `cl--find-class' must be protected in Emacs 24. 6156 ;; shall be purged.
6170 (with-no-warnings (should-not (cl--find-class 'tramp-file-name))) 6157 (should-not (cl--find-class 'tramp-file-name))
6171 (mapatoms 6158 (mapatoms
6172 (lambda (x) 6159 (lambda (x)
6173 (and (functionp x) 6160 (and (functionp x)
@@ -6214,4 +6201,5 @@ If INTERACTIVE is non-nil, the tests are run interactively."
6214;; file name operation cannot run in the timer. Remove `:unstable' tag? 6201;; file name operation cannot run in the timer. Remove `:unstable' tag?
6215 6202
6216(provide 'tramp-tests) 6203(provide 'tramp-tests)
6204
6217;;; tramp-tests.el ends here 6205;;; tramp-tests.el ends here