Remove Emacs 26 compatibility from Tramp

* doc/misc/tramp.texi (Remote processes): Don't mention Emacs version.
(Frequently Asked Questions): Adapt supported Emacs versions.

* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.7.0-pre".

* lisp/net/tramp-compat.el (tramp-compat-file-name-quoted-p)
(tramp-compat-file-name-quote, tramp-compat-file-name-unquote)
(tramp-compat-tramp-syntax, tramp-compat-exec-path)
(tramp-compat-time-equal-p, tramp-compat-flatten-tree)
(tramp-compat-progress-reporter-update)
(tramp-compat-ignore-error, tramp-compat-rx--transform-item)
(tramp-compat-rx--transform, tramp-compat-rx): Remove.

* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-integration.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sshfs.el:
* lisp/net/tramp-sudoedit.el:
* lisp/net/tramp.el:
* lisp/net/trampver.el: Replace the removed `tramp-compat-*' items
by their real definition.  Don't use `tramp-compat-funcall' when
not needed.  Remove `with-no-warnings' and `ignore-errors' where
appropriate.

* lisp/net/tramp.el (tramp-file-name-for-operation): Rearrange list.
(tramp-handle-file-newer-than-file-p): Simplify.
(tramp-get-process-attributes): Don't check for existence of
`connection-local-criteria-for-default-directory'.
(tramp-handle-shell-command): Don't check for existence of
`shell-command-save-pos-or-erase', `async-shell-command-width' and
`shell-command-set-point-after-cmd'.
(tramp-handle-start-file-process): Call `make-process' directly.
(tramp-defined-time): New defsubst.
(tramp-get-local-gid): Don't check for existence of `group-name'.

* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use `tramp-defined-time'.
(tramp-adb-get-signal-strings): Don't bind `shell-file-name' and
`shell-command-switch'.

* lisp/net/tramp-archive.el (top, tramp-archive-file-name-handler):
Don't bind `max-specpdl-size' any longer.
(tramp-archive-autoload-file-name-regexp): Remove Emacs 26
specific code.
(top): Don't call `tramp-register-archive-autoload-file-name-handler'.

* lisp/net/tramp-gvfs.el (top): Don't bind `max-specpdl-size' any longer.
(tramp-gvfs-handle-set-file-times): Use `tramp-defined-time'.

* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times):
Use `tramp-defined-time'.

* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs27-p):
Remove.
(all):
* test/lisp/net/tramp-tests.el (all): Don't skip for Emacs 26.
Replace the removed `tramp-compat-*' items by their real
definition.  Don't use `tramp-compat-funcall' when not needed.
Remove `with-no-warnings' and `ignore-errors' where appropriate.
(with-connection-local-variables)
(shell-command-dont-erase-buffer): Don't declare.
(tramp-test10-write-region): Don't check for `make-empty-file'.
(tramp-test32-shell-command): Simplify.
(tramp-test34-explicit-shell-file-name): Don't protect
`explicit-shell-file-name' any longer.
(tramp--test-emacs27-p): Remove.
This commit is contained in:
Michael Albinus 2023-01-06 13:34:33 +01:00
parent 3fcbb86585
commit 6602ec3abc
20 changed files with 514 additions and 976 deletions

View file

@ -1,5 +1,5 @@
\input texinfo @c -*- mode: texinfo; coding: utf-8 -*-
@setfilename ../info/tramp
@setfilename ../../info/tramp.info
@c %**start of header
@include docstyle.texi
@c In the Tramp GIT, the version number and the bug report address
@ -3928,12 +3928,12 @@ connection-local variables.
@vindex async-shell-command-width
@vindex COLUMNS@r{, environment variable}
If Emacs supports the user option @code{async-shell-command-width}
(since @w{Emacs 27}), @value{tramp} cares about its value for
asynchronous shell commands. It specifies the number of display
columns for command output. For synchronous shell commands, a similar
effect can be achieved by adding the environment variable
@env{COLUMNS} to @code{tramp-remote-process-environment}.
@value{tramp} cares about the user option
@code{async-shell-command-width} for asynchronous shell commands. It
specifies the number of display columns for command output. For
synchronous shell commands, a similar effect can be achieved by adding
the environment variable @env{COLUMNS} to
@code{tramp-remote-process-environment}.
@subsection Running @code{eshell} on a remote host
@ -4824,8 +4824,8 @@ Where is the latest @value{tramp}?
@item
Which systems does it work on?
The package works successfully on @w{Emacs 26}, @w{Emacs 27}, @w{Emacs
28}, and @w{Emacs 29}.
The package works successfully on @w{Emacs 27}, @w{Emacs 28}, @w{Emacs
29}, and @w{Emacs 30}.
While Unix and Unix-like systems are the primary remote targets,
@value{tramp} has equal success connecting to other platforms, such as

View file

@ -7,10 +7,10 @@
@c In the Tramp GIT, the version number and the bug report address
@c are auto-frobbed from configure.ac.
@set trampver 2.6.0-pre
@set trampver 2.7.0-pre
@set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 26.1
@set emacsver 27.1
@c Other flags from configuration.
@set instprefix /usr/local

View file

@ -71,14 +71,14 @@ It is used for TCP/IP devices."
"Regexp for date time format in ls output."))
(defconst tramp-adb-ls-date-regexp
(tramp-compat-rx
(rx
blank (regexp tramp-adb-ls-date-year-regexp)
blank (regexp tramp-adb-ls-date-time-regexp)
blank)
"Regexp for date format in ls output.")
(defconst tramp-adb-ls-toolbox-regexp
(tramp-compat-rx
(rx
bol (* blank) (group (+ (any ".-" alpha))) ; \1 permissions
(? (+ blank) (+ digit)) ; links (Android 7/toybox)
(* blank) (group (+ (not blank))) ; \2 username
@ -327,8 +327,7 @@ arguments to pass to the OPERATION."
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
(tramp-compat-replace-regexp-in-region
(tramp-compat-rx (literal (tramp-compat-file-name-unquote
(file-name-as-directory localname))))
(rx (literal (file-name-unquote (file-name-as-directory localname))))
"" (point-min))
(widen)))
(tramp-adb-sh-fix-ls-output)
@ -366,14 +365,12 @@ Emacs dired can't find files."
(goto-char (point-min))
(while
(search-forward-regexp
(tramp-compat-rx
blank (group blank (regexp tramp-adb-ls-date-year-regexp) blank))
(rx blank (group blank (regexp tramp-adb-ls-date-year-regexp) blank))
nil t)
(replace-match "0\\1" "\\1" nil)
;; Insert missing "/".
(when (looking-at-p
(tramp-compat-rx
(regexp tramp-adb-ls-date-time-regexp) (+ blank) eol))
(rx (regexp tramp-adb-ls-date-time-regexp) (+ blank) eol))
(end-of-line)
(insert "/")))
;; Sort entries.
@ -393,12 +390,10 @@ Emacs dired can't find files."
(defun tramp-adb-ls-output-time-less-p (a b)
"Sort \"ls\" output by time, descending."
(let (time-a time-b)
;; Once we can assume Emacs 27 or later, the two calls
;; (apply #'encode-time X) can be replaced by (encode-time X).
(string-match tramp-adb-ls-date-regexp a)
(setq time-a (apply #'encode-time (parse-time-string (match-string 0 a))))
(setq time-a (encode-time (parse-time-string (match-string 0 a))))
(string-match tramp-adb-ls-date-regexp b)
(setq time-b (apply #'encode-time (parse-time-string (match-string 0 b))))
(setq time-b (encode-time (parse-time-string (match-string 0 b))))
(time-less-p time-b time-a)))
(defun tramp-adb-ls-output-name-less-p (a b)
@ -474,7 +469,7 @@ Emacs dired can't find files."
;; "adb pull ..." does not always return an error code.
(unless
(and (tramp-adb-execute-adb-command
v "pull" (tramp-compat-file-name-unquote localname) tmpfile)
v "pull" (file-name-unquote localname) tmpfile)
(file-exists-p tmpfile))
(ignore-errors (delete-file tmpfile))
(tramp-error
@ -554,8 +549,7 @@ Emacs dired can't find files."
"Moving tmp file `%s' to `%s'" tmpfile filename)
(unwind-protect
(unless (tramp-adb-execute-adb-command
v "push" tmpfile
(tramp-compat-file-name-unquote localname))
v "push" tmpfile (file-name-unquote localname))
(tramp-error v 'file-error "Cannot write: `%s'" filename))
(delete-file tmpfile)))))))
@ -570,11 +564,7 @@ Emacs dired can't find files."
(defun tramp-adb-handle-set-file-times (filename &optional time flag)
"Like `set-file-times' for Tramp files."
(tramp-skeleton-set-file-modes-times-uid-gid filename
(let ((time (if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
(current-time)
time))
(let ((time (tramp-defined-time time))
(nofollow (if (eq flag 'nofollow) "-h" ""))
(quoted-name (tramp-shell-quote-argument localname)))
;; Older versions of toybox 'touch' mishandle nanoseconds and/or
@ -660,8 +650,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(tramp-flush-file-properties v localname)
(unless (tramp-adb-execute-adb-command
v "push"
(tramp-compat-file-name-unquote filename)
(tramp-compat-file-name-unquote localname))
(file-name-unquote filename)
(file-name-unquote localname))
(tramp-error
v 'file-error
"Cannot copy `%s' `%s'" filename newname)))))))))
@ -727,11 +717,6 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
"Strings to return by `process-file' in case of signals."
(with-tramp-connection-property vec "signal-strings"
(let ((default-directory (tramp-make-tramp-file-name vec 'noloc))
;; `shell-file-name' and `shell-command-switch' are needed
;; for Emacs < 27.1, which doesn't support connection-local
;; variables in `shell-command'.
(shell-file-name "/system/bin/sh")
(shell-command-switch "-c")
process-file-return-signal-string signals result)
(dotimes (i 128) (push (format "Signal %d" i) result))
(setq result (reverse result)
@ -764,7 +749,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Determine input.
(if (null infile)
(setq input (tramp-get-remote-null-device v))
(setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
(setq infile (file-name-unquote (expand-file-name infile)))
(if (tramp-equal-remote default-directory infile)
;; INFILE is on the same remote host.
(setq input (tramp-unquote-file-local-name infile))
@ -940,7 +925,7 @@ implementation will be used."
(i 0)
p)
(when (string-match-p (tramp-compat-rx multibyte) command)
(when (string-match-p (rx multibyte) command)
(tramp-error
v 'file-error "Cannot apply multi-byte command `%s'" command))
@ -1132,7 +1117,7 @@ error and non-nil on success."
(defun tramp-adb-send-command (vec command &optional neveropen nooutput)
"Send the COMMAND to connection VEC."
(if (string-match-p (tramp-compat-rx multibyte) command)
(if (string-match-p (rx multibyte) command)
;; Multibyte codepoints with four bytes are not supported at
;; least by toybox.
@ -1156,7 +1141,7 @@ error and non-nil on success."
;; We can't use stty to disable echo of command. stty is said
;; to be added to toybox 0.7.6. busybox shall have it, but this
;; isn't used any longer for Android.
(delete-matching-lines (tramp-compat-rx bol (literal command) eol))
(delete-matching-lines (rx bol (literal command) eol))
;; When the local machine is W32, there are still trailing ^M.
;; There must be a better solution by setting the correct coding
;; system, but this requires changes in core Tramp.
@ -1279,7 +1264,7 @@ connection if a previous connection has died for some reason."
;; Change prompt.
(tramp-set-connection-property
p "prompt" (tramp-compat-rx "///" (literal prompt) "#$"))
p "prompt" (rx "///" (literal prompt) "#$"))
(tramp-adb-send-command
vec (format "PS1=\"///\"\"%s\"\"#$\"" prompt))

View file

@ -110,12 +110,7 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
;; Sometimes, compilation fails with "Variable binding depth exceeds
;; max-specpdl-size". Shall be fixed in Emacs 27.
(with-no-warnings ;; max-specpdl-size
(eval-and-compile
(let ((max-specpdl-size (* 2 max-specpdl-size)))
(require 'tramp-gvfs))))
(require 'tramp-gvfs)
(autoload 'dired-uncache "dired")
(autoload 'url-tramp-convert-url-to-tramp "url-tramp")
@ -183,20 +178,9 @@ It must be supported by libarchive(3).")
;; The definition of `tramp-archive-file-name-regexp' contains calls
;; to `regexp-opt', which cannot be autoloaded while loading
;; loaddefs.el. So we use a macro, which is evaluated only when needed.
;; Emacs 26 and earlier cannot use the autoload form
;; `tramp-compat-rx'. So we refrain from using `rx'.
;;;###autoload
(progn (defmacro tramp-archive-autoload-file-name-regexp ()
"Regular expression matching archive file names."
(if (<= emacs-major-version 26)
'(concat
"\\`" "\\(" ".+" "\\."
;; Default suffixes ...
(regexp-opt tramp-archive-suffixes)
;; ... with compression.
"\\(?:" "\\." (regexp-opt tramp-archive-compression-suffixes) "\\)*"
"\\)" ;; \1
"\\(" "/" ".*" "\\)" "\\'") ;; \2
`(rx
bos
;; This group is used in `tramp-archive-file-name-archive'.
@ -208,25 +192,17 @@ It must be supported by libarchive(3).")
(? "." (| ,@tramp-archive-compression-suffixes)))
;; This group is used in `tramp-archive-file-name-localname'.
(group "/" (* nonl))
eos))))
eos)))
(put #'tramp-archive-autoload-file-name-regexp 'tramp-autoload t)
;; In older Emacs (prior 27.1), `tramp-archive-autoload-file-name-regexp'
;; is not autoloaded. So we cannot expect it to be known in
;; tramp-loaddefs.el. But it exists, when tramp-archive.el is loaded.
;; We must wrap it into `eval-when-compile'. Otherwise, there could
;; be an "Eager macro-expansion failure" when unloading/reloading Tramp.
;;;###tramp-autoload
(defconst tramp-archive-file-name-regexp
(eval-when-compile (ignore-errors (tramp-archive-autoload-file-name-regexp)))
(eval-when-compile (tramp-archive-autoload-file-name-regexp))
"Regular expression matching archive file names.")
;; The value above is nil for Emacs 26. Set it now.
(if (<= emacs-major-version 26)
(setq tramp-archive-file-name-regexp
(ignore-errors (tramp-archive-autoload-file-name-regexp))))
;;;###tramp-autoload
(defconst tramp-archive-method "archive"
"Method name for archives in GVFS.")
@ -360,13 +336,9 @@ arguments to pass to the OPERATION."
(tramp-register-file-name-handlers)
(tramp-archive-run-real-handler operation args))
(with-no-warnings ;; max-specpdl-size
(let* ((filename (apply #'tramp-archive-file-name-for-operation
operation args))
(archive (tramp-archive-file-name-archive filename))
;; Sometimes, it fails with "Variable binding depth exceeds
;; max-specpdl-size". Shall be fixed in Emacs 27.
(max-specpdl-size (* 2 max-specpdl-size)))
(archive (tramp-archive-file-name-archive filename)))
;; `filename' could be a quoted file name. Or the file
;; archive could be a directory, see Bug#30293.
@ -394,7 +366,7 @@ arguments to pass to the OPERATION."
(setq args (cons operation args)))
(if fn
(save-match-data (apply (cdr fn) args))
(tramp-archive-run-real-handler operation args))))))))
(tramp-archive-run-real-handler operation args)))))))
;;;###autoload
(progn (defun tramp-archive-autoload-file-name-handler (operation &rest args)
@ -432,10 +404,6 @@ arguments to pass to the OPERATION."
(remove-hook
'after-init-hook #'tramp-register-archive-autoload-file-name-handler))))
;; In older Emacsen (prior 27.1), the autoload above does not exist.
;; So we call it again; it doesn't hurt.
(tramp-register-archive-autoload-file-name-handler)
;; Mark `operations' the handler is responsible for.
(put #'tramp-archive-file-name-handler 'operations
(mapcar #'car tramp-archive-file-name-handler-alist))
@ -458,7 +426,7 @@ arguments to pass to the OPERATION."
"Return t if NAME is a string with archive file name syntax."
(and (stringp name)
;; `tramp-archive-file-name-regexp' does not suppress quoted file names.
(not (tramp-compat-file-name-quoted-p name t))
(not (file-name-quoted-p name t))
;; We cannot use `string-match-p', the matches are used.
(string-match tramp-archive-file-name-regexp name)
t))
@ -511,7 +479,6 @@ name is kept in slot `hop'"
;; http://...
((and url-handler-mode
tramp-compat-use-url-tramp-p
(string-match-p url-handler-regexp archive)
(string-match-p
"https?" (url-type (url-generic-parse-url archive))))

View file

@ -267,8 +267,7 @@ Return VALUE."
(defun tramp-flush-directory-properties (key directory)
"Remove all properties of DIRECTORY in the cache context of KEY.
Remove also properties of all files in subdirectories."
(let* ((directory
(directory-file-name (tramp-compat-file-name-unquote directory)))
(let* ((directory (directory-file-name (file-name-unquote directory)))
(truename (tramp-get-file-property key directory "file-truename")))
(tramp-message key 8 "%s" directory)
(dolist (key (hash-table-keys tramp-cache-data))
@ -677,4 +676,8 @@ for all methods. Resulting data are derived from connection history."
(provide 'tramp-cache)
;;; TODO:
;;
;; * Use multisession.el, starting with Emacs 29.1.
;;; tramp-cache.el ends here

View file

@ -359,7 +359,7 @@ The remote connection identified by SOURCE is flushed by
(dir (tramp-rename-read-file-name-dir default))
(init (tramp-rename-read-file-name-init default))
(tramp-ignored-file-name-regexp
(tramp-compat-rx (literal (file-remote-p source)))))
(rx (literal (file-remote-p source)))))
(read-file-name-default
"Enter new Tramp connection: "
dir default 'confirm init #'file-directory-p)))))
@ -470,7 +470,7 @@ For details, see `tramp-rename-files'."
(dir (tramp-rename-read-file-name-dir default))
(init (tramp-rename-read-file-name-init default))
(tramp-ignored-file-name-regexp
(tramp-compat-rx (literal (file-remote-p source)))))
(rx (literal (file-remote-p source)))))
(read-file-name-default
(format "Change Tramp connection `%s': " source)
dir default 'confirm init #'file-directory-p)))))
@ -625,7 +625,7 @@ buffer in your bug report.
(unless (hash-table-p val)
;; Remove string quotation.
(when (looking-at
(tramp-compat-rx
(rx
bol (group (* anychar)) "\"" ;; \1 "
(group "(base64-decode-string ") "\\" ;; \2 \
(group "\"" (* anychar)) "\\" ;; \3 \

View file

@ -23,9 +23,9 @@
;;; Commentary:
;; Tramp's main Emacs version for development is Emacs 29. This
;; package provides compatibility functions for Emacs 26, Emacs 27 and
;; Emacs 28.
;; Tramp's main Emacs version for development is Emacs 30. This
;; package provides compatibility functions for Emacs 27, Emacs 28 and
;; Emacs 29.
;;; Code:
@ -36,7 +36,6 @@
(require 'shell)
(require 'subr-x)
(declare-function tramp-compat-rx "tramp")
(declare-function tramp-error "tramp")
(declare-function tramp-file-name-handler "tramp")
(declare-function tramp-tramp-file-p "tramp")
@ -85,153 +84,6 @@ Add the extension of F, if existing."
tramp-temp-name-prefix tramp-compat-temporary-file-directory)
dir-flag (file-name-extension f t)))
;; `file-name-quoted-p', `file-name-quote' and `file-name-unquote' got
;; a second argument in Emacs 27.1.
;;;###tramp-autoload
(defalias 'tramp-compat-file-name-quoted-p
(if (equal (func-arity #'file-name-quoted-p) '(1 . 2))
#'file-name-quoted-p
(lambda (name &optional top)
"Whether NAME is quoted with prefix \"/:\".
If NAME is a remote file name and TOP is nil, check the local part of NAME."
(let ((file-name-handler-alist (unless top file-name-handler-alist)))
(string-prefix-p "/:" (file-local-name name))))))
(defalias 'tramp-compat-file-name-quote
(if (equal (func-arity #'file-name-quote) '(1 . 2))
#'file-name-quote
(lambda (name &optional top)
"Add the quotation prefix \"/:\" to file NAME.
If NAME is a remote file name and TOP is nil, the local part of NAME is quoted."
(let ((file-name-handler-alist (unless top file-name-handler-alist)))
(if (tramp-compat-file-name-quoted-p name top)
name
(concat (file-remote-p name) "/:" (file-local-name name)))))))
(defalias 'tramp-compat-file-name-unquote
(if (equal (func-arity #'file-name-unquote) '(1 . 2))
#'file-name-unquote
(lambda (name &optional top)
"Remove quotation prefix \"/:\" from file NAME.
If NAME is a remote file name and TOP is nil, the local part of
NAME is unquoted."
(let* ((file-name-handler-alist (unless top file-name-handler-alist))
(localname (file-local-name name)))
(when (tramp-compat-file-name-quoted-p localname top)
(setq
localname (if (= (length localname) 2) "/" (substring localname 2))))
(concat (file-remote-p name) localname)))))
;; `tramp-syntax' has changed its meaning in Emacs 26.1. We still
;; support old settings.
(defsubst tramp-compat-tramp-syntax ()
"Return proper value of `tramp-syntax'."
(defvar tramp-syntax)
(cond ((eq tramp-syntax 'ftp) 'default)
((eq tramp-syntax 'sep) 'separate)
(t tramp-syntax)))
;; The signature of `tramp-make-tramp-file-name' has been changed.
;; Therefore, we cannot use `url-tramp-convert-url-to-tramp' prior
;; Emacs 26.1. We use `temporary-file-directory' as indicator.
(defconst tramp-compat-use-url-tramp-p (fboundp 'temporary-file-directory)
"Whether to use url-tramp.el.")
;; `exec-path' is new in Emacs 27.1.
(defalias 'tramp-compat-exec-path
(if (fboundp 'exec-path)
#'exec-path
(lambda ()
"List of directories to search programs to run in remote subprocesses."
(if (tramp-tramp-file-p default-directory)
(tramp-file-name-handler 'exec-path)
exec-path))))
;; `time-equal-p' has appeared in Emacs 27.1.
(defalias 'tramp-compat-time-equal-p
(if (fboundp 'time-equal-p)
#'time-equal-p
(lambda (t1 t2)
"Return non-nil if time value T1 is equal to time value T2.
A nil value for either argument stands for the current time."
(equal (or t1 (current-time)) (or t2 (current-time))))))
;; `flatten-tree' has appeared in Emacs 27.1.
(defalias 'tramp-compat-flatten-tree
(if (fboundp 'flatten-tree)
#'flatten-tree
(lambda (tree)
"Take TREE and \"flatten\" it."
(let (elems)
(setq tree (list tree))
(while (let ((elem (pop tree)))
(cond ((consp elem)
(setq tree (cons (car elem) (cons (cdr elem) tree))))
(elem
(push elem elems)))
tree))
(nreverse elems)))))
;; `progress-reporter-update' got argument SUFFIX in Emacs 27.1.
(defalias 'tramp-compat-progress-reporter-update
(if (equal (func-arity #'progress-reporter-update) '(1 . 3))
#'progress-reporter-update
(lambda (reporter &optional value _suffix)
(progress-reporter-update reporter value))))
;; `ignore-error' is new in Emacs 27.1.
(defmacro tramp-compat-ignore-error (condition &rest body)
"Execute BODY; if the error CONDITION occurs, return nil.
Otherwise, return result of last form in BODY.
CONDITION can also be a list of error conditions."
(declare (debug t) (indent 1))
`(condition-case nil (progn ,@body) (,condition nil)))
;; `rx' in Emacs 26 doesn't know the `literal', `anychar' and
;; `multibyte' constructs. The `not' construct requires an `any'
;; construct as argument. The `regexp' construct requires a literal
;; string.
(defvar tramp-compat-rx--runtime-params)
(defun tramp-compat-rx--transform-items (items)
(mapcar #'tramp-compat-rx--transform-item items))
;; There is an error in Emacs 26. `(rx "a" (? ""))' => "a?".
;; We must protect the string in regexp and literal, therefore.
(defun tramp-compat-rx--transform-item (item)
(pcase item
('anychar 'anything)
('multibyte 'nonascii)
(`(not ,expr)
(if (consp expr) item (list 'not (list 'any expr))))
(`(regexp ,expr)
(setq tramp-compat-rx--runtime-params t)
`(regexp ,(list '\, `(concat "\\(?:" ,expr "\\)"))))
(`(literal ,expr)
(setq tramp-compat-rx--runtime-params t)
`(regexp ,(list '\, `(concat "\\(?:" (regexp-quote ,expr) "\\)"))))
(`(eval . ,_) item)
(`(,head . ,rest) (cons head (tramp-compat-rx--transform-items rest)))
(_ item)))
(defun tramp-compat-rx--transform (items)
(let* ((tramp-compat-rx--runtime-params nil)
(new-rx (cons ': (tramp-compat-rx--transform-items items))))
(if tramp-compat-rx--runtime-params
`(rx-to-string ,(list '\` new-rx) t)
(rx-to-string new-rx t))))
(if (ignore-errors (rx-to-string '(literal "a"))) ;; Emacs 27+.
(defalias 'tramp-compat-rx #'rx)
(defmacro tramp-compat-rx (&rest items)
(tramp-compat-rx--transform items)))
;; This is needed for compilation in the Emacs source tree.
;;;###autoload (defalias 'tramp-compat-rx #'rx)
(put #'tramp-compat-rx 'tramp-autoload t)
;; `file-modes', `set-file-modes' and `set-file-times' got argument
;; FLAG in Emacs 28.1.
(defalias 'tramp-compat-file-modes
@ -419,8 +271,5 @@ CONDITION can also be a list of error conditions."
;;
;; * Starting with Emacs 27.1, there's no need to escape open
;; parentheses with a backslash in docstrings anymore.
;;
;; * Starting with Emacs 27.1, there's `make-empty-file'. Could be
;; used instead of `(write-region "" ...)'.
;;; tramp-compat.el ends here

View file

@ -146,7 +146,7 @@ They are completed by \"M-x TAB\" only when encryption support is enabled."
If NAME doesn't belong to an encrypted remote directory, return nil."
(catch 'crypt-file-name-p
(and tramp-crypt-enabled (stringp name)
(not (tramp-compat-file-name-quoted-p name))
(not (file-name-quoted-p name))
(not (string-suffix-p tramp-crypt-encfs-config name))
(dolist (dir tramp-crypt-directories)
(and (string-prefix-p
@ -497,7 +497,7 @@ directory. File names will be also encrypted."
(tramp-user-error nil "Feature is not enabled."))
(unless (and (tramp-tramp-file-p name) (file-directory-p name))
(tramp-user-error nil "%s must be an existing remote directory." name))
(when (tramp-compat-file-name-quoted-p name)
(when (file-name-quoted-p name)
(tramp-user-error nil "%s must not be quoted." name))
(setq name (file-name-as-directory (expand-file-name name)))
(unless (member name tramp-crypt-directories)
@ -556,7 +556,7 @@ localname."
(defun tramp-crypt-handle-access-file (filename string)
"Like `access-file' for Tramp files."
(let* ((encrypt-filename (tramp-crypt-encrypt-file-name filename))
(encrypt-regexp (tramp-compat-rx (literal encrypt-filename) eos))
(encrypt-regexp (rx (literal encrypt-filename) eos))
tramp-crypt-enabled)
(condition-case err
(access-file encrypt-filename string)
@ -709,8 +709,7 @@ absolute file names."
(mapcar
(lambda (x)
(replace-regexp-in-string
(tramp-compat-rx bos (literal directory)) ""
(tramp-crypt-decrypt-file-name x)))
(rx bos (literal directory)) "" (tramp-crypt-decrypt-file-name x)))
(directory-files (tramp-crypt-encrypt-file-name directory) 'full)))))
(defun tramp-crypt-handle-file-attributes (filename &optional id-format)
@ -756,9 +755,7 @@ absolute file names."
(defun tramp-crypt-handle-file-system-info (filename)
"Like `file-system-info' for Tramp files."
(let (tramp-crypt-enabled)
;; `file-system-info' exists since Emacs 27.1.
(tramp-compat-funcall
'file-system-info (tramp-crypt-encrypt-file-name filename))))
(file-system-info (tramp-crypt-encrypt-file-name filename))))
(defun tramp-crypt-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
@ -769,27 +766,26 @@ absolute file names."
(filename switches &optional wildcard full-directory-p)
"Like `insert-directory' for Tramp files.
WILDCARD is not supported."
;; This package has been added to Emacs 27.1.
(when (load "text-property-search" 'noerror 'nomessage)
(let (tramp-crypt-enabled)
(tramp-handle-insert-directory
(tramp-crypt-encrypt-file-name filename)
switches wildcard full-directory-p)
(let* ((filename (file-name-as-directory filename))
(enc (tramp-crypt-encrypt-file-name filename))
match string)
(goto-char (point-min))
(while (setq match (text-property-search-forward 'dired-filename t t))
(setq string
(buffer-substring
(prop-match-beginning match) (prop-match-end match))
string (if (file-name-absolute-p string)
(tramp-crypt-decrypt-file-name string)
(substring
(tramp-crypt-decrypt-file-name (concat enc string))
(length filename))))
(delete-region (prop-match-beginning match) (prop-match-end match))
(insert (propertize string 'dired-filename t)))))))
(require 'text-property-search)
(let (tramp-crypt-enabled)
(tramp-handle-insert-directory
(tramp-crypt-encrypt-file-name filename)
switches wildcard full-directory-p)
(let* ((filename (file-name-as-directory filename))
(enc (tramp-crypt-encrypt-file-name filename))
match string)
(goto-char (point-min))
(while (setq match (text-property-search-forward 'dired-filename t t))
(setq string
(buffer-substring
(prop-match-beginning match) (prop-match-end match))
string (if (file-name-absolute-p string)
(tramp-crypt-decrypt-file-name string)
(substring
(tramp-crypt-decrypt-file-name (concat enc string))
(length filename))))
(delete-region (prop-match-beginning match) (prop-match-end match))
(insert (propertize string 'dired-filename t))))))
(defun tramp-crypt-handle-lock-file (filename)
"Like `lock-file' for Tramp files."

View file

@ -69,15 +69,15 @@
(tramp-fuse-local-file-name directory))))))))
(if full
;; Massage the result.
(let ((local (tramp-compat-rx
(let ((local (rx
bol
(literal
(tramp-fuse-mount-point
(tramp-dissect-file-name directory)))))
(remote (directory-file-name
(funcall
(if (tramp-compat-file-name-quoted-p directory)
#'tramp-compat-file-name-quote #'identity)
(if (file-name-quoted-p directory)
#'file-name-quote #'identity)
(file-remote-p directory)))))
(mapcar
(lambda (x) (replace-regexp-in-string local remote x))
@ -174,8 +174,7 @@ It has the same meaning as `remote-file-name-inhibit-cache'.")
(tramp-set-file-property
vec "/" "mounted"
(when (string-match
(tramp-compat-rx
bol (group (literal (tramp-fuse-mount-spec vec))) blank)
(rx bol (group (literal (tramp-fuse-mount-spec vec))) blank)
mount)
(match-string 1 mount)))))))
@ -205,7 +204,7 @@ It has the same meaning as `remote-file-name-inhibit-cache'.")
(defun tramp-fuse-local-file-name (filename)
"Return local mount name of FILENAME."
(setq filename (tramp-compat-file-name-unquote (expand-file-name filename)))
(setq filename (file-name-unquote (expand-file-name filename)))
(with-parsed-tramp-file-name filename nil
;; As long as we call `tramp-*-maybe-open-connection' here,
;; we cache the result.
@ -214,10 +213,10 @@ It has the same meaning as `remote-file-name-inhibit-cache'.")
(intern
(format "tramp-%s-maybe-open-connection" (tramp-file-name-method v)))
v)
(let ((quoted (tramp-compat-file-name-quoted-p localname))
(localname (tramp-compat-file-name-unquote localname)))
(let ((quoted (file-name-quoted-p localname))
(localname (file-name-unquote localname)))
(funcall
(if quoted #'tramp-compat-file-name-quote #'identity)
(if quoted #'file-name-quote #'identity)
(expand-file-name
(if (file-name-absolute-p localname)
(substring localname 1) localname)

View file

@ -414,7 +414,7 @@ It has been changed in GVFS 1.14.")
;; </interface>
(defconst tramp-goa-identity-regexp
(tramp-compat-rx
(rx
bol (? (group (regexp tramp-user-regexp)))
"@" (? (group (regexp tramp-host-regexp)))
(? ":" (group (regexp tramp-port-regexp))))
@ -716,13 +716,13 @@ It has been changed in GVFS 1.14.")
"GVFS file attributes."))
(defconst tramp-gvfs-file-attributes-with-gvfs-ls-regexp
(tramp-compat-rx
(rx
blank (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
"=" (group (+? nonl)))
"Regexp to parse GVFS file attributes with `gvfs-ls'.")
(defconst tramp-gvfs-file-attributes-with-gvfs-info-regexp
(tramp-compat-rx
(rx
bol (* blank) (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
":" (+ blank) (group (* nonl)) eol)
"Regexp to parse GVFS file attributes with `gvfs-info'.")
@ -734,7 +734,7 @@ It has been changed in GVFS 1.14.")
"GVFS file system attributes.")
(defconst tramp-gvfs-file-system-attributes-regexp
(tramp-compat-rx
(rx
bol (* blank)
(group (regexp (regexp-opt tramp-gvfs-file-system-attributes)))
":" (+ blank) (group (* nonl)) eol)
@ -744,7 +744,7 @@ It has been changed in GVFS 1.14.")
"Default prefix for owncloud / nextcloud methods.")
(defconst tramp-gvfs-nextcloud-default-prefix-regexp
(tramp-compat-rx (literal tramp-gvfs-nextcloud-default-prefix) eol)
(rx (literal tramp-gvfs-nextcloud-default-prefix) eol)
"Regexp of default prefix for owncloud / nextcloud methods.")
@ -1168,8 +1168,7 @@ file names."
(with-parsed-tramp-file-name name nil
;; If there is a default location, expand tilde.
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
@ -1186,8 +1185,7 @@ file names."
;; We do not pass "/..".
(if (string-match-p (rx bos (| "afp" (: "dav" (? "s")) "smb") eos) method)
(when (string-match
(tramp-compat-rx bos "/" (+ (not "/")) (group "/.." (? "/")))
localname)
(rx bos "/" (+ (not "/")) (group "/.." (? "/"))) localname)
(setq localname (replace-match "/" t t localname 1)))
(when (string-match (rx bol "/.." (? "/")) localname)
(setq localname (replace-match "/" t t localname))))
@ -1222,7 +1220,7 @@ file names."
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(while (looking-at
(tramp-compat-rx
(rx
bol (group (+ nonl)) blank
(group (+ digit)) blank
"(" (group (+? nonl)) ")"
@ -1232,7 +1230,7 @@ file names."
(cons "name" (match-string 1)))))
(goto-char (1+ (match-end 3)))
(while (looking-at
(tramp-compat-rx
(rx
(regexp tramp-gvfs-file-attributes-with-gvfs-ls-regexp)
(group
(| (regexp
@ -1281,11 +1279,10 @@ If FILE-SYSTEM is non-nil, return file system attributes."
"Return GVFS attributes association list of FILENAME."
(setq filename (directory-file-name (expand-file-name filename)))
(with-parsed-tramp-file-name filename nil
(setq localname (tramp-compat-file-name-unquote localname))
(setq localname (file-name-unquote localname))
(if (or (and (string-match-p
(rx bol (| "afp" (: "dav" (? "s")) "smb") eol) method)
(string-match-p
(tramp-compat-rx bol (? "/") (+ (not "/")) eol) localname))
(string-match-p (rx bol (? "/") (+ (not "/")) eol) localname))
(string-equal localname "/"))
(tramp-gvfs-get-root-attributes filename)
(assoc
@ -1485,7 +1482,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
(let* ((events (process-get proc 'events))
(rest-string (process-get proc 'rest-string))
(dd (tramp-get-default-directory (process-buffer proc)))
(ddu (tramp-compat-rx (literal (tramp-gvfs-url-file-name dd)))))
(ddu (rx (literal (tramp-gvfs-url-file-name dd)))))
(when rest-string
(tramp-message proc 10 "Previous string:\n%s" rest-string))
(tramp-message proc 6 "%S\n%s" proc string)
@ -1504,7 +1501,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
(delete-process proc))
(while (string-match
(tramp-compat-rx
(rx
bol (+ nonl) ":"
blank (group (+ nonl)) ":"
blank (group (regexp (regexp-opt tramp-gio-events)))
@ -1607,12 +1604,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
(tramp-gvfs-set-attribute
v (if (eq flag 'nofollow) "-nt" "-t") "uint64"
(tramp-gvfs-url-file-name filename) "time::modified"
(format-time-string
"%s" (if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
nil
time)))))
(format-time-string "%s" (tramp-defined-time time)))))
(defun tramp-gvfs-handle-get-home-directory (vec &optional _user)
"The remote home directory for connection VEC as local file name.
@ -1705,7 +1697,7 @@ ID-FORMAT valid values are `string' and `integer'."
(defun tramp-gvfs-url-file-name (filename)
"Return FILENAME in URL syntax."
(setq filename (tramp-compat-file-name-unquote filename))
(setq filename (file-name-unquote filename))
(let* (;; "/" must NOT be hexified.
(url-unreserved-chars (cons ?/ url-unreserved-chars))
(result
@ -1725,8 +1717,7 @@ ID-FORMAT valid values are `string' and `integer'."
"Retrieve file name from D-Bus OBJECT-PATH."
(dbus-unescape-from-identifier
(replace-regexp-in-string
(tramp-compat-rx bol (* nonl) "/" (group (+ (not "/"))) eol) "\\1"
object-path)))
(rx bol (* nonl) "/" (group (+ (not "/"))) eol) "\\1" object-path)))
(defun tramp-gvfs-url-host (url)
"Return the host name part of URL, a string.
@ -2002,7 +1993,7 @@ Their full names are \"org.gtk.vfs.MountTracker.mounted\" and
(string-equal host (tramp-file-name-host vec))
(string-equal port (tramp-file-name-port vec))
(string-match-p
(tramp-compat-rx bol "/" (literal (or share "")))
(rx bol "/" (literal (or share "")))
(tramp-file-name-unquote-localname vec)))
;; Set mountpoint and location.
(tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint)
@ -2047,8 +2038,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
(tramp-media-device-port media) (tramp-file-name-port vec)))
(localname (tramp-file-name-unquote-localname vec))
(share (when (string-match
(tramp-compat-rx bol (? "/") (group (+ (not "/"))))
localname)
(rx bol (? "/") (group (+ (not "/")))) localname)
(match-string 1 localname)))
(ssl (if (string-match-p (rx bol (| "davs" "nextcloud")) method)
"true" "false"))
@ -2091,8 +2081,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
(list (tramp-gvfs-mount-spec-entry "port" port)))))
(mount-pref
(if (and (string-match-p (rx bol "dav") method)
(string-match
(tramp-compat-rx bol (? "/") (+ (not "/"))) localname))
(string-match (rx bol (? "/") (+ (not "/"))) localname))
(match-string 0 localname)
(tramp-gvfs-get-remote-prefix vec))))
@ -2492,12 +2481,8 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi."
result))))
(when tramp-gvfs-enabled
(with-no-warnings ;; max-specpdl-size
;; Suppress D-Bus error messages and Tramp traces.
(let (;; Sometimes, it fails with "Variable binding depth exceeds
;; max-specpdl-size". Shall be fixed in Emacs 27.
(max-specpdl-size (* 2 max-specpdl-size))
(tramp-verbose 0)
(let ((tramp-verbose 0)
tramp-gvfs-dbus-event-vector fun)
;; Add completion functions for services announced by DNS-SD.
;; See <http://www.dns-sd.org/ServiceTypes.html> for valid service types.
@ -2550,7 +2535,7 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi."
"mtp"
(mapcar
(lambda (method) `(tramp-parse-media-names ,(format "_%s._tcp" method)))
tramp-media-methods)))))
tramp-media-methods))))
(add-hook 'tramp-unload-hook
(lambda ()

View file

@ -133,8 +133,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
;; Use `path-separator' as it does eshell.
(setq eshell-path-env
(if (file-remote-p default-directory)
(mapconcat
#'identity (butlast (tramp-compat-exec-path)) path-separator)
(mapconcat #'identity (butlast (exec-path)) path-separator)
(getenv "PATH"))))
(with-eval-after-load 'esh-util

View file

@ -337,7 +337,7 @@ file names."
(defun tramp-rclone-remote-file-name (filename)
"Return FILENAME as used in the `rclone' command."
(setq filename (tramp-compat-file-name-unquote (expand-file-name filename)))
(setq filename (file-name-unquote (expand-file-name filename)))
(if (tramp-rclone-file-name-p filename)
(with-parsed-tramp-file-name filename nil
;; As long as we call `tramp-rclone-maybe-open-connection' here,

View file

@ -411,7 +411,7 @@ The string is used in `tramp-methods'.")
(add-to-list 'tramp-default-method-alist
`(,tramp-local-host-regexp
,(tramp-compat-rx bos (literal tramp-root-id-string) eos) "su"))
,(rx bos (literal tramp-root-id-string) eos) "su"))
(add-to-list 'tramp-default-user-alist
`(,(rx bos (| "su" "sudo" "doas" "ksu") eos)
@ -1149,8 +1149,7 @@ component is used as the target of the symlink."
;; If TARGET is still remote, quote it.
(if (tramp-tramp-file-p target)
(make-symbolic-link
(tramp-compat-file-name-quote target 'top)
linkname ok-if-already-exists)
(file-name-quote target 'top) linkname ok-if-already-exists)
(let ((ln (tramp-get-remote-ln v))
(cwd (tramp-run-real-handler
@ -1200,10 +1199,9 @@ component is used as the target of the symlink."
(if (directory-name-p filename) #'file-name-as-directory #'identity)
;; Quote properly.
(funcall
(if (tramp-compat-file-name-quoted-p filename)
#'tramp-compat-file-name-quote #'identity)
(if (file-name-quoted-p filename) #'file-name-quote #'identity)
(with-parsed-tramp-file-name
(tramp-compat-file-name-unquote (expand-file-name filename)) nil
(file-name-unquote (expand-file-name filename)) nil
(tramp-make-tramp-file-name
v
(with-tramp-file-property v localname "file-truename"
@ -1243,7 +1241,7 @@ component is used as the target of the symlink."
;; If the resulting localname looks remote, we must quote it
;; for security reasons.
(when (file-remote-p result)
(setq result (tramp-compat-file-name-quote result 'top)))
(setq result (file-name-quote result 'top)))
(tramp-message v 4 "True name of `%s' is `%s'" localname result)
result)))))))
@ -1438,7 +1436,7 @@ component is used as the target of the symlink."
(modtime (or (file-attribute-modification-time attr)
tramp-time-doesnt-exist)))
(setq coding-system-used last-coding-system-used)
(if (not (tramp-compat-time-equal-p modtime tramp-time-dont-know))
(if (not (time-equal-p modtime tramp-time-dont-know))
(tramp-run-real-handler #'set-visited-file-modtime (list modtime))
(progn
(tramp-send-command
@ -1478,9 +1476,7 @@ of."
(cond
;; File exists, and has a known modtime.
((and attr
(not
(tramp-compat-time-equal-p modtime tramp-time-dont-know)))
((and attr (not (time-equal-p modtime tramp-time-dont-know)))
(< (abs (tramp-time-diff modtime mt)) 2))
;; Modtime has the don't know value.
(attr
@ -1497,7 +1493,7 @@ of."
v localname "visited-file-modtime-ild" "")))
;; If file does not exist, say it is not modified if and
;; only if that agrees with the buffer's record.
(t (tramp-compat-time-equal-p mt tramp-time-doesnt-exist)))))))))
(t (time-equal-p mt tramp-time-doesnt-exist)))))))))
(defun tramp-sh-handle-set-file-modes (filename mode &optional flag)
"Like `set-file-modes' for Tramp files."
@ -1519,21 +1515,17 @@ of."
"Like `set-file-times' for Tramp files."
(tramp-skeleton-set-file-modes-times-uid-gid filename
(when (tramp-get-remote-touch v)
(let ((time
(if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
nil
time)))
(tramp-send-command-and-check
v (format
"env TZ=UTC0 %s %s %s %s"
(tramp-get-remote-touch v)
(if (tramp-get-connection-property v "touch-t")
(format "-t %s" (format-time-string "%Y%m%d%H%M.%S" time t))
"")
(if (eq flag 'nofollow) "-h" "")
(tramp-shell-quote-argument localname)))))))
(tramp-send-command-and-check
v (format
"env TZ=UTC0 %s %s %s %s"
(tramp-get-remote-touch v)
(if (tramp-get-connection-property v "touch-t")
(format
"-t %s"
(format-time-string "%Y%m%d%H%M.%S" (tramp-defined-time time) t))
"")
(if (eq flag 'nofollow) "-h" "")
(tramp-shell-quote-argument localname))))))
(defun tramp-sh-handle-get-home-directory (vec &optional user)
"The remote home directory for connection VEC as local file name.
@ -1631,7 +1623,7 @@ ID-FORMAT valid values are `string' and `integer'."
(with-parsed-tramp-file-name (expand-file-name filename) nil
(with-tramp-file-property v localname "file-selinux-context"
(let ((context '(nil nil nil nil))
(regexp (tramp-compat-rx
(regexp (rx
(group (+ (any "_" alnum))) ":"
(group (+ (any "_" alnum))) ":"
(group (+ (any "_" alnum))) ":"
@ -2389,10 +2381,10 @@ The method used must be an out-of-band method."
#'identity)
(if v1
(tramp-make-copy-program-file-name v1)
(tramp-compat-file-name-unquote filename)))
(file-name-unquote filename)))
target (if v2
(tramp-make-copy-program-file-name v2)
(tramp-compat-file-name-unquote newname)))
(file-name-unquote newname)))
;; Check for listener port.
(when (tramp-get-method-parameter v 'tramp-remote-copy-args)
@ -2436,7 +2428,7 @@ The method used must be an out-of-band method."
;; `tramp-ssh-controlmaster-options' is a string instead
;; of a list. Unflatten it.
copy-args
(tramp-compat-flatten-tree
(flatten-tree
(mapcar
(lambda (x) (if (tramp-compat-string-search " " x)
(split-string x) x))
@ -2821,8 +2813,7 @@ the result will be a local, non-Tramp, file name."
;; there could be the false positive "/:".
(if (or (and (eq system-type 'windows-nt)
(string-match-p
(tramp-compat-rx bol (| (: alpha ":") (: (literal null-device) eol)))
name))
(rx bol (| (: alpha ":") (: (literal null-device) eol))) name))
(and (not (tramp-tramp-file-p name))
(not (tramp-tramp-file-p dir))))
(tramp-run-real-handler #'expand-file-name (list name dir))
@ -2841,9 +2832,7 @@ the result will be a local, non-Tramp, file name."
;; supposed to find such a shell on the remote host. Please
;; tell me about it when this doesn't work on your system.
(when (string-match
(tramp-compat-rx
bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
@ -3235,7 +3224,7 @@ implementation will be used."
;; Determine input.
(if (null infile)
(setq input (tramp-get-remote-null-device v))
(setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
(setq infile (file-name-unquote (expand-file-name infile)))
(if (tramp-equal-remote default-directory infile)
;; INFILE is on the same remote host.
(setq input (tramp-unquote-file-local-name infile))
@ -3916,7 +3905,7 @@ Fall back to normal file name handler if no Tramp handler exists."
(setq string (tramp-compat-string-replace "\n\n" "\n" string))
(while (string-match
(tramp-compat-rx
(rx
bol (+ (not ":")) ":" blank
(group (+ (not ":"))) ":" blank
(group (regexp (regexp-opt tramp-gio-events)))
@ -4019,66 +4008,55 @@ commands. \"%n\" is replaced by \"2>/dev/null\", and \"%t\" is
replaced by a temporary file name. If VEC is nil, the respective
local commands are used. If there is a format specifier which
cannot be expanded, this function returns nil."
(if (not (string-match-p
(tramp-compat-rx (| bol (not "%")) "%" (any "ahlnoprsty")) script))
(if (not (string-match-p (rx (| bol (not "%")) "%" (any "ahlnoprsty")) script))
script
(catch 'wont-work
(let ((awk (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%a") script)
(let ((awk (when (string-match-p (rx (| bol (not "%")) "%a") script)
(or
(if vec (tramp-get-remote-awk vec) (executable-find "awk"))
(throw 'wont-work nil))))
(hdmp (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%h") script)
(hdmp (when (string-match-p (rx (| bol (not "%")) "%h") script)
(or
(if vec (tramp-get-remote-hexdump vec)
(executable-find "hexdump"))
(throw 'wont-work nil))))
(dev (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%n") script)
(dev (when (string-match-p (rx (| bol (not "%")) "%n") script)
(or
(if vec (concat "2>" (tramp-get-remote-null-device vec))
(if (eq system-type 'windows-nt) ""
(concat "2>" null-device)))
(throw 'wont-work nil))))
(ls (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%l") script)
(ls (when (string-match-p (rx (| bol (not "%")) "%l") script)
(format "%s %s"
(or (tramp-get-ls-command vec)
(throw 'wont-work nil))
(tramp-sh--quoting-style-options vec))))
(od (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%o") script)
(od (when (string-match-p (rx (| bol (not "%")) "%o") script)
(or (if vec (tramp-get-remote-od vec) (executable-find "od"))
(throw 'wont-work nil))))
(perl (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%p") script)
(perl (when (string-match-p (rx (| bol (not "%")) "%p") script)
(or
(if vec
(tramp-get-remote-perl vec) (executable-find "perl"))
(throw 'wont-work nil))))
(python (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%y") script)
(or
(if vec
(tramp-get-remote-python vec)
(executable-find "python"))
(throw 'wont-work nil))))
(readlink (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%r") script)
(python (when (string-match-p (rx (| bol (not "%")) "%y") script)
(or
(if vec
(tramp-get-remote-python vec)
(executable-find "python"))
(throw 'wont-work nil))))
(readlink (when (string-match-p (rx (| bol (not "%")) "%r") script)
(or
(if vec
(tramp-get-remote-readlink vec)
(executable-find "readlink"))
(throw 'wont-work nil))))
(stat (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%s") script)
(tramp-get-remote-readlink vec)
(executable-find "readlink"))
(throw 'wont-work nil))))
(stat (when (string-match-p (rx (| bol (not "%")) "%s") script)
(or
(if vec
(tramp-get-remote-stat vec) (executable-find "stat"))
(throw 'wont-work nil))))
(tmp (when (string-match-p
(tramp-compat-rx (| bol (not "%")) "%t") script)
(tmp (when (string-match-p (rx (| bol (not "%")) "%t") script)
(or
(if vec
(tramp-file-local-name (tramp-make-tramp-temp-name vec))
@ -4339,8 +4317,7 @@ file exists and nonzero exit status otherwise."
"Couldn't find remote shell prompt for %s" shell)
(unless
(tramp-check-for-regexp
(tramp-get-connection-process vec)
(tramp-compat-rx (literal tramp-end-of-output)))
(tramp-get-connection-process vec) (rx (literal tramp-end-of-output)))
(tramp-wait-for-output (tramp-get-connection-process vec))
(tramp-message vec 5 "Setting shell prompt")
(tramp-send-command
@ -4381,8 +4358,7 @@ file exists and nonzero exit status otherwise."
(tramp-send-command
vec (format "echo ~%s" tramp-root-id-string) t)
(if (or (string-match-p
(tramp-compat-rx
bol "~" (literal tramp-root-id-string) eol)
(rx bol "~" (literal tramp-root-id-string) eol)
(buffer-string))
;; The default shell (ksh93) of OpenSolaris
;; and Solaris is buggy. We've got reports
@ -4421,7 +4397,7 @@ seconds. If not, it produces an error message with the given ERROR-ARGS."
(condition-case nil
(tramp-wait-for-regexp
proc timeout
(tramp-compat-rx
(rx
(| (regexp shell-prompt-pattern) (regexp tramp-shell-prompt-pattern))
eos))
(error
@ -4808,7 +4784,7 @@ Goes through the list `tramp-local-coding-commands' and
(with-current-buffer (tramp-get-connection-buffer vec)
(goto-char (point-min))
(unless (looking-at-p (tramp-compat-rx (literal magic)))
(unless (looking-at-p (rx (literal magic)))
(throw 'wont-work-remote nil)))
;; `rem-enc' and `rem-dec' could be a string meanwhile.
@ -4894,7 +4870,7 @@ Goes through the list `tramp-inline-compress-commands'."
nil t))
(throw 'next nil))
(goto-char (point-min))
(unless (looking-at-p (tramp-compat-rx (literal magic)))
(unless (looking-at-p (rx (literal magic)))
(throw 'next nil)))
(tramp-message
vec 5
@ -4905,7 +4881,7 @@ Goes through the list `tramp-inline-compress-commands'."
(throw 'next nil))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
(unless (looking-at-p (tramp-compat-rx (literal magic)))
(unless (looking-at-p (rx (literal magic)))
(throw 'next nil)))
(setq found t)))
@ -5250,7 +5226,7 @@ connection if a previous connection has died for some reason."
(tramp-get-method-parameter hop 'tramp-remote-shell))
(extra-args (tramp-get-sh-extra-args remote-shell))
(async-args
(tramp-compat-flatten-tree
(flatten-tree
(tramp-get-method-parameter hop 'tramp-async-args)))
(connection-timeout
(tramp-get-method-parameter
@ -5394,7 +5370,7 @@ function waits for output unless NOOUTPUT is set."
;; Busyboxes built with the EDITING_ASK_TERMINAL config
;; option send also escape sequences, which must be
;; ignored.
(regexp (tramp-compat-rx
(regexp (rx
(* (not (any "#$\n")))
(literal tramp-end-of-output)
(? (regexp tramp-device-escape-sequence-regexp))
@ -5402,7 +5378,7 @@ function waits for output unless NOOUTPUT is set."
;; Sometimes, the commands do not return a newline but a
;; null byte before the shell prompt, for example "git
;; ls-files -c -z ...".
(regexp1 (tramp-compat-rx (| bol "\000") (regexp regexp)))
(regexp1 (rx (| bol "\000") (regexp regexp)))
(found (tramp-wait-for-regexp proc timeout regexp1)))
(if found
(let ((inhibit-read-only t))
@ -5442,8 +5418,7 @@ the exit status."
(let (cmd data)
(if (and (stringp command)
(string-match
(tramp-compat-rx
(* nonl) "<<'" (literal tramp-end-of-heredoc) "'" (* nonl))
(rx (* nonl) "<<'" (literal tramp-end-of-heredoc) "'" (* nonl))
command))
(setq cmd (match-string 0 command)
data (substring command (match-end 0)))
@ -5613,7 +5588,7 @@ Nonexistent directories are removed from spec."
(tramp-get-method-parameter vec 'tramp-remote-shell-args)
" ")
(tramp-shell-quote-argument tramp-end-of-heredoc))
'noerror (tramp-compat-rx (literal tramp-end-of-heredoc)))
'noerror (rx (literal tramp-end-of-heredoc)))
(progn
(tramp-message
vec 2 "Could not retrieve `tramp-own-remote-path'")
@ -5663,8 +5638,7 @@ Nonexistent directories are removed from spec."
(while candidates
(goto-char (point-min))
(if (string-match-p
(tramp-compat-rx bol (literal (car candidates)) (? "\r") eol)
(buffer-string))
(rx bol (literal (car candidates)) (? "\r") eol) (buffer-string))
(setq locale (car candidates)
candidates nil)
(setq candidates (cdr candidates)))))
@ -5742,7 +5716,7 @@ Nonexistent directories are removed from spec."
vec (format "( %s / -nt / )" (tramp-get-test-command vec)))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
(when (looking-at-p (tramp-compat-rx (literal tramp-end-of-output)))
(when (looking-at-p (rx (literal tramp-end-of-output)))
(format "%s %%s -nt %%s" (tramp-get-test-command vec)))))
(progn
(tramp-send-command

View file

@ -53,7 +53,7 @@
;;;###tramp-autoload
(tramp--with-startup
(add-to-list 'tramp-default-user-alist
`(,(tramp-compat-rx bos (literal tramp-smb-method) eos) nil nil))
`(,(rx bos (literal tramp-smb-method) eos) nil nil))
;; Add completion function for SMB method.
(tramp-set-completion-function
@ -92,9 +92,9 @@ this variable \"client min protocol=NT1\"."
"Version string of the SMB client.")
(defconst tramp-smb-server-version
(tramp-compat-rx "Domain=[" (* (not "]")) "] "
"OS=[" (* (not "]")) "] "
"Server=[" (* (not "]")) "]")
(rx "Domain=[" (* (not "]")) "] "
"OS=[" (* (not "]")) "] "
"Server=[" (* (not "]")) "]")
"Regexp of SMB server identification.")
(defconst tramp-smb-prompt
@ -730,8 +730,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(with-parsed-tramp-file-name name nil
;; Tilde expansion if necessary.
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
@ -1083,8 +1082,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Check for matching entries.
(mapcar
(lambda (x)
(when (string-match-p
(tramp-compat-rx bol (literal base)) (nth 0 x))
(when (string-match-p (rx bol (literal base)) (nth 0 x))
x))
entries)
;; We just need the only and only entry FILENAME.
@ -1198,8 +1196,7 @@ component is used as the target of the symlink."
;; If TARGET is still remote, quote it.
(if (tramp-tramp-file-p target)
(make-symbolic-link
(tramp-compat-file-name-quote target 'top)
linkname ok-if-already-exists)
(file-name-quote target 'top) linkname ok-if-already-exists)
;; Do the 'confirm if exists' thing.
(when (file-exists-p linkname)
@ -1244,7 +1241,7 @@ component is used as the target of the symlink."
;; Determine input.
(when infile
(setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
(setq infile (file-name-unquote (expand-file-name infile)))
(if (tramp-equal-remote default-directory infile)
;; INFILE is on the same remote host.
(setq input (tramp-unquote-file-local-name infile))
@ -1552,7 +1549,7 @@ component is used as the target of the symlink."
\"//\" substitutes only in the local filename part. Catches
errors for shares like \"C$/\", which are common in Microsoft Windows."
;; Check, whether the local part is a quoted file name.
(if (tramp-compat-file-name-quoted-p filename)
(if (file-name-quoted-p filename)
filename
(with-parsed-tramp-file-name filename nil
;; Ignore in LOCALNAME everything before "//".
@ -1603,8 +1600,7 @@ VEC or USER, or if there is no home directory, return nil."
"Return the share name of LOCALNAME."
(save-match-data
(let ((localname (tramp-file-name-unquote-localname vec)))
(when (string-match
(tramp-compat-rx bol (? "/") (group (+ (not "/"))) "/") localname)
(when (string-match (rx bol (? "/") (group (+ (not "/"))) "/") localname)
(match-string 1 localname)))))
(defun tramp-smb-get-localname (vec)
@ -1615,8 +1611,7 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
(setq
localname
(if (string-match
(tramp-compat-rx bol (? "/") (+ (not "/")) (group "/" (* nonl)))
localname)
(rx bol (? "/") (+ (not "/")) (group "/" (* nonl))) localname)
;; There is a share, separated by "/".
(if (not (tramp-smb-get-cifs-capabilities vec))
(mapconcat
@ -1624,8 +1619,7 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
(match-string 1 localname) "")
(match-string 1 localname))
;; There is just a share.
(if (string-match
(tramp-compat-rx bol (? "/") (group (+ (not "/"))) eol) localname)
(if (string-match (rx bol (? "/") (group (+ (not "/"))) eol) localname)
(match-string 1 localname)
"")))
@ -1753,8 +1747,7 @@ are listed. Result is the list (LOCALNAME MODE SIZE MTIME)."
(if (not share)
;; Read share entries.
(when (string-match
(tramp-compat-rx bol "Disk|" (group (+ (not "|"))) "|") line)
(when (string-match (rx bol "Disk|" (group (+ (not "|"))) "|") line)
(setq localname (match-string 1 line)
mode "dr-xr-xr-x"
size 0))

View file

@ -228,8 +228,7 @@ arguments to pass to the OPERATION."
(defun tramp-sshfs-handle-file-system-info (filename)
"Like `file-system-info' for Tramp files."
;;`file-system-info' exists since Emacs 27.1.
(tramp-compat-funcall 'file-system-info (tramp-fuse-local-file-name filename)))
(file-system-info (tramp-fuse-local-file-name filename)))
(defun tramp-sshfs-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
@ -266,7 +265,7 @@ arguments to pass to the OPERATION."
;; Determine input.
(if (null infile)
(setq input (tramp-get-remote-null-device v))
(setq infile (tramp-compat-file-name-unquote (expand-file-name infile)))
(setq infile (file-name-unquote (expand-file-name infile)))
(if (tramp-equal-remote default-directory infile)
;; INFILE is on the same remote host.
(setq input (tramp-unquote-file-local-name infile))

View file

@ -49,7 +49,7 @@
(tramp-password-previous-hop t)))
(add-to-list 'tramp-default-user-alist
`(,(tramp-compat-rx bos (literal tramp-sudoedit-method) eos)
`(,(rx bos (literal tramp-sudoedit-method) eos)
nil ,tramp-root-id-string))
(tramp-set-completion-function
@ -212,8 +212,8 @@ arguments to pass to the OPERATION."
(unless
(tramp-sudoedit-send-command
v1 "ln"
(tramp-compat-file-name-unquote v1-localname)
(tramp-compat-file-name-unquote v2-localname))
(file-name-unquote v1-localname)
(file-name-unquote v2-localname))
(tramp-error
v1 'file-error
"error with add-name-to-file, see buffer `%s' for details"
@ -342,7 +342,7 @@ absolute file names."
(tramp-skeleton-delete-directory directory recursive trash
(unless (tramp-sudoedit-send-command
v (if recursive '("rm" "-rf") "rmdir")
(tramp-compat-file-name-unquote localname))
(file-name-unquote localname))
(tramp-error v 'file-error "Couldn't delete %s" directory))))
(defun tramp-sudoedit-handle-delete-file (filename &optional trash)
@ -352,7 +352,7 @@ absolute file names."
(if (and delete-by-moving-to-trash trash)
(move-file-to-trash filename)
(unless (tramp-sudoedit-send-command
v "rm" "-f" (tramp-compat-file-name-unquote localname))
v "rm" "-f" (file-name-unquote localname))
;; Propagate the error.
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
@ -382,8 +382,7 @@ the result will be a local, non-Tramp, file name."
(unless (file-name-absolute-p localname)
(setq localname (format "~%s/%s" user localname)))
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
@ -413,7 +412,7 @@ the result will be a local, non-Tramp, file name."
(let ((result (and (tramp-sudoedit-remote-acl-p v)
(tramp-sudoedit-send-command-string
v "getfacl" "-acp"
(tramp-compat-file-name-unquote localname)))))
(file-name-unquote localname)))))
;; The acl string must have a trailing \n, which is not
;; provided by `tramp-sudoedit-send-command-string'. Add it.
(and (stringp result) (concat result "\n"))))))
@ -440,8 +439,7 @@ the result will be a local, non-Tramp, file name."
(tramp-convert-file-attributes v localname id-format
(tramp-sudoedit-send-command-and-read
v "env" "QUOTING_STYLE=locale" "stat" "-c"
tramp-sudoedit-file-attributes
(tramp-compat-file-name-unquote localname)))))
tramp-sudoedit-file-attributes (file-name-unquote localname)))))
(defun tramp-sudoedit-handle-file-executable-p (filename)
"Like `file-executable-p' for Tramp files."
@ -453,7 +451,7 @@ the result will be a local, non-Tramp, file name."
(or (tramp-check-cached-permissions v ?x)
(tramp-check-cached-permissions v ?s))
(tramp-sudoedit-send-command
v "test" "-x" (tramp-compat-file-name-unquote localname))))))
v "test" "-x" (file-name-unquote localname))))))
(defun tramp-sudoedit-handle-file-exists-p (filename)
"Like `file-exists-p' for Tramp files."
@ -466,7 +464,7 @@ the result will be a local, non-Tramp, file name."
(if (tramp-file-property-p v localname "file-attributes")
(not (null (tramp-get-file-property v localname "file-attributes")))
(tramp-sudoedit-send-command
v "test" "-e" (tramp-compat-file-name-unquote localname)))))))
v "test" "-e" (file-name-unquote localname)))))))
(defun tramp-sudoedit-handle-file-name-all-completions (filename directory)
"Like `file-name-all-completions' for Tramp files."
@ -477,7 +475,7 @@ the result will be a local, non-Tramp, file name."
(tramp-sudoedit-send-command
v "ls" "-a1" "--quoting-style=literal" "--show-control-chars"
(if (zerop (length localname))
"" (tramp-compat-file-name-unquote localname)))
"" (file-name-unquote localname)))
(mapcar
(lambda (f)
(if (file-directory-p (expand-file-name f directory))
@ -500,7 +498,7 @@ the result will be a local, non-Tramp, file name."
(if (tramp-file-property-p v localname "file-attributes")
(tramp-handle-file-readable-p filename)
(tramp-sudoedit-send-command
v "test" "-r" (tramp-compat-file-name-unquote localname))))))
v "test" "-r" (file-name-unquote localname))))))
(defun tramp-sudoedit-handle-set-file-modes (filename mode &optional flag)
"Like `set-file-modes' for Tramp files."
@ -508,8 +506,7 @@ the result will be a local, non-Tramp, file name."
(unless (and (eq flag 'nofollow) (file-symlink-p filename))
(tramp-skeleton-set-file-modes-times-uid-gid filename
(unless (tramp-sudoedit-send-command
v "chmod" (format "%o" mode)
(tramp-compat-file-name-unquote localname))
v "chmod" (format "%o" mode) (file-name-unquote localname))
(tramp-error
v 'file-error "Error while changing file's mode %s" filename)))))
@ -523,15 +520,14 @@ the result will be a local, non-Tramp, file name."
(with-parsed-tramp-file-name (expand-file-name filename) nil
(with-tramp-file-property v localname "file-selinux-context"
(let ((context '(nil nil nil nil))
(regexp (tramp-compat-rx
(regexp (rx
(group (+ (any "_" alnum))) ":"
(group (+ (any "_" alnum))) ":"
(group (+ (any "_" alnum))) ":"
(group (+ (any "_" alnum))))))
(when (and (tramp-sudoedit-remote-selinux-p v)
(tramp-sudoedit-send-command
v "ls" "-d" "-Z"
(tramp-compat-file-name-unquote localname)))
v "ls" "-d" "-Z" (file-name-unquote localname)))
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(when (re-search-forward regexp (line-end-position) t)
@ -547,7 +543,7 @@ the result will be a local, non-Tramp, file name."
(tramp-message v 5 "file system info: %s" localname)
(when (tramp-sudoedit-send-command
v "df" "--block-size=1" "--output=size,used,avail"
(tramp-compat-file-name-unquote localname))
(file-name-unquote localname))
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(forward-line)
@ -565,17 +561,11 @@ the result will be a local, non-Tramp, file name."
(defun tramp-sudoedit-handle-set-file-times (filename &optional time flag)
"Like `set-file-times' for Tramp files."
(tramp-skeleton-set-file-modes-times-uid-gid filename
(let ((time
(if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
nil
time)))
(tramp-sudoedit-send-command
v "env" "TZ=UTC0" "touch" "-t"
(format-time-string "%Y%m%d%H%M.%S" time t)
(if (eq flag 'nofollow) "-h" "")
(tramp-compat-file-name-unquote localname)))))
(tramp-sudoedit-send-command
v "env" "TZ=UTC0" "touch" "-t"
(format-time-string "%Y%m%d%H%M.%S" (tramp-defined-time time) t)
(if (eq flag 'nofollow) "-h" "")
(file-name-unquote localname))))
(defun tramp-sudoedit-handle-file-truename (filename)
"Like `file-truename' for Tramp files."
@ -584,10 +574,9 @@ the result will be a local, non-Tramp, file name."
(if (directory-name-p filename) #'file-name-as-directory #'identity)
;; Quote properly.
(funcall
(if (tramp-compat-file-name-quoted-p filename)
#'tramp-compat-file-name-quote #'identity)
(if (file-name-quoted-p filename) #'file-name-quote #'identity)
(with-parsed-tramp-file-name
(tramp-compat-file-name-unquote (expand-file-name filename)) nil
(file-name-unquote (expand-file-name filename)) nil
(tramp-make-tramp-file-name
v
(with-tramp-file-property v localname "file-truename"
@ -604,7 +593,7 @@ the result will be a local, non-Tramp, file name."
;; If the resulting localname looks remote, we must quote it
;; for security reasons.
(when (file-remote-p result)
(setq result (tramp-compat-file-name-quote result 'top)))
(setq result (file-name-quote result 'top)))
(tramp-message v 4 "True name of `%s' is `%s'" localname result)
result)))))))
@ -618,7 +607,7 @@ the result will be a local, non-Tramp, file name."
;; be satisfied without remote operation.
(tramp-check-cached-permissions v ?w)
(tramp-sudoedit-send-command
v "test" "-w" (tramp-compat-file-name-unquote localname)))
v "test" "-w" (file-name-unquote localname)))
;; If file doesn't exist, check if directory is writable.
(and
(file-directory-p (file-name-directory filename))
@ -629,7 +618,7 @@ the result will be a local, non-Tramp, file name."
(tramp-skeleton-make-directory dir parents
(unless (tramp-sudoedit-send-command
v "mkdir" "-m" (format "%#o" (default-file-modes))
(tramp-compat-file-name-unquote localname))
(file-name-unquote localname))
(tramp-error v 'file-error "Couldn't make directory %s" dir))))
(defun tramp-sudoedit-handle-make-symbolic-link
@ -649,8 +638,7 @@ component is used as the target of the symlink."
;; If TARGET is still remote, quote it.
(if (tramp-tramp-file-p target)
(make-symbolic-link
(tramp-compat-file-name-quote target 'top)
linkname ok-if-already-exists)
(file-name-quote target 'top) linkname ok-if-already-exists)
;; Do the 'confirm if exists' thing.
(when (file-exists-p linkname)
@ -668,8 +656,8 @@ component is used as the target of the symlink."
(tramp-flush-file-properties v localname)
(tramp-sudoedit-send-command
v "ln" "-sf"
(tramp-compat-file-name-unquote target)
(tramp-compat-file-name-unquote localname)))))
(file-name-unquote target)
(file-name-unquote localname)))))
(defun tramp-sudoedit-handle-rename-file
(filename newname &optional ok-if-already-exists)
@ -693,8 +681,7 @@ component is used as the target of the symlink."
(setq acl-string (string-join (split-string acl-string "\n" 'omit) ","))
(prog1
(tramp-sudoedit-send-command
v "setfacl" "-m"
acl-string (tramp-compat-file-name-unquote localname))
v "setfacl" "-m" acl-string (file-name-unquote localname))
(tramp-flush-file-property v localname "file-acl")))))
(defun tramp-sudoedit-handle-set-file-selinux-context (filename context)
@ -712,7 +699,7 @@ component is used as the target of the symlink."
(when role (format "--role=%s" role))
(when type (format "--type=%s" type))
(when range (format "--range=%s" range))
(tramp-compat-file-name-unquote localname))
(file-name-unquote localname))
(if (and user role type range)
(tramp-set-file-property
v localname "file-selinux-context" context)
@ -820,7 +807,7 @@ in case of error, t otherwise."
vec 'tramp-sudo-login
?h (or (tramp-file-name-host vec) "")
?u (or (tramp-file-name-user vec) ""))
(tramp-compat-flatten-tree args))))
(flatten-tree args))))
;; We suppress the messages `Waiting for prompts from remote shell'.
(tramp-verbose (if (= tramp-verbose 3) 2 tramp-verbose))
;; The password shall be cached also in case of "emacs -Q".

View file

@ -523,7 +523,7 @@ interpreted as a regular expression which always matches."
(defcustom tramp-restricted-shell-hosts-alist
(when (and (eq system-type 'windows-nt)
(not (string-match-p (rx "sh" eol) tramp-encoding-shell)))
(list (tramp-compat-rx
(list (rx
bos (| (literal (downcase tramp-system-name))
(literal (upcase tramp-system-name)))
eos)))
@ -537,7 +537,7 @@ host runs a restricted shell, it shall be added to this list, too."
;;;###tramp-autoload
(defcustom tramp-local-host-regexp
(tramp-compat-rx
(rx
bos
(| (literal tramp-system-name)
(| "localhost" "localhost4" "localhost6" "127.0.0.1" "::1"))
@ -638,7 +638,7 @@ This regexp must match both `tramp-initial-end-of-output' and
:type 'regexp)
(defcustom tramp-password-prompt-regexp
(tramp-compat-rx
(rx
bol (* nonl)
(group (regexp (regexp-opt password-word-equivalents)))
(* nonl) ":" (? "\^@") (* blank))
@ -897,18 +897,17 @@ Used in `tramp-make-tramp-file-name'.")
(defun tramp-build-prefix-regexp ()
"Return `tramp-prefix-regexp'."
(tramp-compat-rx bol (literal (tramp-build-prefix-format))))
(rx bol (literal (tramp-build-prefix-format))))
(defvar tramp-prefix-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching the very beginning of Tramp file names.
Should always start with \"^\". Derived from `tramp-prefix-format'.")
(defconst tramp-method-regexp-alist
`((default . ,(tramp-compat-rx
(| (literal tramp-default-method-marker) (>= 2 alnum))))
`((default . ,(rx (| (literal tramp-default-method-marker) (>= 2 alnum))))
(simplified . "")
(separate . ,(tramp-compat-rx
(? (| (literal tramp-default-method-marker) (>= 2 alnum))))))
(separate
. ,(rx (? (| (literal tramp-default-method-marker) (>= 2 alnum))))))
"Alist mapping Tramp syntax to regexps matching methods identifiers.")
(defun tramp-build-method-regexp ()
@ -936,7 +935,7 @@ Used in `tramp-make-tramp-file-name'.")
(defun tramp-build-postfix-method-regexp ()
"Return `tramp-postfix-method-regexp'."
(tramp-compat-rx (literal (tramp-build-postfix-method-format))))
(rx (literal (tramp-build-postfix-method-format))))
(defvar tramp-postfix-method-regexp nil ; Init'd when defining `tramp-syntax'!
"Regexp matching delimiter between method and user or host names.
@ -948,8 +947,7 @@ Derived from `tramp-postfix-method-format'.")
(defconst tramp-prefix-domain-format "%"
"String matching delimiter between user and domain names.")
(defconst tramp-prefix-domain-regexp
(tramp-compat-rx (literal tramp-prefix-domain-format))
(defconst tramp-prefix-domain-regexp (rx (literal tramp-prefix-domain-format))
"Regexp matching delimiter between user and domain names.
Derived from `tramp-prefix-domain-format'.")
@ -957,7 +955,7 @@ Derived from `tramp-prefix-domain-format'.")
"Regexp matching domain names.")
(defconst tramp-user-with-domain-regexp
(tramp-compat-rx
(rx
(group (regexp tramp-user-regexp))
(regexp tramp-prefix-domain-regexp)
(group (regexp tramp-domain-regexp)))
@ -967,8 +965,7 @@ Derived from `tramp-prefix-domain-format'.")
"String matching delimiter between user and host names.
Used in `tramp-make-tramp-file-name'.")
(defconst tramp-postfix-user-regexp
(tramp-compat-rx (literal tramp-postfix-user-format))
(defconst tramp-postfix-user-regexp (rx (literal tramp-postfix-user-format))
"Regexp matching delimiter between user and host names.
Derived from `tramp-postfix-user-format'.")
@ -991,7 +988,7 @@ Used in `tramp-make-tramp-file-name'.")
(defun tramp-build-prefix-ipv6-regexp ()
"Return `tramp-prefix-ipv6-regexp'."
(tramp-compat-rx (literal tramp-prefix-ipv6-format)))
(rx (literal tramp-prefix-ipv6-format)))
(defvar tramp-prefix-ipv6-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching left hand side of IPv6 addresses.
@ -1019,7 +1016,7 @@ Used in `tramp-make-tramp-file-name'.")
(defun tramp-build-postfix-ipv6-regexp ()
"Return `tramp-postfix-ipv6-regexp'."
(tramp-compat-rx (literal tramp-postfix-ipv6-format)))
(rx (literal tramp-postfix-ipv6-format)))
(defvar tramp-postfix-ipv6-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching right hand side of IPv6 addresses.
@ -1028,8 +1025,7 @@ Derived from `tramp-postfix-ipv6-format'.")
(defconst tramp-prefix-port-format "#"
"String matching delimiter between host names and port numbers.")
(defconst tramp-prefix-port-regexp
(tramp-compat-rx (literal tramp-prefix-port-format))
(defconst tramp-prefix-port-regexp (rx (literal tramp-prefix-port-format))
"Regexp matching delimiter between host names and port numbers.
Derived from `tramp-prefix-port-format'.")
@ -1037,7 +1033,7 @@ Derived from `tramp-prefix-port-format'.")
"Regexp matching port numbers.")
(defconst tramp-host-with-port-regexp
(tramp-compat-rx
(rx
(group (regexp tramp-host-regexp))
(regexp tramp-prefix-port-regexp)
(group (regexp tramp-port-regexp)))
@ -1046,8 +1042,7 @@ Derived from `tramp-prefix-port-format'.")
(defconst tramp-postfix-hop-format "|"
"String matching delimiter after ad-hoc hop definitions.")
(defconst tramp-postfix-hop-regexp
(tramp-compat-rx (literal tramp-postfix-hop-format))
(defconst tramp-postfix-hop-regexp (rx (literal tramp-postfix-hop-format))
"Regexp matching delimiter after ad-hoc hop definitions.
Derived from `tramp-postfix-hop-format'.")
@ -1067,7 +1062,7 @@ Used in `tramp-make-tramp-file-name'.")
(defun tramp-build-postfix-host-regexp ()
"Return `tramp-postfix-host-regexp'."
(tramp-compat-rx (literal tramp-postfix-host-format)))
(rx (literal tramp-postfix-host-format)))
(defvar tramp-postfix-host-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching delimiter between host names and localnames.
@ -1094,7 +1089,7 @@ Derived from `tramp-postfix-host-format'.")
(defun tramp-build-remote-file-name-spec-regexp ()
"Construct a regexp matching a Tramp file name for a Tramp syntax.
It is expected, that `tramp-syntax' has the proper value."
(tramp-compat-rx
(rx
;; Method.
(group (regexp tramp-method-regexp)) (regexp tramp-postfix-method-regexp)
;; Optional user. This includes domain.
@ -1116,7 +1111,7 @@ It is expected, that `tramp-syntax' has the proper value."
It is expected, that `tramp-syntax' has the proper value.
See `tramp-file-name-structure'."
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(? (group (+ (regexp tramp-remote-file-name-spec-regexp)
(regexp tramp-postfix-hop-regexp))))
@ -1176,11 +1171,9 @@ initial value is overwritten by the car of `tramp-file-name-structure'.")
;; `tramp-method-regexp' needs at least two characters, in order to
;; distinguish from volume letter. This is in the way when completing.
(defconst tramp-completion-method-regexp-alist
`((default . ,(tramp-compat-rx
(| (literal tramp-default-method-marker) (+ alnum))))
`((default . ,(rx (| (literal tramp-default-method-marker) (+ alnum))))
(simplified . "")
(separate . ,(tramp-compat-rx
(| (literal tramp-default-method-marker) (* alnum)))))
(separate . ,(rx (| (literal tramp-default-method-marker) (* alnum)))))
"Alist mapping Tramp syntax to regexps matching completion methods.")
(defun tramp-build-completion-method-regexp ()
@ -1196,8 +1189,8 @@ The `ftp' syntax does not support methods.")
"Return `tramp-completion-file-name-regexp' according to `tramp-syntax'."
(if (eq tramp-syntax 'separate)
;; FIXME: This shouldn't be necessary.
(tramp-compat-rx bos "/" (? "[" (* (not "]"))) eos)
(tramp-compat-rx
(rx bos "/" (? "[" (* (not "]"))) eos)
(rx
bos
;; `file-name-completion' uses absolute paths for matching.
;; This means that on W32 systems, something like
@ -1509,8 +1502,7 @@ same connection. Make a copy in order to avoid side effects."
(setq vec (copy-tramp-file-name vec))
(setf (tramp-file-name-localname vec)
(and (stringp localname)
(tramp-compat-file-name-unquote
(directory-file-name localname)))
(file-name-unquote (directory-file-name localname)))
(tramp-file-name-hop vec) nil))
vec))
@ -1543,7 +1535,7 @@ entry does not exist, return nil."
;; The localname can be quoted with "/:". Extract this.
(defun tramp-file-name-unquote-localname (vec)
"Return unquoted localname component of VEC."
(tramp-compat-file-name-unquote (tramp-file-name-localname vec)))
(file-name-unquote (tramp-file-name-localname vec)))
;;;###tramp-autoload
(defun tramp-tramp-file-p (name)
@ -1581,7 +1573,7 @@ of `process-file', `start-file-process', or `shell-command'."
;; The localname can be quoted with "/:". Extract this.
(defun tramp-unquote-file-local-name (name)
"Return unquoted localname of NAME."
(tramp-compat-file-name-unquote (tramp-file-local-name name)))
(file-name-unquote (tramp-file-local-name name)))
(defun tramp-find-method (method user host)
"Return the right method string to use depending on USER and HOST.
@ -1743,7 +1735,7 @@ See `tramp-dissect-file-name' for details."
(let ((v (tramp-dissect-file-name
(concat tramp-prefix-format
(replace-regexp-in-string
(tramp-compat-rx (regexp tramp-postfix-hop-regexp) eos)
(rx (regexp tramp-postfix-hop-regexp) eos)
tramp-postfix-host-format name))
nodefault)))
;; Only some methods from tramp-sh.el do support multi-hops.
@ -1839,8 +1831,7 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
(replace-regexp-in-string
tramp-prefix-regexp ""
(replace-regexp-in-string
(tramp-compat-rx
(regexp tramp-postfix-host-regexp) eos)
(rx (regexp tramp-postfix-host-regexp) eos)
tramp-postfix-hop-format
(tramp-make-tramp-file-name vec 'noloc)))))
@ -1970,7 +1961,7 @@ of `current-buffer'."
;; Also, in `font-lock-defaults' you can specify a function name for
;; the "KEYWORDS" part, so font-lock calls it to get the actual keywords!
'(list
(tramp-compat-rx bol (regexp tramp-debug-outline-regexp) (+ nonl))
(rx bol (regexp tramp-debug-outline-regexp) (+ nonl))
'(1 font-lock-warning-face t t)
'(0 (outline-font-lock-face) keep t))
"Used for highlighting Tramp debug buffers in `outline-mode'.")
@ -2384,7 +2375,7 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
(let* ((parameters (cdr reporter))
(message (aref parameters 3)))
(when (tramp-compat-string-search message (or (current-message) ""))
(tramp-compat-progress-reporter-update reporter value suffix))))
(progress-reporter-update reporter value suffix))))
(defmacro with-tramp-progress-reporter (vec level message &rest body)
"Execute BODY, spinning a progress reporter with MESSAGE in interactive mode.
@ -2422,13 +2413,12 @@ locally on a remote file name. When the local system is a W32 system
but the remote system is Unix, this introduces a superfluous drive
letter into the file name. This function removes it."
(save-match-data
(let ((quoted (tramp-compat-file-name-quoted-p name 'top))
(result (tramp-compat-file-name-unquote name 'top)))
(let ((quoted (file-name-quoted-p name 'top))
(result (file-name-unquote name 'top)))
(setq result
(replace-regexp-in-string
(tramp-compat-rx (regexp tramp-volume-letter-regexp) "/")
"/" result))
(if quoted (tramp-compat-file-name-quote result 'top) result))))
(rx (regexp tramp-volume-letter-regexp) "/") "/" result))
(if quoted (file-name-quote result 'top) result))))
;;; Config Manipulation Functions:
@ -2536,7 +2526,7 @@ coding system might not be determined. This function repairs it."
;; We found a matching entry in `file-coding-system-alist'.
;; So we add a similar entry, but with the temporary file name
;; as regexp.
(push (cons (tramp-compat-rx (literal tmpname)) (cdr elt)) result)))))
(push (cons (rx (literal tmpname)) (cdr elt)) result)))))
(defun tramp-run-real-handler (operation args)
"Invoke normal file name handler for OPERATION.
@ -2586,15 +2576,13 @@ Must be handled by the callers."
file-name-nondirectory file-name-sans-versions
file-notify-add-watch file-ownership-preserved-p
file-readable-p file-regular-p file-remote-p
file-selinux-context file-symlink-p file-truename
file-writable-p find-backup-file-name get-file-buffer
insert-directory insert-file-contents load
make-directory set-file-acl set-file-modes
file-selinux-context file-symlink-p file-system-info
file-truename file-writable-p find-backup-file-name
get-file-buffer insert-directory insert-file-contents
load make-directory set-file-acl set-file-modes
set-file-selinux-context set-file-times
substitute-in-file-name unhandled-file-name-directory
vc-registered
;; Emacs 27+ only.
file-system-info
;; Emacs 28- only.
make-directory-internal
;; Emacs 28+ only.
@ -2637,10 +2625,8 @@ Must be handled by the callers."
(if (bufferp (nth 0 args)) (nth 0 args) (current-buffer))))
;; COMMAND.
((member operation
'(make-nearby-temp-file process-file shell-command
start-file-process temporary-file-directory
;; Emacs 27+ only.
exec-path make-process
'(exec-path make-nearby-temp-file make-process process-file
shell-command start-file-process temporary-file-directory
;; Emacs 29+ only.
list-system-processes memory-info process-attributes))
default-directory)
@ -2821,7 +2807,7 @@ remote file names."
#'file-name-sans-extension
(directory-files
dir nil (rx bos "tramp" (+ nonl) ".el" (? "c") eos)))))
(files-regexp (tramp-compat-rx bol (regexp (regexp-opt files)) eol)))
(files-regexp (rx bol (regexp (regexp-opt files)) eol)))
(mapatoms
(lambda (atom)
(when (and (functionp atom)
@ -2858,7 +2844,7 @@ remote file names."
(put #'tramp-completion-file-name-handler 'operations
(mapcar #'car tramp-completion-file-name-handler-alist))
;; Integrated in Emacs 27.
;; After unloading, `tramp-archive-enabled' might not be defined.
(when (bound-and-true-p tramp-archive-enabled)
(add-to-list 'file-name-handler-alist
(cons tramp-archive-file-name-regexp
@ -2967,7 +2953,7 @@ not in completion mode."
;; Suppress hop from completion.
(when (string-match
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (+ (regexp tramp-remote-file-name-spec-regexp)
(regexp tramp-postfix-hop-regexp))))
@ -3060,14 +3046,14 @@ They are collected by `tramp-completion-dissect-file-name1'."
(let (;; "/method" "/[method"
(tramp-completion-file-name-structure1
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (? (regexp tramp-completion-method-regexp))) eol)
1 nil nil nil))
;; "/method:user" "/[method/user"
(tramp-completion-file-name-structure2
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (regexp tramp-method-regexp))
(regexp tramp-postfix-method-regexp)
@ -3076,7 +3062,7 @@ They are collected by `tramp-completion-dissect-file-name1'."
;; "/method:host" "/[method/host"
(tramp-completion-file-name-structure3
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (regexp tramp-method-regexp))
(regexp tramp-postfix-method-regexp)
@ -3085,7 +3071,7 @@ They are collected by `tramp-completion-dissect-file-name1'."
;; "/method:[ipv6" "/[method/ipv6"
(tramp-completion-file-name-structure4
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (regexp tramp-method-regexp))
(regexp tramp-postfix-method-regexp)
@ -3095,7 +3081,7 @@ They are collected by `tramp-completion-dissect-file-name1'."
;; "/method:user@host" "/[method/user@host"
(tramp-completion-file-name-structure5
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (regexp tramp-method-regexp))
(regexp tramp-postfix-method-regexp)
@ -3106,7 +3092,7 @@ They are collected by `tramp-completion-dissect-file-name1'."
;; "/method:user@[ipv6" "/[method/user@ipv6"
(tramp-completion-file-name-structure6
(list
(tramp-compat-rx
(rx
(regexp tramp-prefix-regexp)
(group (regexp tramp-method-regexp))
(regexp tramp-postfix-method-regexp)
@ -3239,7 +3225,7 @@ Either user or host may be nil."
Either user or host may be nil."
(let (result
(regexp
(tramp-compat-rx
(rx
bol (group (regexp tramp-host-regexp))
(? (+ blank) (group (regexp tramp-user-regexp))))))
(when (re-search-forward regexp (line-end-position) t)
@ -3255,8 +3241,7 @@ User is always nil."
(defun tramp-parse-shosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
(tramp-parse-group
(tramp-compat-rx bol (group (regexp tramp-host-regexp))) 1 ","))
(tramp-parse-group (rx bol (group (regexp tramp-host-regexp))) 1 ","))
(defun tramp-parse-sconfig (filename)
"Return a list of (user host) tuples allowed to access.
@ -3267,7 +3252,7 @@ User is always nil."
"Return a (user host) tuple allowed to access.
User is always nil."
(tramp-parse-group
(tramp-compat-rx
(rx
(| (: bol (* blank) "Host")
(: bol (+ nonl)) ;; ???
(group (regexp tramp-host-regexp))))
@ -3292,15 +3277,14 @@ User is always nil."
User is always nil."
(tramp-parse-shostkeys-sknownhosts
dirname
(tramp-compat-rx
bol "key_" (+ digit) "_" (group (regexp tramp-host-regexp)) ".pub" eol)))
(rx bol "key_" (+ digit) "_" (group (regexp tramp-host-regexp)) ".pub" eol)))
(defun tramp-parse-sknownhosts (dirname)
"Return a list of (user host) tuples allowed to access.
User is always nil."
(tramp-parse-shostkeys-sknownhosts
dirname
(tramp-compat-rx
(rx
bol (group (regexp tramp-host-regexp)) ".ssh-" (| "dss" "rsa") ".pub" eol)))
(defun tramp-parse-hosts (filename)
@ -3312,8 +3296,7 @@ User is always nil."
"Return a (user host) tuple allowed to access.
User is always nil."
(tramp-parse-group
(tramp-compat-rx
bol (group (| (regexp tramp-ipv6-regexp) (regexp tramp-host-regexp))))
(rx bol (group (| (regexp tramp-ipv6-regexp) (regexp tramp-host-regexp))))
1 (rx blank)))
(defun tramp-parse-passwd (filename)
@ -3332,7 +3315,7 @@ Host is always \"localhost\"."
"Return a (user host) tuple allowed to access.
Host is always \"localhost\"."
(let (result
(regexp (tramp-compat-rx bol (group (regexp tramp-user-regexp)) ":")))
(regexp (rx bol (group (regexp tramp-user-regexp)) ":")))
(when (re-search-forward regexp (line-end-position) t)
(setq result (list (match-string 1) "localhost")))
(forward-line 1)
@ -3383,14 +3366,13 @@ User is always nil."
(tramp-parse-putty-group registry-or-dirname)))))
;; UNIX case.
(tramp-parse-shostkeys-sknownhosts
registry-or-dirname
(tramp-compat-rx bol (group (regexp tramp-host-regexp)) eol))))
registry-or-dirname (rx bol (group (regexp tramp-host-regexp)) eol))))
(defun tramp-parse-putty-group (registry)
"Return a (user host) tuple allowed to access.
User is always nil."
(let (result
(regexp (tramp-compat-rx (literal registry) "\\" (group (+ nonl)))))
(regexp (rx (literal registry) "\\" (group (+ nonl)))))
(when (re-search-forward regexp (line-end-position) t)
(setq result (list nil (match-string 1))))
(forward-line 1)
@ -3812,8 +3794,7 @@ Let-bind it when necessary.")
;; not support tilde expansion. But users could declare a
;; respective connection property. (Bug#53847)
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
@ -3974,9 +3955,7 @@ Let-bind it when necessary.")
(and
completion-ignored-extensions
(string-match-p
(tramp-compat-rx
(regexp (regexp-opt completion-ignored-extensions)) eos)
x)
(rx (regexp (regexp-opt completion-ignored-extensions)) eos) x)
;; We remember the hit.
(push x hits-ignored-extensions))))))
;; No match. So we try again for ignored files.
@ -4007,18 +3986,11 @@ Let-bind it when necessary.")
((not (file-exists-p file2)) t)
;; Tramp reads and writes timestamps on second level. So we round
;; the timestamps to seconds without fractions.
;; `time-convert' has been introduced with Emacs 27.1.
((fboundp 'time-convert)
(time-less-p
(tramp-compat-funcall
'time-convert
(file-attribute-modification-time (file-attributes file2)) 'integer)
(tramp-compat-funcall
'time-convert
(file-attribute-modification-time (file-attributes file1)) 'integer)))
(t (time-less-p
(file-attribute-modification-time (file-attributes file2))
(file-attribute-modification-time (file-attributes file1))))))
(time-convert
(file-attribute-modification-time (file-attributes file2)) 'integer)
(time-convert
(file-attribute-modification-time (file-attributes file1)) 'integer)))))
(defun tramp-handle-file-readable-p (filename)
"Like `file-readable-p' for Tramp files."
@ -4081,9 +4053,8 @@ Let-bind it when necessary.")
(if (directory-name-p filename) #'file-name-as-directory #'identity)
;; Quote properly.
(funcall
(if (tramp-compat-file-name-quoted-p filename)
#'tramp-compat-file-name-quote #'identity)
(let ((result (tramp-compat-file-name-unquote (expand-file-name filename)))
(if (file-name-quoted-p filename) #'file-name-quote #'identity)
(let ((result (file-name-unquote (expand-file-name filename)))
(numchase 0)
;; Don't make the following value larger than necessary.
;; People expect an error message in a timely fashion when
@ -4107,7 +4078,7 @@ Let-bind it when necessary.")
v2
(if (stringp symlink-target)
(if (file-remote-p symlink-target)
(tramp-compat-file-name-quote symlink-target 'top)
(file-name-quote symlink-target 'top)
(tramp-drop-volume-letter
(expand-file-name
symlink-target
@ -4417,53 +4388,49 @@ Parsing the remote \"ps\" output is controlled by
It is not guaranteed, that all process attributes as described in
`process-attributes' are returned. The additional attribute
`pid' shall be returned always."
;; Since Emacs 27.1.
(when (fboundp 'connection-local-criteria-for-default-directory)
(with-tramp-file-property vec "/" "process-attributes"
(ignore-errors
(with-temp-buffer
(hack-connection-local-variables-apply
(connection-local-criteria-for-default-directory))
;; (pop-to-buffer (current-buffer))
(when (zerop
(apply
#'process-file
"ps" nil t nil tramp-process-attributes-ps-args))
(let (result res)
(goto-char (point-min))
(while (not (eobp))
;; (tramp-test-message
;; "%s" (buffer-substring (point) (line-end-position)))
(when (save-excursion
(search-forward-regexp
(rx digit) (line-end-position) 'noerror))
(setq res nil)
(dolist (elt tramp-process-attributes-ps-format)
(push
(cons
(car elt)
(cond
((eq (cdr elt) 'number) (read (current-buffer)))
((eq (cdr elt) 'string)
(search-forward-regexp (rx (+ (not blank))))
(match-string 0))
((numberp (cdr elt))
(search-forward-regexp (rx (+ blank)))
(search-forward-regexp
(rx (+ nonl)) (+ (point) (cdr elt)))
(string-trim (match-string 0)))
((fboundp (cdr elt))
(funcall (cdr elt)))
((null (cdr elt))
(search-forward-regexp (rx (+ blank)))
(buffer-substring (point) (line-end-position)))))
res))
;; `nice' could be `-'.
(setq res (rassq-delete-all '- res))
(push (append res) result))
(forward-line))
;; Return result.
result)))))))
(with-tramp-file-property vec "/" "process-attributes"
(ignore-errors
(with-temp-buffer
(hack-connection-local-variables-apply
(connection-local-criteria-for-default-directory))
;; (pop-to-buffer (current-buffer))
(when (zerop
(apply
#'process-file "ps" nil t nil tramp-process-attributes-ps-args))
(let (result res)
(goto-char (point-min))
(while (not (eobp))
;; (tramp-test-message
;; "%s" (buffer-substring (point) (line-end-position)))
(when (save-excursion
(search-forward-regexp
(rx digit) (line-end-position) 'noerror))
(setq res nil)
(dolist (elt tramp-process-attributes-ps-format)
(push
(cons
(car elt)
(cond
((eq (cdr elt) 'number) (read (current-buffer)))
((eq (cdr elt) 'string)
(search-forward-regexp (rx (+ (not blank))))
(match-string 0))
((numberp (cdr elt))
(search-forward-regexp (rx (+ blank)))
(search-forward-regexp (rx (+ nonl)) (+ (point) (cdr elt)))
(string-trim (match-string 0)))
((fboundp (cdr elt))
(funcall (cdr elt)))
((null (cdr elt))
(search-forward-regexp (rx (+ blank)))
(buffer-substring (point) (line-end-position)))))
res))
;; `nice' could be `-'.
(setq res (rassq-delete-all '- res))
(push (append res) result))
(forward-line))
;; Return result.
result))))))
(defun tramp-handle-list-system-processes ()
"Like `list-system-processes' for Tramp files."
@ -4624,9 +4591,9 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
tramp-prefix-format proxy tramp-postfix-host-format))
(entry
(list (and (stringp host-port)
(tramp-compat-rx bol (literal host-port) eol))
(rx bol (literal host-port) eol))
(and (stringp user-domain)
(tramp-compat-rx bol (literal user-domain) eol))
(rx bol (literal user-domain) eol))
(propertize proxy 'tramp-ad-hoc t))))
(tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry)
;; Add the hop.
@ -4699,14 +4666,14 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
(or
;; The host name is used for the remote shell command.
(member
"%h" (tramp-compat-flatten-tree
"%h" (flatten-tree
(tramp-get-method-parameter item 'tramp-login-args)))
;; The host name must match previous hop.
(string-match-p previous-host host))
(setq tramp-default-proxies-alist saved-tdpa)
(tramp-user-error
vec "Host name `%s' does not match `%s'" host previous-host))
(setq previous-host (tramp-compat-rx bol (literal host) eol)))))
(setq previous-host (rx bol (literal host) eol)))))
;; Result.
target-alist))
@ -4720,7 +4687,7 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(let ((args (tramp-get-method-parameter vec parameter))
(spec (apply 'format-spec-make spec-list)))
;; Expand format spec.
(tramp-compat-flatten-tree
(flatten-tree
(mapcar
(lambda (x)
(setq x (mapcar (lambda (y) (format-spec y spec)) x))
@ -4857,9 +4824,8 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(setq
login-args
(append
(tramp-compat-flatten-tree
(tramp-get-method-parameter v 'tramp-async-args))
(tramp-compat-flatten-tree
(flatten-tree (tramp-get-method-parameter v 'tramp-async-args))
(flatten-tree
(mapcar
(lambda (x) (split-string x " "))
(tramp-expand-args
@ -5061,19 +5027,11 @@ support symbolic links."
(when current-buffer-p
(barf-if-buffer-read-only)
(push-mark nil t))
;; `shell-command-save-pos-or-erase' has been introduced with
;; Emacs 27.1.
(if (fboundp 'shell-command-save-pos-or-erase)
(tramp-compat-funcall
'shell-command-save-pos-or-erase current-buffer-p)
(setq buffer-read-only nil)
(erase-buffer)))
(shell-command-save-pos-or-erase current-buffer-p))
(if (integerp asynchronous)
(let ((tramp-remote-process-environment
;; `async-shell-command-width' has been introduced with
;; Emacs 27.1.
(if (natnump (bound-and-true-p async-shell-command-width))
(if (natnump async-shell-command-width)
(cons (format "COLUMNS=%d"
(bound-and-true-p async-shell-command-width))
tramp-remote-process-environment)
@ -5124,11 +5082,7 @@ support symbolic links."
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point)
(current-buffer))))
;; `shell-command-set-point-after-cmd' has been
;; introduced with Emacs 27.1.
(if (fboundp 'shell-command-set-point-after-cmd)
(tramp-compat-funcall
'shell-command-set-point-after-cmd)))
(shell-command-set-point-after-cmd))
;; There's some output, display it.
(when (with-current-buffer output-buffer (> (point-max) (point-min)))
(display-message-or-buffer output-buffer)))))))
@ -5136,10 +5090,7 @@ support symbolic links."
(defun tramp-handle-start-file-process (name buffer program &rest args)
"Like `start-file-process' for Tramp files.
BUFFER might be a list, in this case STDERR is separated."
;; `make-process' knows the `:file-handler' argument since Emacs
;; 27.1 only. Therefore, we invoke it via `tramp-file-name-handler'.
(tramp-file-name-handler
'make-process
(make-process
:name name
:buffer (if (consp buffer) (car buffer) buffer)
:command (and program (cons program args))
@ -5152,7 +5103,7 @@ BUFFER might be a list, in this case STDERR is separated."
"Like `substitute-in-file-name' for Tramp files.
\"//\" and \"/~\" substitute only in the local filename part."
;; Check, whether the local part is a quoted file name.
(if (tramp-compat-file-name-quoted-p filename)
(if (file-name-quoted-p filename)
filename
;; First, we must replace environment variables.
(setq filename (tramp-replace-environment-variables filename))
@ -5183,6 +5134,12 @@ BUFFER might be a list, in this case STDERR is separated."
(defconst tramp-time-doesnt-exist '(-1 65535)
"An invalid time value, used as \"Doesn't exist\" value.")
(defsubst tramp-defined-time (time)
"Return TIME or nil (when TIME is not a time spec)."
(unless (or (time-equal-p time tramp-time-doesnt-exist)
(time-equal-p time tramp-time-dont-know))
time))
(defun tramp-handle-set-visited-file-modtime (&optional time-list)
"Like `set-visited-file-modtime' for Tramp files."
(unless (buffer-file-name)
@ -5194,7 +5151,7 @@ BUFFER might be a list, in this case STDERR is separated."
(or (file-attribute-modification-time
(file-attributes (buffer-file-name)))
tramp-time-doesnt-exist))))
(unless (tramp-compat-time-equal-p time-list tramp-time-dont-know)
(unless (time-equal-p time-list tramp-time-dont-know)
(tramp-run-real-handler #'set-visited-file-modtime (list time-list))))
(defun tramp-handle-verify-visited-file-modtime (&optional buf)
@ -5220,14 +5177,13 @@ of."
(cond
;; File exists, and has a known modtime.
((and attr
(not (tramp-compat-time-equal-p modtime tramp-time-dont-know)))
((and attr (not (time-equal-p modtime tramp-time-dont-know)))
(< (abs (tramp-time-diff modtime mt)) 2))
;; Modtime has the don't know value.
(attr t)
;; If file does not exist, say it is not modified if and
;; only if that agrees with the buffer's record.
(t (tramp-compat-time-equal-p mt tramp-time-doesnt-exist))))))))
(t (time-equal-p mt tramp-time-doesnt-exist))))))))
(defun tramp-handle-write-region
(start end filename &optional append visit lockname mustbenew)
@ -5424,7 +5380,7 @@ Wait, until the connection buffer changes."
;; Hide message in buffer.
(narrow-to-region (point-max) (point-max))
;; Wait for new output.
(while (not (tramp-compat-ignore-error file-error
(while (not (ignore-error file-error
(tramp-wait-for-regexp
proc 0.1 tramp-security-key-confirmed-regexp)))
(when (tramp-check-for-regexp proc tramp-security-key-timeout-regexp)
@ -5756,8 +5712,7 @@ the remote host use line-endings as defined in the variable
(tramp-flush-directory-properties vec "/"))
(when (buffer-live-p buf)
(with-current-buffer buf
(when (and prompt
(tramp-search-regexp (tramp-compat-rx (literal prompt))))
(when (and prompt (tramp-search-regexp (rx (literal prompt))))
(delete-region (point) (point-max))))))))
(defun tramp-get-inode (vec)
@ -5942,9 +5897,7 @@ ID-FORMAT valid values are `string' and `integer'."
(with-tramp-connection-property nil (format "gid-%s" id-format)
(cond
((equal id-format 'integer) (group-gid))
;; `group-name' has been introduced with Emacs 27.1.
((and (fboundp 'group-name) (equal id-format 'string))
(tramp-compat-funcall 'group-name (group-gid)))
((equal id-format 'string) (group-name (group-gid)))
((file-attribute-group-id (file-attributes "~/" id-format))))))
(defun tramp-get-local-locale (&optional vec)
@ -5961,7 +5914,7 @@ VEC is used for tracing."
(while candidates
(goto-char (point-min))
(if (string-match-p
(tramp-compat-rx bol (literal (car candidates)) (? "\r") eol)
(rx bol (literal (car candidates)) (? "\r") eol)
(buffer-string))
(setq locale (car candidates)
candidates nil)
@ -6292,7 +6245,7 @@ this file, if that variable is non-nil."
("|" . "__")
("[" . "_l")
("]" . "_r"))
(tramp-compat-file-name-unquote (buffer-file-name)))
(file-name-unquote (buffer-file-name)))
tramp-auto-save-directory)))
result)
(prog1 ;; Run plain `make-auto-save-file-name'.
@ -6321,7 +6274,7 @@ ALIST is of the form ((FROM . TO) ...)."
(let* ((pr (car alist))
(from (car pr))
(to (cdr pr)))
(while (string-match (tramp-compat-rx (literal from)) string)
(while (string-match (rx (literal from)) string)
(setq string (replace-match to t t string)))
(setq alist (cdr alist))))
string))
@ -6556,7 +6509,7 @@ T1 and T2 are time values (as returned by `current-time' for example)."
Suppress `shell-file-name'. This is needed on w32 systems, which
would use a wrong quoting for local file names. See `w32-shell-name'."
(let (shell-file-name)
(shell-quote-argument (tramp-compat-file-name-unquote s))))
(shell-quote-argument (file-name-unquote s))))
;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
;; does not deal well with newline characters. Newline is replaced by
@ -6589,7 +6542,7 @@ Only works for Bourne-like shells."
(string= (substring result 0 2) "\\~"))
(setq result (substring result 1)))
(replace-regexp-in-string
(tramp-compat-rx "\\" (literal tramp-rsh-end-of-line))
(rx "\\" (literal tramp-rsh-end-of-line))
(format "'%s'" tramp-rsh-end-of-line) result)))))
;;; Signal handling. This works for remote processes, which have set

View file

@ -7,8 +7,8 @@
;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes
;; Package: tramp
;; Version: 2.6.0-pre
;; Package-Requires: ((emacs "26.1"))
;; Version: 2.7.0-pre
;; Package-Requires: ((emacs "27.1"))
;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/
@ -40,7 +40,7 @@
;; ./configure" to change them.
;;;###tramp-autoload
(defconst tramp-version "2.6.0-pre"
(defconst tramp-version "2.7.0-pre"
"This version of Tramp.")
;;;###tramp-autoload
@ -55,11 +55,9 @@
(dir (or (locate-dominating-file (locate-library "tramp") ".git")
source-directory))
debug-on-error)
;; `emacs-repository-get-branch' has been introduced with Emacs 27.1.
(with-no-warnings
(and (stringp dir) (file-directory-p dir)
(executable-find "git")
(emacs-repository-get-branch dir)))))
(and (stringp dir) (file-directory-p dir)
(executable-find "git")
(emacs-repository-get-branch dir))))
"The repository branch of the Tramp sources.")
(defconst tramp-repository-version
@ -76,9 +74,9 @@
"The repository revision of the Tramp sources.")
;; Check for Emacs version.
(let ((x (if (not (string-version-lessp emacs-version "26.1"))
(let ((x (if (not (string-version-lessp emacs-version "27.1"))
"ok"
(format "Tramp 2.6.0-pre is not fit for %s"
(format "Tramp 2.7.0-pre is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x)))
@ -104,7 +102,8 @@
("2.3.3" . "26.1") ("2.3.3.26.1" . "26.1") ("2.3.5.26.2" . "26.2")
("2.3.5.26.3" . "26.3")
("2.4.3.27.1" . "27.1") ("2.4.5.27.2" . "27.2")
("2.5.2.28.1" . "28.1") ("2.5.3.28.2" . "28.2")))
("2.5.2.28.1" . "28.1") ("2.5.3.28.2" . "28.2")
("2.6.0.29.1" . "29.1")))
(add-hook 'tramp-unload-hook
(lambda ()

View file

@ -121,12 +121,6 @@ the origin of the temporary TMPFILE, have no write permissions."
(directory-files tmpfile 'full directory-files-no-dot-files-regexp))
(delete-directory tmpfile)))
(defun tramp-archive--test-emacs27-p ()
"Check for Emacs version >= 27.1.
Some semantics has been changed for there, without new functions or
variables, so we check the Emacs version directly."
(>= emacs-major-version 27))
(ert-deftest tramp-archive-test00-availability ()
"Test availability of archive file name functions."
:expected-result (if tramp-archive-enabled :passed :failed)
@ -615,16 +609,13 @@ This checks also `file-name-as-directory', `file-name-directory',
(with-temp-buffer
(insert-directory tramp-archive-test-archive nil)
(goto-char (point-min))
(should
(looking-at-p
(tramp-compat-rx (literal tramp-archive-test-archive)))))
(should (looking-at-p (rx (literal tramp-archive-test-archive)))))
(with-temp-buffer
(insert-directory tramp-archive-test-archive "-al")
(goto-char (point-min))
(should
(looking-at-p
(tramp-compat-rx
bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
(rx bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
(with-temp-buffer
(insert-directory
(file-name-as-directory tramp-archive-test-archive)
@ -877,12 +868,8 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
(ert-deftest tramp-archive-test43-file-system-info ()
"Check that `file-system-info' returns proper values."
(skip-unless tramp-archive-enabled)
;; Since Emacs 27.1.
(skip-unless (fboundp 'file-system-info))
;; `file-system-info' exists since Emacs 27. We don't want to see
;; compiler warnings for older Emacsen.
(let ((fsi (with-no-warnings (file-system-info tramp-archive-test-archive))))
(let ((fsi (file-system-info tramp-archive-test-archive)))
(skip-unless fsi)
(should (and (consp fsi)
(= (length fsi) 3)
@ -895,8 +882,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
"Check that `tramp-archive' autoloads properly."
:tags '(:expensive-test)
(skip-unless tramp-archive-enabled)
;; Autoloading tramp-archive works since Emacs 27.1.
(skip-unless (tramp-archive--test-emacs27-p))
;; tramp-archive is neither loaded at Emacs startup, nor when
;; loading a file like "/mock::foo" (which loads Tramp).
@ -919,7 +904,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
(dolist (file `("/mock::foo" ,(concat tramp-archive-test-archive "foo")))
(should
(string-match
(tramp-compat-rx
(rx
"tramp-archive loaded: "
(literal (symbol-name
(tramp-archive-file-name-p default-directory)))
@ -942,8 +927,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
"Check that `tramp-archive' is loaded lazily, only when needed."
:tags '(:expensive-test)
(skip-unless tramp-archive-enabled)
;; Autoloading tramp-archive works since Emacs 27.1.
(skip-unless (tramp-archive--test-emacs27-p))
;; tramp-archive is neither loaded at Emacs startup, nor when
;; loading a file like "/foo.tar". It is loaded only when
@ -964,7 +947,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
(dolist (tae '(t nil))
(should
(string-match
(tramp-compat-rx
(rx
"tramp-archive loaded: nil" (+ ascii)
"tramp-archive loaded: nil" (+ ascii)
"tramp-archive loaded: " (literal (symbol-name tae)))

File diff suppressed because it is too large Load diff