Commit b3032988 authored by Michael Albinus's avatar Michael Albinus

Remove Emacs 23 compat code from Tramp

* doc/misc/tramp.texi (Remote processes): Don't mention
Emacs 24 explicitely.
(Frequently Asked Questions): Remove Emacs 23 from
compatibility list.

* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el: Replace compat function calls.

* lisp/net/tramp-compat.el (remote-file-name-inhibit-cache)
(tramp-compat-condition-case-unless-debug)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-process-live-p): Remove them.

* lisp/net/trampver.el: Make version check fit for Emacs 24.
parent 4de0737c
......@@ -2553,9 +2553,8 @@ when using @value{tramp} between two hosts with different operating
systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
ensures the correct name of the remote shell program.
Starting with Emacs 24, when @option{explicit-shell-file-name} is
equal to @code{nil}, calling @code{shell} interactively will prompt
for a shell name.
When @option{explicit-shell-file-name} is equal to @code{nil}, calling
@code{shell} interactively will prompt for a shell name.
Starting with Emacs 26, you could use connection-local variables for
setting different values of @option{explicit-shell-file-name} for
......@@ -2856,8 +2855,7 @@ Where is the latest @value{tramp}?
@item
Which systems does it work on?
The package works successfully on Emacs 23, Emacs 24, Emacs 25, and
Emacs 26.
The package works successfully on Emacs 24, Emacs 25, and Emacs 26.
While Unix and Unix-like systems are the primary remote targets,
@value{tramp} has equal success connecting to other platforms, such as
......
......@@ -206,7 +206,7 @@ pass to the OPERATION."
(tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
(process-put p 'adjust-window-size-function 'ignore)
(set-process-query-on-exit-flag p nil)
(while (tramp-compat-process-live-p p)
(while (process-live-p p)
(accept-process-output p 0.1))
(accept-process-output p 0.1)
(tramp-message v 6 "\n%s" (buffer-string))
......@@ -1210,7 +1210,7 @@ connection if a previous connection has died for some reason."
(when (and user (not (tramp-get-file-property vec "" "su-command-p" t)))
(tramp-error vec 'file-error "Cannot switch to user `%s'" user))
(unless (tramp-compat-process-live-p p)
(unless (process-live-p p)
(save-match-data
(when (and p (processp p)) (delete-process p))
(if (zerop (length device))
......@@ -1229,7 +1229,7 @@ connection if a previous connection has died for some reason."
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Wait for initial prompt.
(tramp-adb-wait-for-output p 30)
(unless (tramp-compat-process-live-p p)
(unless (process-live-p p)
(tramp-error vec 'file-error "Terminated!"))
(tramp-set-connection-property p "vector" vec)
(process-put p 'adjust-window-size-function 'ignore)
......
......@@ -250,7 +250,7 @@ value is not set for the connection, returns DEFAULT."
(value
;; If the key is an auxiliary process object, check whether
;; the process is still alive.
(if (and (processp key) (not (tramp-compat-process-live-p key)))
(if (and (processp key) (not (process-live-p key)))
default
(if (hash-table-p hash)
(gethash property hash default)
......
......@@ -24,8 +24,7 @@
;;; Commentary:
;; Tramp's main Emacs version for development is Emacs 26. This
;; package provides compatibility functions for Emacs 23, Emacs 24 and
;; Emacs 25.
;; package provides compatibility functions for Emacs 24 and Emacs 25.
;;; Code:
......@@ -43,12 +42,6 @@
(require 'trampver)
(require 'tramp-loaddefs)
;; `remote-file-name-inhibit-cache' has been introduced with Emacs
;; 24.1. Besides t, nil, and integer, we use also timestamps (as
;; returned by `current-time') internally.
(unless (boundp 'remote-file-name-inhibit-cache)
(defvar remote-file-name-inhibit-cache nil))
;; For not existing functions, obsolete functions, or functions with a
;; changed argument list, there are compiler warnings. We want to
;; avoid them in cases we know what we do.
......@@ -84,22 +77,6 @@
'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards)
(ad-activate 'file-expand-wildcards))))
;; `condition-case-unless-debug' is introduced with Emacs 24.
(if (fboundp 'condition-case-unless-debug)
(defalias 'tramp-compat-condition-case-unless-debug
'condition-case-unless-debug)
(defmacro tramp-compat-condition-case-unless-debug
(var bodyform &rest handlers)
"Like `condition-case' except that it does not catch anything when debugging."
(declare (debug condition-case) (indent 2))
(let ((bodysym (make-symbol "body")))
`(let ((,bodysym (lambda () ,bodyform)))
(if debug-on-error
(funcall ,bodysym)
(condition-case ,var
(funcall ,bodysym)
,@handlers))))))
(defsubst tramp-compat-temporary-file-directory ()
"Return name of directory for temporary files.
It is the default value of `temporary-file-directory'."
......@@ -123,103 +100,6 @@ Add the extension of F, if existing."
'temporary-file-directory
'tramp-handle-temporary-file-directory))
;; PRESERVE-EXTENDED-ATTRIBUTES has been introduced with Emacs 24.1
;; (as PRESERVE-SELINUX-CONTEXT), and renamed in Emacs 24.3.
(defun tramp-compat-copy-file
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files (compat function)."
(cond
(preserve-extended-attributes
(condition-case nil
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)
(wrong-number-of-arguments
(copy-file
filename newname ok-if-already-exists keep-date preserve-uid-gid))))
(t
(copy-file
filename newname ok-if-already-exists keep-date preserve-uid-gid))))
;; COPY-CONTENTS has been introduced with Emacs 24.1.
(defun tramp-compat-copy-directory
(directory newname &optional keep-time parents copy-contents)
"Make a copy of DIRECTORY (compat function)."
(condition-case nil
(tramp-compat-funcall
'copy-directory directory newname keep-time parents copy-contents)
;; `copy-directory' is either not implemented, or it does not
;; support the the COPY-CONTENTS flag. For the time being, we
;; ignore COPY-CONTENTS as well.
(error
;; If `default-directory' is a remote directory, make sure we
;; find its `copy-directory' handler.
(let ((handler (or (find-file-name-handler directory 'copy-directory)
(find-file-name-handler newname 'copy-directory))))
(if handler
(funcall handler 'copy-directory directory newname keep-time parents)
;; Compute target name.
(setq directory (directory-file-name (expand-file-name directory))
newname (directory-file-name (expand-file-name newname)))
(if (and (file-directory-p newname)
(not (string-equal (file-name-nondirectory directory)
(file-name-nondirectory newname))))
(setq newname
(expand-file-name
(file-name-nondirectory directory) newname)))
(if (not (file-directory-p newname)) (make-directory newname parents))
;; Copy recursively.
(mapc
(lambda (file)
(if (file-directory-p file)
(tramp-compat-copy-directory file newname keep-time parents)
(copy-file file newname t keep-time)))
;; We do not want to delete "." and "..".
(directory-files directory 'full directory-files-no-dot-files-regexp))
;; Set directory attributes.
(set-file-modes newname (file-modes directory))
(if keep-time
(set-file-times newname (nth 5 (file-attributes directory)))))))))
;; TRASH has been introduced with Emacs 24.1.
(defun tramp-compat-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files (compat function)."
(condition-case nil
(tramp-compat-funcall 'delete-file filename trash)
;; This Emacs version does not support the TRASH flag.
(wrong-number-of-arguments
(let ((delete-by-moving-to-trash (and delete-by-moving-to-trash trash)))
(delete-file filename)))))
;; RECURSIVE has been introduced with Emacs 23.2. TRASH has been
;; introduced with Emacs 24.1.
(defun tramp-compat-delete-directory (directory &optional recursive trash)
"Like `delete-directory' for Tramp files (compat function)."
(condition-case nil
(cond
(trash
(tramp-compat-funcall 'delete-directory directory recursive trash))
(t
(delete-directory directory recursive)))
;; This Emacs version does not support the TRASH flag. We use the
;; implementation from Emacs 23.2.
(wrong-number-of-arguments
(setq directory (directory-file-name (expand-file-name directory)))
(when (not (file-symlink-p directory))
(mapc (lambda (file)
(if (eq t (car (file-attributes file)))
(tramp-compat-delete-directory file recursive trash)
(tramp-compat-delete-file file trash)))
(directory-files
directory 'full directory-files-no-dot-files-regexp)))
(delete-directory directory))))
(defun tramp-compat-process-running-p (process-name)
"Returns t if system process PROCESS-NAME is running for `user-login-name'."
(when (stringp process-name)
......@@ -244,19 +124,6 @@ Add the extension of F, if existing."
process-name))))
(setq result t)))))))))
;; `process-running-live-p' is introduced in Emacs 24.
(defalias 'tramp-compat-process-live-p
(if (fboundp 'process-running-live-p)
'process-running-live-p
(lambda (process)
"Returns non-nil if PROCESS is alive.
A process is considered alive if its status is `run', `open',
`listen', `connect' or `stop'. Value is nil if PROCESS is not a
process."
(and (processp process)
(memq (process-status process)
'(run open listen connect stop))))))
;; `user-error' has appeared in Emacs 24.3.
(defsubst tramp-compat-user-error (vec-or-proc format &rest args)
"Signal a pilot error."
......@@ -323,15 +190,15 @@ This is a floating point number if the size is too large for an integer."
This is a string of ten letters or dashes as in ls -l."
(nth 8 attributes)))
;; `default-toplevel-value' has been declared in Emacs 24.
;; `default-toplevel-value' has been declared in Emacs 24.4.
(unless (fboundp 'default-toplevel-value)
(defalias 'default-toplevel-value 'symbol-value))
;; `format-message' is new in Emacs 25.
;; `format-message' is new in Emacs 25.1.
(unless (fboundp 'format-message)
(defalias 'format-message 'format))
;; `file-missing' is introduced in Emacs 26.
;; `file-missing' is introduced in Emacs 26.1.
(defconst tramp-file-missing
(if (get 'file-missing 'error-conditions) 'file-missing 'file-error)
"The error symbol for the `file-missing' error.")
......
......@@ -39,7 +39,7 @@
;; All actions to mount a remote location, and to retrieve mount
;; information, are performed by D-Bus messages. File operations
;; themselves are performed via the mounted filesystem in ~/.gvfs.
;; Consequently, GNU Emacs 23.1 with enabled D-Bus bindings is a
;; Consequently, GNU Emacs with enabled D-Bus bindings is a
;; precondition.
;; The GVFS D-Bus interface is said to be unstable. There were even
......@@ -158,7 +158,6 @@
(defconst tramp-gvfs-service-daemon "org.gtk.vfs.Daemon"
"The well known name of the GVFS daemon.")
;; D-Bus integration is available since Emacs 23 on some system types.
;; We don't call `dbus-ping', because this would load dbus.el.
(defconst tramp-gvfs-enabled
(ignore-errors
......@@ -666,19 +665,10 @@ file names."
(and t2 (not (tramp-gvfs-file-name-p newname))))
;; We cannot copy or rename directly.
;; PRESERVE-EXTENDED-ATTRIBUTES has been introduced with
;; Emacs 24.1 (as PRESERVE-SELINUX-CONTEXT), and renamed
;; in Emacs 24.3.
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(cond
(preserve-extended-attributes
(funcall
file-operation
filename tmpfile t keep-date preserve-uid-gid
preserve-extended-attributes))
(t
(funcall
file-operation filename tmpfile t keep-date preserve-uid-gid)))
(funcall
file-operation filename tmpfile t keep-date preserve-uid-gid
preserve-extended-attributes)
(rename-file tmpfile newname ok-if-already-exists))
;; Direct action.
......@@ -729,25 +719,16 @@ file names."
"Like `copy-file' for Tramp files."
(setq filename (expand-file-name filename))
(setq newname (expand-file-name newname))
(cond
;; At least one file a Tramp file?
((or (tramp-tramp-file-p filename)
(tramp-tramp-file-p newname))
(tramp-gvfs-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes))
;; Compat section. PRESERVE-EXTENDED-ATTRIBUTES has been
;; introduced with Emacs 24.1 (as PRESERVE-SELINUX-CONTEXT), and
;; renamed in Emacs 24.3.
(preserve-extended-attributes
;; At least one file a Tramp file?
(if (or (tramp-tramp-file-p filename)
(tramp-tramp-file-p newname))
(tramp-gvfs-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)
(tramp-run-real-handler
'copy-file
(list filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)))
(t
(tramp-run-real-handler
'copy-file
(list filename newname ok-if-already-exists keep-date preserve-uid-gid)))))
preserve-uid-gid preserve-extended-attributes))))
(defun tramp-gvfs-handle-delete-directory (directory &optional recursive trash)
"Like `delete-directory' for Tramp files."
......@@ -756,8 +737,8 @@ file names."
(mapc (lambda (file)
(if (eq t (tramp-compat-file-attribute-type
(file-attributes file)))
(tramp-compat-delete-directory file recursive trash)
(tramp-compat-delete-file file trash)))
(delete-directory file recursive trash)
(delete-file file trash)))
(directory-files
directory 'full directory-files-no-dot-files-regexp))
(when (directory-files directory nil directory-files-no-dot-files-regexp)
......@@ -1089,7 +1070,7 @@ file names."
;; There might be an error if the monitor is not supported.
;; Give the filter a chance to read the output.
(tramp-accept-process-output p 1)
(unless (tramp-compat-process-live-p p)
(unless (process-live-p p)
(tramp-error
v 'file-notify-error "Monitoring not supported for `%s'" file-name))
p))))
......
......@@ -1303,13 +1303,7 @@ target of the symlink differ."
(when (> (buffer-size) 0)
(goto-char (point-min))
;; ... inode
(setq res-inode
(condition-case err
(read (current-buffer))
;; This error happens in Emacs 23. Starting with
;; Emacs 24, a large integer will be converted into
;; a float automatically during `read'.
(overflow-error (string-to-number (cadr err)))))
(setq res-inode (read (current-buffer)))
;; ... file mode flags
(setq res-filemodes (symbol-name (read (current-buffer))))
;; ... number links
......@@ -1950,27 +1944,17 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)
"Like `copy-file' for Tramp files."
(setq filename (expand-file-name filename))
(setq newname (expand-file-name newname))
(cond
;; At least one file a Tramp file?
((or (tramp-tramp-file-p filename)
(tramp-tramp-file-p newname))
(tramp-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes))
;; Compat section. PRESERVE-EXTENDED-ATTRIBUTES has been
;; introduced with Emacs 24.1 (as PRESERVE-SELINUX-CONTEXT), and
;; renamed in Emacs 24.3.
(preserve-extended-attributes
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
(if (or (tramp-tramp-file-p filename)
(tramp-tramp-file-p newname))
(tramp-do-copy-or-rename-file
'copy filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)
(tramp-run-real-handler
'copy-file
(list filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-extended-attributes)))
(t
(tramp-run-real-handler
'copy-file
(list filename newname ok-if-already-exists keep-date preserve-uid-gid)))))
preserve-uid-gid preserve-extended-attributes))))
(defun tramp-sh-handle-copy-directory
(dirname newname &optional keep-date parents copy-contents)
......@@ -2814,7 +2798,7 @@ the result will be a local, non-Tramp, file name."
(defun tramp-process-sentinel (proc event)
"Flush file caches."
(unless (tramp-compat-process-live-p proc)
(unless (process-live-p proc)
(let ((vec (tramp-get-connection-property proc "vector" nil)))
(when vec
(tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
......@@ -3628,7 +3612,7 @@ Fall back to normal file name handler if no Tramp handler exists."
;; There might be an error if the monitor is not supported.
;; Give the filter a chance to read the output.
(tramp-accept-process-output p 1)
(unless (tramp-compat-process-live-p p)
(unless (process-live-p p)
(tramp-error
v 'file-notify-error "Monitoring not supported for `%s'" file-name))
p))))
......@@ -4620,7 +4604,7 @@ connection if a previous connection has died for some reason."
;; If Tramp opens the same connection within a short time frame,
;; there is a problem. We shall signal this.
(unless (or (tramp-compat-process-live-p p)
(unless (or (process-live-p p)
(not (tramp-file-name-equal-p
vec (car tramp-current-connection)))
(> (tramp-time-diff
......@@ -4641,9 +4625,9 @@ connection if a previous connection has died for some reason."
(tramp-get-connection-property
p "last-cmd-time" '(0 0 0)))
60)
(tramp-compat-process-live-p p))
(process-live-p p))
(tramp-send-command vec "echo are you awake" t t)
(unless (and (tramp-compat-process-live-p p)
(unless (and (process-live-p p)
(tramp-wait-for-output p 10))
;; The error will be caught locally.
(tramp-error vec 'file-error "Awake did fail")))
......@@ -4653,7 +4637,7 @@ connection if a previous connection has died for some reason."
;; New connection must be opened.
(condition-case err
(unless (tramp-compat-process-live-p p)
(unless (process-live-p p)
;; During completion, don't reopen a new connection. We
;; check this for the process related to
......
......@@ -382,7 +382,7 @@ pass to the OPERATION."
(defun tramp-smb-action-with-tar (proc vec)
"Untar from connection buffer."
(if (not (tramp-compat-process-live-p proc))
(if (not (process-live-p proc))
(throw 'tramp-action 'process-died)
(with-current-buffer (tramp-get-connection-buffer vec)
......@@ -516,7 +516,7 @@ pass to the OPERATION."
(set-process-query-on-exit-flag p nil)
(tramp-process-actions p v nil tramp-smb-actions-with-tar)
(while (tramp-compat-process-live-p p)
(while (process-live-p p)
(sit-for 0.1))
(tramp-message v 6 "\n%s" (buffer-string))))
......@@ -561,7 +561,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
0 (format "Copying %s to %s" filename newname)
(if (file-directory-p filename)
(tramp-compat-copy-directory
(copy-directory
filename newname keep-date 'parents 'copy-contents)
(let ((tmpfile (file-local-copy filename)))
......@@ -708,7 +708,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(defun tramp-smb-action-get-acl (proc vec)
"Read ACL data from connection buffer."
(unless (tramp-compat-process-live-p proc)
(unless (process-live-p proc)
;; Accept pending output.
(while (tramp-accept-process-output proc 0.1))
(with-current-buffer (tramp-get-connection-buffer vec)
......@@ -1224,7 +1224,7 @@ target of the symlink differ."
(narrow-to-region (point-max) (point-max))
(let ((p (tramp-get-connection-process v)))
(tramp-smb-send-command v "exit $lasterrorcode")
(while (tramp-compat-process-live-p p)
(while (process-live-p p)
(sleep-for 0.1)
(setq ret (process-exit-status p))))
(delete-region (point-min) (point-max))
......@@ -1308,7 +1308,7 @@ target of the symlink differ."
(defun tramp-smb-action-set-acl (proc vec)
"Read ACL data from connection buffer."
(unless (tramp-compat-process-live-p proc)
(unless (process-live-p proc)
;; Accept pending output.
(while (tramp-accept-process-output proc 0.1))
(with-current-buffer (tramp-get-connection-buffer vec)
......@@ -1724,7 +1724,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
(defun tramp-smb-get-cifs-capabilities (vec)
"Check, whether the SMB server supports POSIX commands."
;; When we are not logged in yet, we return nil.
(if (tramp-compat-process-live-p (tramp-get-connection-process vec))
(if (process-live-p (tramp-get-connection-process vec))
(with-tramp-connection-property
(tramp-get-connection-process vec) "cifs-capabilities"
(save-match-data
......@@ -1742,7 +1742,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
"Check, whether the SMB server supports the STAT command."
;; When we are not logged in yet, we return nil.
(if (and (tramp-smb-get-share vec)
(tramp-compat-process-live-p (tramp-get-connection-process vec)))
(process-live-p (tramp-get-connection-process vec)))
(with-tramp-connection-property
(tramp-get-connection-process vec) "stat-capability"
(tramp-smb-send-command vec "stat \"/\""))))
......@@ -1807,13 +1807,13 @@ If ARGUMENT is non-nil, use it as argument for
(tramp-get-connection-property
p "last-cmd-time" '(0 0 0)))
60)
(tramp-compat-process-live-p p)
(process-live-p p)
(re-search-forward tramp-smb-errors nil t))
(delete-process p)
(setq p nil)))
;; Check whether it is still the same share.
(unless (and (tramp-compat-process-live-p p)
(unless (and (process-live-p p)
(or argument
(string-equal
share
......@@ -1949,7 +1949,7 @@ Returns nil if an error message has appeared."
;; Algorithm: get waiting output. See if last line contains
;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings.
;; If not, wait a bit and again get waiting output.
(while (and (not found) (not err) (tramp-compat-process-live-p p))
(while (and (not found) (not err) (process-live-p p))
;; Accept pending output.
(tramp-accept-process-output p 0.1)
......@@ -1963,7 +1963,7 @@ Returns nil if an error message has appeared."
(setq err (re-search-forward tramp-smb-errors nil t)))
;; When the process is still alive, read pending output.
(while (and (not found) (tramp-compat-process-live-p p))
(while (and (not found) (process-live-p p))
;; Accept pending output.
(tramp-accept-process-output p 0.1)
......@@ -1987,7 +1987,7 @@ Returns nil if an error message has appeared."
"Send SIGKILL to the winexe process."
(ignore-errors
(let ((p (get-buffer-process (current-buffer))))
(when (tramp-compat-process-live-p p)
(when (process-live-p p)
(signal-process (process-id p) 'SIGINT)))))
(defun tramp-smb-call-winexe (vec)
......
This diff is collapsed.
......@@ -53,7 +53,7 @@
(replace-regexp-in-string "\n" "" (buffer-string))))))))
;; Check for Emacs version.
(let ((x (if (>= emacs-major-version 23)
(let ((x (if (>= emacs-major-version 24)
"ok"
(format "Tramp 2.3.2-pre is not fit for %s"
(when (string-match "^.*$" (emacs-version))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment