Remove Emacs 27 compatibility from Tramp

* doc/misc/tramp.texi (Frequently Asked Questions):
Adapt supported Emacs versions.

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

* lisp/net/tramp-compat.el (tramp-compat-file-modes)
(tramp-compat-set-file-modes, tramp-compat-set-file-times)
(tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes)
(tramp-compat-directory-empty-p, tramp-compat-null-device)
(tramp-compat-string-replace, tramp-compat-string-search)
(tramp-compat-make-lock-file-name)
(tramp-compat-file-name-concat)
(tramp-compat-replace-regexp-in-region, tramp-compat-length<)
(tramp-compat-length>, tramp-compat-length=)
(tramp-compat-always): Remove.

* lisp/net/tramp-adb.el:
* lisp/net/tramp-androidsu.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-compat.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-message.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: Use original objects instead of their
`tramp-compat-' counterparts when possible.
This commit is contained in:
Michael Albinus 2024-07-24 15:25:55 +02:00
parent 135ce96f1e
commit c4e8112f98
18 changed files with 123 additions and 300 deletions

View file

@ -3361,11 +3361,10 @@ files, set user option
@code{remote-file-name-inhibit-auto-save-visited} to non-@code{nil}.
@vindex lock-file-name-transforms
And still more issues to handle. Since @w{Emacs 28}, file locks use a
similar user option as auto-save files, called
@code{lock-file-name-transforms}. By default this user option is
@code{nil}, meaning to keep file locks in the same directory as the
original file.
And still more issues to handle. File locks use a similar user option
as auto-save files, called @code{lock-file-name-transforms}. By
default this user option is @code{nil}, meaning to keep file locks in
the same directory as the original file.
If you change @code{lock-file-name-transforms} in order to keep file
locks for remote files somewhere else, you will lose Emacs's feature
@ -5154,8 +5153,8 @@ Where is the latest @value{tramp}?
@item
Which systems does it work on?
The package works successfully on @w{Emacs 27}, @w{Emacs 28}, @w{Emacs
29}, and @w{Emacs 30}.
The package works successfully on @w{Emacs 28}, @w{Emacs 29}, @w{Emacs
30}, and @w{Emacs 31}.
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.7.2-pre
@set trampver 2.8.0-pre
@set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 27.1
@set emacsver 28.1
@c Other flags from configuration.
@set instprefix /usr/local

View file

@ -228,7 +228,7 @@ arguments to pass to the OPERATION."
(when (string-match
(rx bol (group (+ (not blank))) (+ blank) "device" eol) line)
;; Replace ":" by "#".
`(nil ,(tramp-compat-string-replace
`(nil ,(string-replace
":" tramp-prefix-port-format (match-string 1 line)))))
(tramp-process-lines nil tramp-adb-program "devices")))
@ -329,10 +329,10 @@ arguments to pass to the OPERATION."
v (format "%s -d -a -l %s %s | cat"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname "."))
(file-name-concat localname "."))
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
(tramp-compat-replace-regexp-in-region
(file-name-concat localname ".."))))
(replace-regexp-in-region
(rx (literal (file-name-unquote (file-name-as-directory localname))))
"" (point-min))
(widen)))
@ -373,7 +373,7 @@ Emacs dired can't find files."
(search-forward-regexp
(rx blank (group blank (regexp tramp-adb-ls-date-year-regexp) blank))
nil t)
(replace-match "0\\1" "\\1" nil)
(replace-match "0\\1" "\\1")
;; Insert missing "/".
(when (looking-at-p
(rx (regexp tramp-adb-ls-date-time-regexp) (+ blank) eol))
@ -650,7 +650,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; KEEP-DATE handling.
(when keep-date
(tramp-compat-set-file-times
(set-file-times
newname
(file-attribute-modification-time (file-attributes filename))
(unless ok-if-already-exists 'nofollow)))))
@ -946,7 +946,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
(let* ((host (tramp-file-name-host vec))
(port (tramp-file-name-port-or-default vec))
(devices (mapcar #'cadr (tramp-adb-parse-device-names nil))))
(tramp-compat-string-replace
(string-replace
tramp-prefix-port-format ":"
(cond ((member host devices) host)
;; This is the case when the host is connected to the default port.
@ -956,15 +956,14 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
;; An empty host name shall be mapped as well, when there
;; is exactly one entry in `devices'.
((and (tramp-string-empty-or-nil-p host)
(tramp-compat-length= devices 1))
(length= devices 1))
(car devices))
;; Try to connect device.
((and tramp-adb-connect-if-not-connected
(tramp-compat-length> host 0)
(length> host 0)
(tramp-adb-execute-adb-command
vec "connect"
(tramp-compat-string-replace
tramp-prefix-port-format ":" host)))
(string-replace tramp-prefix-port-format ":" host)))
;; When new device connected, running other adb command (e.g.
;; adb shell) immediately will fail. To get around this
;; problem, add sleep 0.1 second here.
@ -977,7 +976,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
"Execute an adb command.
Insert the result into the connection buffer. Return nil on
error and non-nil on success."
(when (and (tramp-compat-length> (tramp-file-name-host vec) 0)
(when (and (length> (tramp-file-name-host vec) 0)
;; The -s switch is only available for ADB device commands.
(not (member (car args) '("connect" "disconnect"))))
(setq args (append (list "-s" (tramp-adb-get-device vec)) args)))
@ -1021,7 +1020,7 @@ error and non-nil on success."
;; system, but this requires changes in core Tramp.
(goto-char (point-min))
(while (search-forward-regexp (rx (+ "\r") eol) nil t)
(replace-match "" nil nil)))))))
(replace-match "")))))))
(defun tramp-adb-send-command-and-check
(vec command &optional exit-status command-augmented-p)

View file

@ -304,15 +304,14 @@ FUNCTION."
"Like `tramp-handle-make-process', but modified for Android."
(tramp-skeleton-make-process args nil nil
(let* ((env (mapcar
(lambda (elt)
(when (tramp-compat-string-search "=" elt) elt))
(lambda (elt) (when (string-search "=" elt) elt))
tramp-remote-process-environment))
;; We use as environment the difference to toplevel
;; `process-environment'.
(env (dolist (elt process-environment env)
(when
(and
(tramp-compat-string-search "=" elt)
(string-search "=" elt)
(not
(member
elt (default-toplevel-value 'process-environment))))

View file

@ -602,7 +602,7 @@ offered."
(defun tramp-archive-handle-directory-file-name (directory)
"Like `directory-file-name' for file archives."
(with-parsed-tramp-archive-file-name directory nil
(if (and (tramp-compat-length> localname 0)
(if (and (length> localname 0)
(eq (aref localname (1- (length localname))) ?/)
(not (string= localname "/")))
(substring directory 0 -1)

View file

@ -271,8 +271,7 @@ Remove also properties of all files in subdirectories."
(dolist (key (hash-table-keys tramp-cache-data))
(when (and (tramp-file-name-p key)
(stringp (tramp-file-name-localname key))
(tramp-compat-string-search
directory (tramp-file-name-localname key)))
(string-search directory (tramp-file-name-localname key)))
(remhash key tramp-cache-data)))
;; Remove file properties of symlinks.
(when (and (stringp truename)

View file

@ -287,7 +287,7 @@ non-nil."
(defun tramp-cleanup-all-buffers ()
"Kill all remote buffers."
(interactive)
(let ((tramp-cleanup-some-buffers-hook '(tramp-compat-always)))
(let ((tramp-cleanup-some-buffers-hook '(always)))
(tramp-cleanup-some-buffers)))
;;; Rename
@ -472,8 +472,7 @@ ESC or `q' to quit without changing further buffers,
(dolist (buffer (tramp-list-remote-buffers))
(switch-to-buffer buffer)
(let* ((bfn (buffer-file-name))
(new-bfn (and (stringp bfn)
(tramp-compat-string-replace source target bfn)))
(new-bfn (and (stringp bfn) (string-replace source target bfn)))
(prompt (format-message
"Set visited file name to `%s' [Type yn!eq or %s] "
new-bfn (key-description (vector help-char)))))
@ -827,7 +826,7 @@ buffer in your bug report.
(insert "\nload-path shadows:\n==================\n")
(ignore-errors
(mapc
(lambda (x) (when (tramp-compat-string-search "tramp" x) (insert x "\n")))
(lambda (x) (when (string-search "tramp" x) (insert x "\n")))
(split-string (list-load-path-shadows t) "\n")))
;; Append buffers only when we are in message mode.

View file

@ -24,8 +24,8 @@
;;; Commentary:
;; Tramp's main Emacs version for development is Emacs 30. This
;; package provides compatibility functions for Emacs 27, Emacs 28 and
;; Emacs 29.
;; package provides compatibility functions for Emacs 28, Emacs 29 and
;; Emacs 30.
;;; Code:
@ -79,8 +79,7 @@
(if-let ((xdg (xdg-cache-home))
((file-directory-p xdg))
((file-writable-p xdg)))
;; We can use `file-name-concat' starting with Emacs 28.1.
(prog1 (setq xdg (concat (file-name-as-directory xdg) "emacs"))
(prog1 (setq xdg (file-name-concat xdg "emacs"))
(make-directory xdg t))
(eval (car (get 'temporary-file-directory 'standard-value)) t)))
"The default value of `temporary-file-directory' for Tramp.")
@ -99,152 +98,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-modes', `set-file-modes' and `set-file-times' got argument
;; FLAG in Emacs 28.1.
(defalias 'tramp-compat-file-modes
(if (equal (func-arity #'file-modes) '(1 . 2))
#'file-modes
(lambda (filename &optional _flag)
(file-modes filename))))
(defalias 'tramp-compat-set-file-modes
(if (equal (func-arity #'set-file-modes) '(2 . 3))
#'set-file-modes
(lambda (filename mode &optional _flag)
(set-file-modes filename mode))))
(defalias 'tramp-compat-set-file-times
(if (equal (func-arity #'set-file-times) '(1 . 3))
#'set-file-times
(lambda (filename &optional timestamp _flag)
(set-file-times filename timestamp))))
;; `directory-files' and `directory-files-and-attributes' got argument
;; COUNT in Emacs 28.1.
(defalias 'tramp-compat-directory-files
(if (equal (func-arity #'directory-files) '(1 . 5))
#'directory-files
(lambda (directory &optional full match nosort _count)
(directory-files directory full match nosort))))
(defalias 'tramp-compat-directory-files-and-attributes
(if (equal (func-arity #'directory-files-and-attributes) '(1 . 6))
#'directory-files-and-attributes
(lambda (directory &optional full match nosort id-format _count)
(directory-files-and-attributes directory full match nosort id-format))))
;; `directory-empty-p' is new in Emacs 28.1.
(defalias 'tramp-compat-directory-empty-p
(if (fboundp 'directory-empty-p)
#'directory-empty-p
(lambda (dir)
(and (file-directory-p dir)
(null (tramp-compat-directory-files
dir nil directory-files-no-dot-files-regexp t 1))))))
;; Function `null-device' is new in Emacs 28.1.
(defalias 'tramp-compat-null-device
(if (fboundp 'null-device)
#'null-device
(lambda ()
(if (tramp-tramp-file-p default-directory) "/dev/null" null-device))))
;; Function `string-replace' is new in Emacs 28.1.
(defalias 'tramp-compat-string-replace
(if (fboundp 'string-replace)
#'string-replace
(lambda (from-string to-string in-string)
(let (case-fold-search)
(replace-regexp-in-string
(regexp-quote from-string) to-string in-string t t)))))
;; Function `string-search' is new in Emacs 28.1.
(defalias 'tramp-compat-string-search
(if (fboundp 'string-search)
#'string-search
(lambda (needle haystack &optional start-pos)
(let (case-fold-search)
(string-match-p (regexp-quote needle) haystack start-pos)))))
;; Function `make-lock-file-name' is new in Emacs 28.1.
(defalias 'tramp-compat-make-lock-file-name
(if (fboundp 'make-lock-file-name)
#'make-lock-file-name
(lambda (filename)
(expand-file-name
(concat
".#" (file-name-nondirectory filename))
(file-name-directory filename)))))
;; Function `file-name-concat' is new in Emacs 28.1.
(defalias 'tramp-compat-file-name-concat
(if (fboundp 'file-name-concat)
#'file-name-concat
(lambda (directory &rest components)
(let ((components (cl-remove-if (lambda (el)
(or (null el) (equal "" el)))
components))
file-name-handler-alist)
(if (null components)
directory
(apply #'tramp-compat-file-name-concat
(concat (unless (or (equal "" directory) (null directory))
(file-name-as-directory directory))
(car components))
(cdr components)))))))
;; Function `replace-regexp-in-region' is new in Emacs 28.1.
(defalias 'tramp-compat-replace-regexp-in-region
(if (fboundp 'replace-regexp-in-region)
#'replace-regexp-in-region
(lambda (regexp replacement &optional start end)
(if start
(when (< start (point-min))
(error "Start before start of buffer"))
(setq start (point)))
(if end
(when (> end (point-max))
(error "End after end of buffer"))
(setq end (point-max)))
(save-excursion
(let ((matches 0)
(case-fold-search nil))
(goto-char start)
(while (search-forward-regexp regexp end t)
(replace-match replacement t)
(setq matches (1+ matches)))
(and (not (zerop matches))
matches))))))
;; `length<', `length>' and `length=' are added to Emacs 28.1.
(defalias 'tramp-compat-length<
(if (fboundp 'length<)
#'length<
(lambda (sequence length)
(< (length sequence) length))))
(defalias 'tramp-compat-length>
(if (fboundp 'length>)
#'length>
(lambda (sequence length)
(> (length sequence) length))))
(defalias 'tramp-compat-length=
(if (fboundp 'length=)
#'length=
(lambda (sequence length)
(= (length sequence) length))))
;; `always' is introduced with Emacs 28.1.
(defalias 'tramp-compat-always
(if (fboundp 'always)
#'always
(lambda (&rest _arguments)
"Do nothing and return t.
This function accepts any number of ARGUMENTS, but ignores them.
Also see `ignore'."
t)))
;; `permission-denied' is introduced in Emacs 29.1.
(defconst tramp-permission-denied
(if (get 'permission-denied 'error-conditions) 'permission-denied 'file-error)
@ -274,7 +127,7 @@ Also see `ignore'."
#'take
(lambda (n list)
(when (and (natnump n) (> n 0))
(if (tramp-compat-length< list n)
(if (length< list n)
list (butlast list (- (length list) n)))))))
;; Function `ntake' is new in Emacs 29.1.
@ -283,7 +136,7 @@ Also see `ignore'."
#'ntake
(lambda (n list)
(when (and (natnump n) (> n 0))
(if (tramp-compat-length< list n)
(if (length< list n)
list (nbutlast list (- (length list) n)))))))
;; Function `string-equal-ignore-case' is new in Emacs 29.1.

View file

@ -831,15 +831,13 @@ WILDCARD is not supported."
"Like `set-file-modes' for Tramp files."
(tramp-skeleton-set-file-modes-times-uid-gid filename
(let (tramp-crypt-enabled)
(tramp-compat-set-file-modes
(tramp-crypt-encrypt-file-name filename) mode flag))))
(set-file-modes (tramp-crypt-encrypt-file-name filename) mode flag))))
(defun tramp-crypt-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 (tramp-crypt-enabled)
(tramp-compat-set-file-times
(tramp-crypt-encrypt-file-name filename) time flag))))
(set-file-times (tramp-crypt-encrypt-file-name filename) time flag))))
(defun tramp-crypt-handle-set-file-uid-gid (filename &optional uid gid)
"Like `tramp-set-file-uid-gid' for Tramp files."

View file

@ -63,8 +63,7 @@
(append
'("." "..")
(tramp-fuse-remove-hidden-files
(tramp-compat-directory-files
(tramp-fuse-local-file-name directory))))))))
(directory-files (tramp-fuse-local-file-name directory))))))))
(if full
;; Massage the result.
(let ((local (rx
@ -207,7 +206,7 @@ It has the same meaning as `remote-file-name-inhibit-cache'.")
(delete (tramp-file-name-unify vec) tramp-fuse-mount-points))
;; Give the caches a chance to expire.
(sleep-for 1)
(when (tramp-compat-directory-empty-p mount-point)
(when (directory-empty-p mount-point)
(delete-directory mount-point))))
(defun tramp-fuse-local-file-name (filename)

View file

@ -1169,7 +1169,7 @@ file names."
(delete-file file)))
(directory-files
directory 'full directory-files-no-dot-files-regexp))
(unless (tramp-compat-directory-empty-p directory)
(unless (directory-empty-p directory)
(tramp-error
v 'file-error "Couldn't delete non-empty %s" directory)))
@ -1203,7 +1203,7 @@ file names."
(setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
(setq name (file-name-concat dir name)))
;; If NAME is not a Tramp file, run the real handler.
(if (not (tramp-tramp-file-p name))
(tramp-run-real-handler #'expand-file-name (list name))
@ -1465,7 +1465,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
(defun tramp-gvfs-handle-file-name-all-completions (filename directory)
"Like `file-name-all-completions' for Tramp files."
(tramp-skeleton-file-name-all-completions filename directory
(unless (tramp-compat-string-search "/" filename)
(unless (string-search "/" filename)
(all-completions
filename
(with-parsed-tramp-file-name (expand-file-name directory) nil
@ -1533,12 +1533,9 @@ If FILE-SYSTEM is non-nil, return file system attributes."
(tramp-message proc 6 "%S\n%s" proc string)
(setq string (concat rest-string string)
;; Fix action names.
string (tramp-compat-string-replace
"attributes changed" "attribute-changed" string)
string (tramp-compat-string-replace
"changes done" "changes-done-hint" string)
string (tramp-compat-string-replace
"renamed to" "moved" string))
string (string-replace "attributes changed" "attribute-changed" string)
string (string-replace "changes done" "changes-done-hint" string)
string (string-replace "renamed to" "moved" string))
;; https://bugs.launchpad.net/bugs/1742946
(when
(string-match-p
@ -2145,7 +2142,7 @@ Their full names are
(vec (make-tramp-file-name
:method "mtp"
;; A host name cannot contain spaces.
:host (tramp-compat-string-replace " " "_" (nth 1 volume))))
:host (string-replace " " "_" (nth 1 volume))))
(media (make-tramp-media-device
:method method
:host (tramp-gvfs-url-host (nth 5 volume))
@ -2462,7 +2459,7 @@ VEC is used only for traces."
(vec (make-tramp-file-name
:method "mtp"
;; A host name cannot contain spaces.
:host (tramp-compat-string-replace " " "_" (nth 1 volume))))
:host (string-replace " " "_" (nth 1 volume))))
(media (make-tramp-media-device
:method method
:host (tramp-gvfs-url-host (nth 5 volume))
@ -2476,7 +2473,7 @@ VEC is used only for traces."
;; Adapt default host name, supporting /mtp:: when possible.
(setq tramp-default-host-alist
(append
`(("mtp" nil ,(if (tramp-compat-length= devices 1) (car devices) "")))
`(("mtp" nil ,(if (length= devices 1) (car devices) "")))
(delete
(assoc "mtp" tramp-default-host-alist)
tramp-default-host-alist)))))

View file

@ -190,13 +190,13 @@ They are completed by `M-x TAB' only in Tramp debug buffers."
"Get the debug file name for VEC."
(declare (tramp-suppress-trace t))
(expand-file-name
(tramp-compat-string-replace "/" " " (tramp-debug-buffer-name vec))
(string-replace "/" " " (tramp-debug-buffer-name vec))
tramp-compat-temporary-file-directory))
(defun tramp-trace-buffer-name (vec)
"A name for the trace buffer for VEC."
(declare (tramp-suppress-trace t))
(tramp-compat-string-replace "*debug" "*trace" (tramp-debug-buffer-name vec)))
(string-replace "*debug" "*trace" (tramp-debug-buffer-name vec)))
(defvar tramp-trace-functions nil
"A list of non-Tramp functions to be traced with `tramp-verbose' > 10.")

View file

@ -1909,9 +1909,9 @@ ID-FORMAT valid values are `string' and `integer'."
"Like `file-name-all-completions' for Tramp files."
(tramp-skeleton-file-name-all-completions filename directory
(with-parsed-tramp-file-name (expand-file-name directory) nil
(when (and (not (tramp-compat-string-search "/" filename))
(when (and (not (string-search "/" filename))
(tramp-connectable-p v))
(unless (tramp-compat-string-search "/" filename)
(unless (string-search "/" filename)
(all-completions
filename
(with-tramp-file-property v localname "file-name-all-completions"
@ -2228,7 +2228,7 @@ file names."
;; KEEP-DATE handling.
(when (and keep-date (not copy-keep-date))
(tramp-compat-set-file-times
(set-file-times
newname file-times (unless ok-if-already-exists 'nofollow)))
;; Set the mode.
@ -2505,8 +2505,7 @@ The method used must be an out-of-band method."
copy-args
(flatten-tree
(mapcar
(lambda (x) (if (tramp-compat-string-search " " x)
(split-string x) x))
(lambda (x) (if (string-search " " x) (split-string x) x))
copy-args))
copy-env (apply #'tramp-expand-args v 'tramp-copy-env nil spec)
remote-copy-program
@ -2805,7 +2804,7 @@ The method used must be an out-of-band method."
(save-restriction
(narrow-to-region beg-marker end-marker)
;; Some busyboxes are reluctant to discard colors.
(unless (tramp-compat-string-search
(unless (string-search
"color" (tramp-get-connection-property v "ls" ""))
(goto-char (point-min))
(while (search-forward-regexp ansi-color-control-seq-regexp nil t)
@ -2892,7 +2891,7 @@ the result will be a local, non-Tramp, file name."
(tramp-run-real-handler #'expand-file-name (list name dir))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
(setq name (file-name-concat dir name)))
;; Dissect NAME.
(with-parsed-tramp-file-name name nil
;; If connection is not established yet, run the real handler.
@ -2983,7 +2982,7 @@ will be used."
(heredoc (and (not (bufferp stderr))
(stringp program)
(string-match-p (rx "sh" eol) program)
(tramp-compat-length= args 2)
(length= args 2)
(string-equal "-c" (car args))
;; Don't if there is a quoted string.
(not (string-match-p (rx (any "'\"")) (cadr args)))
@ -2992,7 +2991,7 @@ will be used."
;; When PROGRAM is nil, we just provide a tty.
(args (if (not heredoc) args
(let ((i 250))
(while (and (not (tramp-compat-length< (cadr args) i))
(while (and (not (length< (cadr args) i))
(string-match " " (cadr args) i))
(setcdr
args
@ -3011,7 +3010,7 @@ will be used."
(env (dolist (elt (cons prompt process-environment) env)
(or (member
elt (default-toplevel-value 'process-environment))
(if (tramp-compat-string-search "=" elt)
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv))))))
(env (setenv-internal
@ -3244,7 +3243,7 @@ will be used."
;; We use as environment the difference to toplevel `process-environment'.
(dolist (elt process-environment)
(or (member elt (default-toplevel-value 'process-environment))
(if (tramp-compat-string-search "=" elt)
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv)))))
(setq env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep))
@ -3773,7 +3772,7 @@ Fall back to normal file name handler if no Tramp handler exists."
;; Make events a list of symbols.
events
(mapcar
(lambda (x) (intern-soft (tramp-compat-string-replace "_" "-" x)))
(lambda (x) (intern-soft (string-replace "_" "-" x)))
(split-string events "," 'omit))))
;; "gio monitor".
((setq command (tramp-get-remote-gio-monitor v))
@ -3831,12 +3830,9 @@ Fall back to normal file name handler if no Tramp handler exists."
(tramp-message proc 6 "%S\n%s" proc string)
(setq string (concat rest-string string)
;; Fix action names.
string (tramp-compat-string-replace
"attributes changed" "attribute-changed" string)
string (tramp-compat-string-replace
"changes done" "changes-done-hint" string)
string (tramp-compat-string-replace
"renamed to" "moved" string))
string (string-replace "attributes changed" "attribute-changed" string)
string (string-replace "changes done" "changes-done-hint" string)
string (string-replace "renamed to" "moved" string))
(catch 'doesnt-work
;; https://bugs.launchpad.net/bugs/1742946
@ -3871,7 +3867,7 @@ Fall back to normal file name handler if no Tramp handler exists."
(setq string (substring string pos)))
;; Delete empty lines.
(setq string (tramp-compat-string-replace "\n\n" "\n" string))
(setq string (string-replace "\n\n" "\n" string))
(while (string-match
(rx
@ -3924,9 +3920,7 @@ Fall back to normal file name handler if no Tramp handler exists."
(list
proc
(mapcar
(lambda (x)
(intern-soft
(tramp-compat-string-replace "_" "-" (downcase x))))
(lambda (x) (intern-soft (string-replace "_" "-" (downcase x))))
(split-string (match-string 1 line) "," 'omit))
(or (match-string 2 line)
(file-name-nondirectory
@ -4050,8 +4044,8 @@ Only send the definition if it has not already been done."
vec 5 (format-message "Sending script `%s'" name)
;; In bash, leading TABs like in `tramp-bundle-read-file-names'
;; could result in unwanted command expansion. Avoid this.
(setq script (tramp-compat-string-replace
(make-string 1 ?\t) (make-string 8 ? ) script))
(setq script
(string-replace (make-string 1 ?\t) (make-string 8 ? ) script))
;; Expand format specifiers.
(unless (setq script (tramp-expand-script vec script))
(tramp-error
@ -4141,7 +4135,7 @@ variable PATH."
(pipe-buf (tramp-get-remote-pipe-buf vec))
tmpfile chunk chunksize)
(tramp-message vec 5 "Setting $PATH environment variable")
(if (tramp-compat-length< command pipe-buf)
(if (length< command pipe-buf)
(tramp-send-command vec command)
;; Use a temporary file. We cannot use `write-region' because
;; setting the remote path happens in the early connection
@ -4793,12 +4787,12 @@ means standard output and thus the current buffer), or nil (which
means discard it)."
(tramp-call-process
nil tramp-encoding-shell
(when (and input (not (tramp-compat-string-search "%s" cmd))) input)
(when (and input (not (string-search "%s" cmd))) input)
(if (eq output t) t nil)
nil
tramp-encoding-command-switch
(concat
(if (tramp-compat-string-search "%s" cmd) (format cmd input) cmd)
(if (string-search "%s" cmd) (format cmd input) cmd)
(if (stringp output) (concat " >" output) ""))))
(defconst tramp-inline-compress-commands
@ -6003,13 +5997,12 @@ function cell is returned to be applied on a buffer."
(with-tramp-connection-property (tramp-get-process vec) prop
(tramp-find-inline-encoding vec)
(tramp-get-connection-property (tramp-get-process vec) prop)))
(prop1 (if (tramp-compat-string-search "encoding" prop)
(prop1 (if (string-search "encoding" prop)
"inline-compress" "inline-decompress"))
compress)
;; The connection property might have been cached. So we must
;; send the script to the remote side - maybe.
(when (and coding (symbolp coding)
(tramp-compat-string-search "remote" prop))
(when (and coding (symbolp coding) (string-search "remote" prop))
(let ((name (symbol-name coding)))
(while (string-match "-" name)
(setq name (replace-match "_" nil t name)))
@ -6021,7 +6014,7 @@ function cell is returned to be applied on a buffer."
;; Return the value.
(cond
((and compress (symbolp coding))
(if (tramp-compat-string-search "decompress" prop1)
(if (string-search "decompress" prop1)
`(lambda (beg end)
(,coding beg end)
(let ((coding-system-for-write 'binary)
@ -6040,16 +6033,15 @@ function cell is returned to be applied on a buffer."
(,coding (point-min) (point-max)))))
((symbolp coding)
coding)
((and compress (tramp-compat-string-search "decoding" prop))
((and compress (string-search "decoding" prop))
(format
;; Windows shells need the program file name after
;; the pipe symbol be quoted if they use forward
;; slashes as directory separators.
(cond
((and (tramp-compat-string-search "local" prop)
(eq system-type 'windows-nt))
"(%s | \"%s\")")
((tramp-compat-string-search "local" prop) "(%s | %s)")
((and (string-search "local" prop) (eq system-type 'windows-nt))
"(%s | \"%s\")")
((string-search "local" prop) "(%s | %s)")
(t "(%s | %s >%%s)"))
coding compress))
(compress
@ -6057,14 +6049,13 @@ function cell is returned to be applied on a buffer."
;; Windows shells need the program file name after
;; the pipe symbol be quoted if they use forward
;; slashes as directory separators.
(if (and (tramp-compat-string-search "local" prop)
(eq system-type 'windows-nt))
(if (and (string-search "local" prop) (eq system-type 'windows-nt))
"(%s <%%s | \"%s\")"
"(%s <%%s | %s)")
compress coding))
((tramp-compat-string-search "decoding" prop)
((string-search "decoding" prop)
(cond
((tramp-compat-string-search "local" prop) (format "%s" coding))
((string-search "local" prop) (format "%s" coding))
(t (format "%s >%%s" coding))))
(t
(format "%s <%%s" coding)))))))

View file

@ -485,7 +485,7 @@ arguments to pass to the OPERATION."
(let* ((share (tramp-smb-get-share v))
(localname (file-name-as-directory
(tramp-compat-string-replace
(string-replace
"\\" "/" (tramp-smb-get-localname v))))
(tmpdir (tramp-compat-make-temp-name))
(args (list (concat "//" host "/" share) "-E"))
@ -572,7 +572,7 @@ arguments to pass to the OPERATION."
;; Handle KEEP-DATE argument.
(when keep-date
(tramp-compat-set-file-times
(set-file-times
newname
(file-attribute-modification-time (file-attributes dirname))
(unless ok-if-already-exists 'nofollow)))
@ -656,7 +656,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; KEEP-DATE handling.
(when keep-date
(tramp-compat-set-file-times
(set-file-times
newname
(file-attribute-modification-time (file-attributes filename))
(unless ok-if-already-exists 'nofollow)))))
@ -716,7 +716,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
(setq name (file-name-concat dir name)))
;; If NAME is not a Tramp file, run the real handler.
(if (not (tramp-tramp-file-p name))
(tramp-run-real-handler #'expand-file-name (list name))
@ -780,7 +780,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(with-tramp-file-property v localname "file-acl"
(when (tramp-smb-remote-acl-p v)
(let* ((share (tramp-smb-get-share v))
(localname (tramp-compat-string-replace
(localname (string-replace
"\\" "/" (tramp-smb-get-localname v)))
(args (list (concat "//" host "/" share) "-E"))
(options tramp-smb-options))
@ -845,8 +845,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Check result.
(when entry
(list (and (tramp-compat-string-search "d" (nth 1 entry))
t) ;0 file type
(list (and (string-search "d" (nth 1 entry)) t) ;0 file type
-1 ;1 link count
(cons
tramp-unknown-id-string tramp-unknown-id-integer) ;2 uid
@ -981,7 +980,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(mapcar
(lambda (x)
(list
(if (tramp-compat-string-search "d" (nth 1 x))
(if (string-search "d" (nth 1 x))
(file-name-as-directory (nth 0 x))
(nth 0 x))))
(tramp-smb-get-file-entries directory))))))))
@ -1020,7 +1019,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(defun tramp-smb-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
(if (file-exists-p filename)
(tramp-compat-string-search
(string-search
"w" (or (file-attribute-modes (file-attributes filename)) ""))
(let ((dir (file-name-directory filename)))
(and (file-exists-p dir)
@ -1083,14 +1082,14 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(sort
entries
(lambda (x y)
(if (tramp-compat-string-search "t" switches)
(if (string-search "t" switches)
;; Sort by date.
(time-less-p (nth 3 y) (nth 3 x))
;; Sort by name.
(string-lessp (nth 0 x) (nth 0 y))))))
;; Handle "-F" switch.
(when (tramp-compat-string-search "F" switches)
(when (string-search "F" switches)
(mapc
(lambda (x)
(unless (string-empty-p (car x))
@ -1121,7 +1120,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(expand-file-name
(nth 0 x) (file-name-directory filename))
'string)))))
(when (tramp-compat-string-search "l" switches)
(when (string-search "l" switches)
(insert
(format
"%10s %3d %-8s %-8s %8s %s "
@ -1150,7 +1149,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(put-text-property start (point) 'dired-filename t))
;; Insert symlink.
(when (and (tramp-compat-string-search "l" switches)
(when (and (string-search "l" switches)
(stringp (file-attribute-type attr)))
(insert " -> " (file-attribute-type attr))))
@ -1369,11 +1368,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(when (and (stringp acl-string) (tramp-smb-remote-acl-p v))
(let* ((share (tramp-smb-get-share v))
(localname (tramp-compat-string-replace
"\\" "/" (tramp-smb-get-localname v)))
(localname (string-replace "\\" "/" (tramp-smb-get-localname v)))
(args (list (concat "//" host "/" share) "-E" "-S"
(tramp-compat-string-replace
"\n" "," acl-string)))
(string-replace "\n" "," acl-string)))
(options tramp-smb-options))
(if (tramp-string-empty-or-nil-p user)
@ -1492,7 +1489,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Save exit.
;; FIXME: Does `tramp-get-connection-buffer' return the proper value?
(with-current-buffer (tramp-get-connection-buffer v)
(if (tramp-compat-string-search tramp-temp-buffer-name (buffer-name))
(if (string-search tramp-temp-buffer-name (buffer-name))
(progn
(set-process-buffer (tramp-get-connection-process v) nil)
(kill-buffer (current-buffer)))
@ -1765,12 +1762,10 @@ are listed. Result is the list (LOCALNAME MODE SIZE MTIME)."
mode (or (match-string 1 line) "")
mode (format
"%s%s"
(if (tramp-compat-string-search "D" mode) "d" "-")
(if (string-search "D" mode) "d" "-")
(mapconcat
(lambda (_x) "") " "
(format
"r%sx"
(if (tramp-compat-string-search "R" mode) "-" "w"))))
(format "r%sx" (if (string-search "R" mode) "-" "w"))))
line (substring line 0 -6))
(cl-return))

View file

@ -301,15 +301,13 @@ arguments to pass to the OPERATION."
"Like `set-file-modes' for Tramp files."
(unless (and (eq flag 'nofollow) (file-symlink-p filename))
(tramp-skeleton-set-file-modes-times-uid-gid filename
(tramp-compat-set-file-modes
(tramp-fuse-local-file-name filename) mode flag))))
(set-file-modes (tramp-fuse-local-file-name filename) mode flag))))
(defun tramp-sshfs-handle-set-file-times (filename &optional timestamp flag)
"Like `set-file-times' for Tramp files."
(unless (and (eq flag 'nofollow) (file-symlink-p filename))
(tramp-skeleton-set-file-modes-times-uid-gid filename
(tramp-compat-set-file-times
(tramp-fuse-local-file-name filename) timestamp flag))))
(set-file-times (tramp-fuse-local-file-name filename) timestamp flag))))
(defun tramp-sshfs-handle-write-region
(start end filename &optional append visit lockname mustbenew)

View file

@ -305,7 +305,7 @@ absolute file names."
;; Set the time and mode. Mask possible errors.
(when keep-date
(ignore-errors
(tramp-compat-set-file-times
(set-file-times
newname file-times (unless ok-if-already-exists 'nofollow))
(set-file-modes newname file-modes)))
@ -371,7 +371,7 @@ the result will be a local, non-Tramp, file name."
(setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
(setq name (file-name-concat dir name)))
;; If NAME is not a Tramp file, run the real handler.
(if (not (tramp-tramp-file-p name))
(tramp-run-real-handler #'expand-file-name (list name))

View file

@ -1716,7 +1716,7 @@ This is HOST, if non-nil. Otherwise, do a lookup in
`tramp-default-host-alist' and `tramp-default-host'."
(declare (tramp-suppress-trace t))
(let ((result
(or (and (tramp-compat-length> host 0) host)
(or (and (length> host 0) host)
(let ((choices tramp-default-host-alist)
lhost item)
(while choices
@ -1728,7 +1728,7 @@ This is HOST, if non-nil. Otherwise, do a lookup in
lhost)
tramp-default-host)))
;; We must mark, whether a default value has been used.
(if (or (tramp-compat-length> host 0) (null result))
(if (or (length> host 0) (null result))
result
(propertize result 'tramp-default t))))
@ -1772,8 +1772,7 @@ default values are used."
(setq v (tramp-dissect-hop-name hop)
hop (and hop (tramp-make-tramp-hop-name v))))
(let ((tramp-default-host
(or (and v (not (tramp-compat-string-search
"%h" (tramp-file-name-host v)))
(or (and v (not (string-search "%h" (tramp-file-name-host v)))
(tramp-file-name-host v))
tramp-default-host)))
(setq method (tramp-find-method method user host)
@ -2100,7 +2099,7 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
"Report progress of an operation for Tramp."
(let* ((parameters (cdr reporter))
(message (aref parameters 3)))
(when (tramp-compat-string-search message (or (current-message) ""))
(when (string-search message (or (current-message) ""))
(progress-reporter-update reporter value suffix))))
;;;###tramp-autoload
@ -2269,7 +2268,7 @@ If optional FLAG is `nofollow', do not follow FILENAME if it is a
symbolic link. If the file modes of FILENAME cannot be
determined, return the value of `default-file-modes', without
execute permissions."
(or (tramp-compat-file-modes filename flag)
(or (file-modes filename flag)
(logand (default-file-modes) #o0666)))
(defun tramp-replace-environment-variables (filename)
@ -3106,7 +3105,7 @@ PARTIAL-USER must match USER, PARTIAL-HOST must match HOST."
(defun tramp-completion-handle-file-name-nondirectory (filename)
"Like `file-name-nondirectory' for partial Tramp files."
(tramp-compat-string-replace (file-name-directory filename) "" filename))
(string-replace (file-name-directory filename) "" filename))
(defun tramp-parse-default-user-host (method)
"Return a list of (user host) tuples allowed to access for METHOD.
@ -3354,7 +3353,7 @@ BODY is the backend specific code."
(if (and delete-by-moving-to-trash ,trash)
;; Move non-empty dir to trash only if recursive deletion was
;; requested.
(if (not (or ,recursive (tramp-compat-directory-empty-p ,directory)))
(if (not (or ,recursive (directory-empty-p ,directory)))
(tramp-error
v 'file-error "Directory is not empty, not moving to trash")
(move-file-to-trash ,directory))
@ -4011,7 +4010,7 @@ Let-bind it when necessary.")
;; Otherwise, remove any trailing slash from localname component.
;; Method, host, etc, are unchanged.
(while (with-parsed-tramp-file-name directory nil
(and (tramp-compat-length> localname 0)
(and (length> localname 0)
(eq (aref localname (1- (length localname))) ?/)
(not (string= localname "/"))))
(setq directory (substring directory 0 -1)))
@ -4029,7 +4028,7 @@ Let-bind it when necessary.")
(lambda (x)
(cons x (file-attributes
(if full x (expand-file-name x directory)) id-format)))
(tramp-compat-directory-files directory full match nosort count)))
(directory-files directory full match nosort count)))
(defun tramp-handle-dired-uncache (dir)
"Like `dired-uncache' for Tramp files."
@ -4046,7 +4045,7 @@ Let-bind it when necessary.")
(setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
(setq name (file-name-concat dir name)))
;; If NAME is not a Tramp file, run the real handler.
(if (not (tramp-tramp-file-p name))
(tramp-run-real-handler #'expand-file-name (list name))
@ -4212,8 +4211,7 @@ Let-bind it when necessary.")
;; "." and ".." are never interesting as completions, and are
;; actually in the way in a directory with only one file. See
;; file_name_completion() in dired.c.
(when (and (consp fnac)
(tramp-compat-length= (delete "./" (delete "../" fnac)) 1))
(when (and (consp fnac) (length= (delete "./" (delete "../" fnac)) 1))
(setq fnac (delete "./" (delete "../" fnac))))
(or
(try-completion
@ -4446,7 +4444,7 @@ existing) are returned."
(list filename switches wildcard full-directory-p))
;; `ls-lisp' always returns full listings. We must remove
;; superfluous parts.
(unless (tramp-compat-string-search "l" switches)
(unless (string-search "l" switches)
(save-excursion
(goto-char (point-min))
(while (setq start
@ -4723,7 +4721,7 @@ It is not guaranteed, that all process attributes as described in
(defun tramp-get-lock-file (file)
"Read lockfile info of FILE.
Return nil when there is no lockfile."
(when-let ((lockname (tramp-compat-make-lock-file-name file)))
(when-let ((lockname (make-lock-file-name file)))
(or (file-symlink-p lockname)
(and (file-readable-p lockname)
(with-temp-buffer
@ -4785,7 +4783,7 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
(match-string 2 info) (match-string 3 info)))
(throw 'dont-lock nil)))
(when-let ((lockname (tramp-compat-make-lock-file-name file))
(when-let ((lockname (make-lock-file-name file))
;; USER@HOST.PID[:BOOT_TIME]
(info
(format
@ -4833,7 +4831,7 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
;; connection. See Bug#61663.
(if-let ((v (tramp-dissect-file-name file))
((process-live-p (tramp-get-process v)))
(lockname (tramp-compat-make-lock-file-name file)))
(lockname (make-lock-file-name file)))
(delete-file lockname)
;; Trigger the unlock error. Be quiet if user isn't
;; interested in lock files. See Bug#70900.
@ -5076,13 +5074,13 @@ should be set connection-local.")
(adb-file-name-handler-p (tramp-adb-file-name-p v))
(env (mapcar
(lambda (elt)
(when (tramp-compat-string-search "=" elt) elt))
(when (string-search "=" elt) elt))
tramp-remote-process-environment))
;; We use as environment the difference to toplevel
;; `process-environment'.
(env (dolist (elt process-environment env)
(when (and
(tramp-compat-string-search "=" elt)
(string-search "=" elt)
(not
(member
elt (default-toplevel-value 'process-environment))))
@ -5149,8 +5147,7 @@ should be set connection-local.")
;; Command could be too long, for example due to a longish PATH.
(when (and sh-file-name-handler-p
(tramp-compat-length>
(string-join command) (tramp-get-remote-pipe-buf v)))
(length> (string-join command) (tramp-get-remote-pipe-buf v)))
(signal 'error (cons "Command too long:" command)))
(setq
@ -7021,7 +7018,7 @@ If VEC is `tramp-null-hop', return local null device."
null-device
(with-tramp-connection-property vec "null-device"
(let ((default-directory (tramp-make-tramp-file-name vec)))
(tramp-compat-null-device)))))
(null-device)))))
;; Checklist for `tramp-unload-hook'
;; - Unload all `tramp-*' packages

View file

@ -7,8 +7,8 @@
;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes
;; Package: tramp
;; Version: 2.7.2-pre
;; Package-Requires: ((emacs "27.1"))
;; Version: 2.8.0-pre
;; Package-Requires: ((emacs "28.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.7.2-pre"
(defconst tramp-version "2.8.0-pre"
"This version of Tramp.")
;;;###tramp-autoload
@ -76,9 +76,9 @@
"The repository revision of the Tramp sources.")
;; Check for Emacs version.
(let ((x (if (not (string-version-lessp emacs-version "27.1"))
(let ((x (if (not (string-version-lessp emacs-version "28.1"))
"ok"
(format "Tramp 2.7.2-pre is not fit for %s"
(format "Tramp 2.8.0-pre is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x)))