1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-08 15:35:02 +00:00

Improve XEmacs compatibility.

* net/tramp.el (tramp-autoload-file-name-handler):
Wrap `temporary-file-directory' by `symbol-value', it doesn't exist in XEmacs.
(tramp-read-passwd): Don't use `with-timeout-suspend' and
`with-timeout-unsuspend' if they don't exist, like in XEmacs.
(tramp-time-less-p, tramp-time-subtract): Remove functions.
(tramp-handle-file-newer-than-file-p, tramp-time-diff):
* net/ttramp-adb.el (tramp-adb-ls-output-time-less-p):
* net/ttramp-cache.el (tramp-get-file-property):
* net/ttramp-smb.el (tramp-smb-handle-insert-directory):
Use `time-less-p' and `time-subtract, respectively.
This commit is contained in:
Michael Albinus 2014-11-20 20:10:15 +01:00
parent cd2e816cd3
commit 6ec5ee8872
7 changed files with 43 additions and 37 deletions

View File

@ -1,3 +1,26 @@
2014-11-20 Michael Albinus <michael.albinus@gmx.de>
Improve XEmacs compatibility.
* net/tramp.el (tramp-autoload-file-name-handler):
Wrap `temporary-file-directory' by `symbol-value', it doesn't
exist in XEmacs.
(tramp-read-passwd): Don't use `with-timeout-suspend' and
`with-timeout-unsuspend' if they don't exist, like in XEmacs.
(tramp-time-less-p, tramp-time-subtract): Remove functions.
(tramp-handle-file-newer-than-file-p, tramp-time-diff):
* net/ttramp-adb.el (tramp-adb-ls-output-time-less-p):
* net/ttramp-cache.el (tramp-get-file-property):
* net/ttramp-smb.el (tramp-smb-handle-insert-directory):
Use `time-less-p' and `time-subtract, respectively.
* net/ttramp-adb.el (top): Do not require time-date.el.
* net/ttramp-compat.el (top): Require time-date.el for XEmacs.
* net/ttramp-sh.el (tramp-open-connection-setup-interactive-shell):
Check, whether `utf-8' is a valid coding system.
2014-11-19 Eli Zaretskii <eliz@gnu.org>
* vc/vc.el (vc-retrieve-tag): Doc fix.

View File

@ -34,7 +34,6 @@
;;; Code:
(require 'tramp)
(require 'time-date)
;; Pacify byte-compiler.
(defvar directory-sep-char)
@ -468,7 +467,7 @@ Emacs dired can't find files."
(setq time-a (apply '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))))
(tramp-time-less-p time-b time-a)))
(time-less-p time-b time-a)))
(defun tramp-adb-ls-output-name-less-p (a b)
"Sort \"ls\" output by name, ascending."

View File

@ -136,7 +136,7 @@ Returns DEFAULT if not set."
(tramp-time-diff (current-time) (car value))
remote-file-name-inhibit-cache))
(and (consp remote-file-name-inhibit-cache)
(tramp-time-less-p
(time-less-p
remote-file-name-inhibit-cache (car value)))))
(setq value (cdr value))
(setq value default))

View File

@ -44,7 +44,8 @@
(require 'outline)
(require 'passwd)
(require 'pp)
(require 'regexp-opt))
(require 'regexp-opt)
(require 'time-date))
(require 'advice)
(require 'custom)

View File

@ -3971,9 +3971,10 @@ process to set up. VEC specifies the connection."
(if (featurep 'mule)
;; Use MULE to select the right EOL convention for communicating
;; with the process.
(let ((cs (or (when (string-match
"utf8" (or (tramp-get-remote-locale vec) ""))
(cons 'utf-8 'utf-8))
(let ((cs (or (and (memq 'utf-8 (coding-system-list))
(string-match
"utf8" (or (tramp-get-remote-locale vec) ""))
(cons 'utf-8 'utf-8))
(tramp-compat-funcall 'process-coding-system proc)
(cons 'undecided 'undecided)))
cs-decode cs-encode)

View File

@ -976,7 +976,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(lambda (x y)
(if (string-match "t" switches)
;; Sort by date.
(tramp-time-less-p (nth 3 y) (nth 3 x))
(time-less-p (nth 3 y) (nth 3 x))
;; Sort by name.
(string-lessp (nth 0 x) (nth 0 y))))))
@ -1010,8 +1010,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(or (nth 3 attr) "nogroup") ; gid
(or (nth 7 attr) (nth 2 x)) ; size
(format-time-string
(if (tramp-time-less-p
(tramp-time-subtract (current-time) (nth 3 x))
(if (time-less-p (time-subtract (current-time) (nth 3 x))
tramp-half-a-year)
"%b %e %R"
"%b %e %Y")

View File

@ -2253,8 +2253,9 @@ Falls back to normal file name handler if no Tramp file name handler exists."
;;;###autoload
(progn (defun tramp-autoload-file-name-handler (operation &rest args)
"Load Tramp file name handler, and perform OPERATION."
;; Avoid recursive loading of tramp.el.
(let ((default-directory temporary-file-directory))
;; Avoid recursive loading of tramp.el. `temporary-file-directory'
;; does not exist in XEmacs, so we must use something else.
(let ((default-directory (or (symbol-value 'temporary-file-directory) "/")))
(load "tramp" nil t))
(apply operation args)))
@ -2968,8 +2969,8 @@ User is always nil."
(cond
((not (file-exists-p file1)) nil)
((not (file-exists-p file2)) t)
(t (tramp-time-less-p (nth 5 (file-attributes file2))
(nth 5 (file-attributes file1))))))
(t (time-less-p (nth 5 (file-attributes file2))
(nth 5 (file-attributes file1))))))
(defun tramp-handle-file-regular-p (filename)
"Like `file-regular-p' for Tramp files."
@ -4171,7 +4172,8 @@ Invokes `password-read' if available, `read-passwd' else."
(tramp-check-for-regexp proc tramp-password-prompt-regexp)
(format "%s for %s " (capitalize (match-string 1)) key))))
;; We suspend the timers while reading the password.
(stimers (with-timeout-suspend))
(stimers (and (functionp 'with-timeout-suspend)
(tramp-compat-funcall 'with-timeout-suspend)))
auth-info auth-passwd)
(unwind-protect
@ -4211,7 +4213,8 @@ Invokes `password-read' if available, `read-passwd' else."
(read-passwd pw-prompt))
(tramp-set-connection-property v "first-password-request" nil)))
;; Reenable the timers.
(with-timeout-unsuspend stimers))))
(and (functionp 'with-timeout-unsuspend)
(tramp-compat-funcall 'with-timeout-unsuspend stimers)))))
;;;###tramp-autoload
(defun tramp-clear-passwd (vec)
@ -4236,26 +4239,6 @@ Invokes `password-read' if available, `read-passwd' else."
("oct" . 10) ("nov" . 11) ("dec" . 12))
"Alist mapping month names to integers.")
;; FIXME: Shouldn't this also look at any subseconds parts of T1 and T2?
;;;###tramp-autoload
(defun tramp-time-less-p (t1 t2)
"Say whether time value T1 is less than time value T2."
(unless t1 (setq t1 '(0 0)))
(unless t2 (setq t2 '(0 0)))
(or (< (car t1) (car t2))
(and (= (car t1) (car t2))
(< (nth 1 t1) (nth 1 t2)))))
;; FIXME: Shouldn't this also look at any subseconds parts of T1 and T2?
(defun tramp-time-subtract (t1 t2)
"Subtract two time values.
Return the difference in the format of a time value."
(unless t1 (setq t1 '(0 0)))
(unless t2 (setq t2 '(0 0)))
(let ((borrow (< (cadr t1) (cadr t2))))
(list (- (car t1) (car t2) (if borrow 1 0))
(- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
;;;###tramp-autoload
(defun tramp-time-diff (t1 t2)
"Return the difference between the two times, in seconds.
@ -4274,7 +4257,7 @@ T1 and T2 are time values (as returned by `current-time' for example)."
(if (< (length t1) 3) (append t1 '(0)) t1)
(if (< (length t2) 3) (append t2 '(0)) t2)))
(t
(let ((time (tramp-time-subtract t1 t2)))
(let ((time (time-subtract t1 t2)))
(+ (* (car time) 65536.0)
(cadr time)
(/ (or (nth 2 time) 0) 1000000.0))))))