* lisp/net/tramp-adb.el (tramp-adb-handle-process-file):
Use `process-file-return-signal-string'.
* lisp/net/tramp-cache.el (tramp-dump-connection-properties):
Use "lisp-data" for persistency file.
* lisp/net/tramp-cmds.el (tramp-cleanup-this-connection)
(tramp-rename-these-files, tramp-recompile-elpa):
Declare `completion'.
* lisp/net/tramp-container.el (tramp-kubernetes--container)
(tramp-kubernetes--pod, tramp-kubernetes--namespace): Make more
robust.
* lisp/net/tramp-crypt.el (tramp-crypt-remove-directory):
Declare `completion'.
* lisp/net/tramp-gvfs.el (file-notyify-callback): Declare.
* lisp/net/tramp-sh.el (process-file-return-signal-string)
(vc-handled-backends): Don't declare.
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
Use `copy-directory-create-symlink'.
* lisp/net/tramp.el (tramp-skeleton-write-region): Use `lock-file' and
`unlock-file'..
(tramp-handle-make-lock-file-name): Use `remote-file-name-inhibit-locks'.
(tramp-handle-unlock-file): Use `remote-file-name-inhibit-locks'
and `userlock--handle-unlock-error'.
(tramp-handle-shell-command): Use `shell-command-buffer-name-async'
and `shell-command-buffer-name'.
(tramp-read-passwd): Remove workaround.
(cherry picked from commit
1b806a200edcb893471237f47e969dbb9d6a99f1)
(kill-buffer (tramp-get-connection-buffer v))
(setq ret 1)))
- ;; Handle signals. `process-file-return-signal-string' exists
- ;; since Emacs 28.1.
- (when (and (bound-and-true-p process-file-return-signal-string)
+ (when (and process-file-return-signal-string
(natnump ret) (> ret 128))
(setq ret (nth (- ret 128) (tramp-adb-get-signal-strings v))))))
;; Dump it.
(with-temp-file tramp-persistency-file-name
(insert
- ;; Starting with Emacs 28, we could use `lisp-data'.
- (format ";; -*- emacs-lisp -*- <%s %s>\n"
+ (format ";; -*- lisp-data -*- <%s %s>\n"
(time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S")
tramp-persistency-file-name)
";; Tramp connection history. Don't change this file.\n"
;;;###tramp-autoload
(defun tramp-cleanup-this-connection ()
"Flush all connection related objects of the current buffer's connection."
- ;; (declare (completion tramp-command-completion-p)))
+ (declare (completion tramp-command-completion-p))
(interactive)
(and (tramp-tramp-file-p default-directory)
(tramp-cleanup-connection
(tramp-dissect-file-name default-directory 'noexpand))))
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-cleanup-this-connection 'completion-predicate
- #'tramp-command-completion-p)
-
;;;###tramp-autoload
(defvar tramp-cleanup-all-connections-hook nil
"List of functions to be called after all Tramp connections are cleaned up.")
without confirmation if the prefix argument is non-nil.
For details, see `tramp-rename-files'."
- ;; (declare (completion tramp-command-completion-p))
+ (declare (completion tramp-command-completion-p))
(interactive
(let ((source default-directory)
target
(tramp-rename-files default-directory target))
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-rename-these-files 'completion-predicate #'tramp-command-completion-p)
-
;;; Run as sudo
(defcustom tramp-file-name-with-method "sudo"
;;; Recompile on ELPA
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
;;;###tramp-autoload
(defun tramp-recompile-elpa-command-completion-p (_symbol _buffer)
"A predicate for `tramp-recompile-elpa'.
(defun tramp-recompile-elpa ()
"Recompile the installed Tramp ELPA package.
This is needed if there are compatibility problems."
- ;; (declare (completion tramp-recompile-elpa-command-completion-p))
+ (declare (completion tramp-recompile-elpa-command-completion-p))
(interactive)
;; We expect just one Tramp package is installed.
(when-let
"--eval" (format "(byte-recompile-directory %S 0 t)" dir))
(message "Package `tramp' recompiled.")))))
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-recompile-elpa 'completion-predicate
- #'tramp-recompile-elpa-command-completion-p)
-
;; Tramp version is useful in a number of situations.
;;;###tramp-autoload
;;;###tramp-autoload
(defun tramp-kubernetes--container (vec)
"Extract the container name from a kubernetes host name in VEC."
- (or (let ((host (tramp-file-name-host vec)))
- (and (string-match tramp-kubernetes--host-name-regexp host)
- (match-string 1 host)))
+ (or (when-let ((host (and vec (tramp-file-name-host vec)))
+ ((string-match tramp-kubernetes--host-name-regexp host)))
+ (match-string 1 host))
""))
;;;###tramp-autoload
(defun tramp-kubernetes--pod (vec)
"Extract the pod name from a kubernetes host name in VEC."
- (or (let ((host (tramp-file-name-host vec)))
- (and (string-match tramp-kubernetes--host-name-regexp host)
- (match-string 2 host)))
+ (or (when-let ((host (and vec (tramp-file-name-host vec)))
+ ((string-match tramp-kubernetes--host-name-regexp host)))
+ (match-string 2 host))
""))
;;;###tramp-autoload
(defun tramp-kubernetes--namespace (vec)
"Extract the namespace from a kubernetes host name in VEC.
Use `tramp-kubernetes-namespace' otherwise."
- (or (when-let ((_ vec)
- (host (tramp-file-name-host vec)))
- (and (string-match tramp-kubernetes--host-name-regexp host)
- (match-string 3 host)))
+ (or (when-let ((host (and vec (tramp-file-name-host vec)))
+ ((string-match tramp-kubernetes--host-name-regexp host)))
+ (match-string 3 host))
tramp-kubernetes-namespace))
;; We must change `vec' and `default-directory' to the previous hop,
"Non-nil when encryption support is available.")
(setq tramp-crypt-enabled (executable-find tramp-crypt-encfs-program))
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
(defun tramp-crypt-command-completion-p (symbol _buffer)
"A predicate for Tramp interactive commands.
They are completed by `M-x TAB' only when encryption support is enabled."
"Unmark expanded remote directory NAME for encryption.
Existing files in that directory and its subdirectories will be
kept in their encrypted form."
- ;; (declare (completion tramp-crypt-command-completion-p))
+ (declare (completion tramp-crypt-command-completion-p))
(interactive "DRemote directory name: ")
(unless tramp-crypt-enabled
(tramp-user-error nil "Feature is not enabled"))
(setq tramp-crypt-directories (delete name tramp-crypt-directories))
(tramp-register-file-name-handlers)))
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-(function-put
- #'tramp-crypt-remove-directory 'completion-predicate
- #'tramp-crypt-command-completion-p)
-
;; `auth-source' requires a user.
(defun tramp-crypt-dissect-file-name (name)
"Return a `tramp-file-name' structure for NAME.
(require 'url-util)
;; Pacify byte-compiler.
+(declare-function file-notify-callback "filenotify")
(declare-function zeroconf-init "zeroconf")
(declare-function zeroconf-list-service-types "zeroconf")
(declare-function zeroconf-list-services "zeroconf")
;; `unread-command-events' does not accept several events at
;; once. Therefore, we apply the callback directly.
(when (member action events)
- (tramp-compat-funcall
- 'file-notify-callback (list proc action file file1)))))
+ (file-notify-callback (list proc action file file1)))))
;; Save rest of the string.
(when (string-empty-p string) (setq string nil))
(declare (tramp-suppress-trace t))
(1+ (string-to-number (match-string 3))))
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
(defun tramp-debug-buffer-command-completion-p (_symbol buffer)
"A predicate for Tramp interactive commands.
They are completed by `M-x TAB' only in Tramp debug buffers."
(declare-function dired-compress-file "dired-aux")
(declare-function dired-remove-file "dired-aux")
(defvar dired-compress-file-suffixes)
-;; Added in Emacs 28.1.
-(defvar process-file-return-signal-string)
-(defvar vc-handled-backends)
(defvar vc-bzr-program)
(defvar vc-git-program)
(defvar vc-hg-program)
(unless (file-exists-p dirname)
(tramp-error v 'file-missing dirname))
- ;; `copy-directory-create-symlink' exists since Emacs 28.1.
- (if (and (bound-and-true-p copy-directory-create-symlink)
+ (if (and copy-directory-create-symlink
(setq target (file-symlink-p dirname))
(tramp-equal-remote dirname newname))
(make-symbolic-link
(kill-buffer (tramp-get-connection-buffer v))
(setq ret 1)))
- ;; Handle signals. `process-file-return-signal-string' exists
- ;; since Emacs 28.1.
- (when (and (bound-and-true-p process-file-return-signal-string)
+ ;; Handle signals.
+ (when (and process-file-return-signal-string
(natnump ret) (>= ret 128))
(setq ret (nth (- ret 128) (tramp-sh-get-signal-strings v)))))))
(unless (file-exists-p dirname)
(tramp-error v 'file-missing dirname))
- ;; `copy-directory-create-symlink' exists since Emacs 28.1.
- (if (and (bound-and-true-p copy-directory-create-symlink)
+ (if (and copy-directory-create-symlink
(setq target (file-symlink-p dirname))
(tramp-equal-remote dirname newname))
(make-symbolic-link
((member operation
'(access-file byte-compiler-base-file-name delete-directory
delete-file diff-latest-backup-file directory-file-name
- directory-files directory-files-and-attributes
- dired-compress-file dired-uncache file-acl
- file-accessible-directory-p file-attributes
- file-directory-p file-executable-p file-exists-p
- file-local-copy file-modes file-name-as-directory
+ directory-files directory-files-and-attributes dired-compress-file
+ dired-uncache file-acl file-accessible-directory-p file-attributes
+ file-directory-p file-executable-p file-exists-p file-local-copy
+ file-locked-p file-modes file-name-as-directory
file-name-case-insensitive-p file-name-directory
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-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
+ file-notify-add-watch file-ownership-preserved-p file-readable-p
+ file-regular-p file-remote-p 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 lock-file make-directory
+ make-lock-file-name set-file-acl set-file-modes
+ set-file-selinux-context set-file-times substitute-in-file-name
+ unhandled-file-name-directory unlock-file vc-registered
;; Emacs 28- only.
make-directory-internal
- ;; Emacs 28+ only.
- file-locked-p lock-file make-lock-file-name unlock-file
;; Emacs 29+ only.
abbreviate-file-name
;; Tramp internal magic file name function.
;;; File name handler functions for completion mode:
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
(defun tramp-command-completion-p (_symbol buffer)
"A predicate for Tramp interactive commands.
They are completed by `M-x TAB' only if the current buffer is remote."
(tramp-tramp-file-p lockname)
(not file-locked))
(setq file-locked t)
- ;; `lock-file' exists since Emacs 28.1.
- (tramp-compat-funcall 'lock-file lockname))
+ (lock-file lockname))
;; The body.
,@body
;; Unlock file.
(when file-locked
- ;; `unlock-file' exists since Emacs 28.1.
- (tramp-compat-funcall 'unlock-file lockname))
+ (unlock-file lockname))
;; Sanity check.
(unless (equal curbuf (current-buffer))
(defun tramp-handle-make-lock-file-name (file)
"Like `make-lock-file-name' for Tramp files."
(and create-lockfiles
- ;; This variable has been introduced with Emacs 28.1.
- (not (bound-and-true-p remote-file-name-inhibit-locks))
+ (not remote-file-name-inhibit-locks)
(tramp-run-real-handler 'make-lock-file-name (list file))))
(defun tramp-handle-unlock-file (file)
(unless (or (not create-lockfiles)
(bound-and-true-p remote-file-name-inhibit-locks))
(signal 'file-error `("Cannot remove lock file for" ,file))))
- ;; `userlock--handle-unlock-error' exists since Emacs 28.1. It
- ;; checks for `create-lockfiles' since Emacs 30.1, we don't need
- ;; this check here, then.
- (error (unless (or (not create-lockfiles)
- (bound-and-true-p remote-file-name-inhibit-locks))
- (tramp-compat-funcall 'userlock--handle-unlock-error err)))))
+ ;; `userlock--handle-unlock-error' checks for `create-lockfiles'
+ ;; since Emacs 30.1, we don't need this check here, then.
+ (error (unless (or (not create-lockfiles) remote-file-name-inhibit-locks)
+ (userlock--handle-unlock-error err)))))
(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
"Like `load' for Tramp files."
(setq current-buffer-p t)
(current-buffer))
(t (get-buffer-create
- ;; These variables have been introduced with Emacs 28.1.
(if asynchronous
- (or (bound-and-true-p shell-command-buffer-name-async)
- "*Async Shell Command*")
- (or (bound-and-true-p shell-command-buffer-name)
- "*Shell Command Output*"))))))
+ (or shell-command-buffer-name-async "*Async Shell Command*")
+ (or shell-command-buffer-name "*Shell Command Output*"))))))
(error-buffer
(cond
((bufferp error-buffer) error-buffer)
(lambda () (password-cache-add key auth-passwd)))
auth-passwd))
- ;; Workaround. Prior Emacs 28.1, auth-source has saved empty
- ;; passwords. See discussion in Bug#50399.
- (when (tramp-string-empty-or-nil-p auth-passwd)
- (setq tramp-password-save-function nil))
(tramp-set-connection-property vec "first-password-request" nil))))
(defun tramp-read-passwd-without-cache (proc &optional prompt)