comparison lisp/net/tramp.el @ 72569:7457615d594a

Sync with Tramp 2.0.54.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 29 Aug 2006 05:48:40 +0000
parents 21a427e4868a
children 59b2832e02ef c358d0861b16
comparison
equal deleted inserted replaced
72568:02a05917de2a 72569:7457615d594a
3886 (tramp-run-real-handler 'find-backup-file-name (list filename))))) 3886 (tramp-run-real-handler 'find-backup-file-name (list filename)))))
3887 3887
3888 (defun tramp-handle-make-auto-save-file-name () 3888 (defun tramp-handle-make-auto-save-file-name ()
3889 "Like `make-auto-save-file-name' for tramp files. 3889 "Like `make-auto-save-file-name' for tramp files.
3890 Returns a file name in `tramp-auto-save-directory' for autosaving this file." 3890 Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3891 (when tramp-auto-save-directory 3891 (let ((tramp-auto-save-directory tramp-auto-save-directory))
3892 (unless (file-exists-p tramp-auto-save-directory) 3892 ;; File name must be unique. This is ensured with Emacs 22 (see
3893 (make-directory tramp-auto-save-directory t))) 3893 ;; UNIQUIFY element of `auto-save-file-name-transforms'); but for
3894 ;; jka-compr doesn't like auto-saving, so by appending "~" to the 3894 ;; all other cases we must do it ourselves.
3895 ;; file name we make sure that jka-compr isn't used for the 3895 (when (boundp 'auto-save-file-name-transforms)
3896 ;; auto-save file. 3896 (mapcar
3897 (let ((buffer-file-name 3897 '(lambda (x)
3898 (if tramp-auto-save-directory 3898 (when (and (string-match (car x) buffer-file-name)
3899 (expand-file-name 3899 (not (car (cddr x))))
3900 (tramp-subst-strs-in-string 3900 (setq tramp-auto-save-directory
3901 '(("_" . "|") 3901 (or tramp-auto-save-directory temporary-file-directory))))
3902 ("/" . "_a") 3902 (symbol-value 'auto-save-file-name-transforms)))
3903 (":" . "_b") 3903 ;; Create directory.
3904 ("|" . "__") 3904 (when tramp-auto-save-directory
3905 ("[" . "_l") 3905 (unless (file-exists-p tramp-auto-save-directory)
3906 ("]" . "_r")) 3906 (make-directory tramp-auto-save-directory t)))
3907 (buffer-file-name)) 3907 ;; jka-compr doesn't like auto-saving, so by appending "~" to the
3908 tramp-auto-save-directory) 3908 ;; file name we make sure that jka-compr isn't used for the
3909 (buffer-file-name)))) 3909 ;; auto-save file.
3910 ;; Run plain `make-auto-save-file-name'. There might be an advice when 3910 (let ((buffer-file-name
3911 ;; it is not a magic file name operation (since Emacs 22). 3911 (if tramp-auto-save-directory
3912 ;; We must deactivate it temporarily. 3912 (expand-file-name
3913 (if (not (ad-is-active 'make-auto-save-file-name)) 3913 (tramp-subst-strs-in-string
3914 (tramp-run-real-handler 3914 '(("_" . "|")
3915 'make-auto-save-file-name nil) 3915 ("/" . "_a")
3916 ;; else 3916 (":" . "_b")
3917 (ad-deactivate 'make-auto-save-file-name) 3917 ("|" . "__")
3918 (prog1 3918 ("[" . "_l")
3919 (tramp-run-real-handler 3919 ("]" . "_r"))
3920 'make-auto-save-file-name nil) 3920 (buffer-file-name))
3921 (ad-activate 'make-auto-save-file-name))))) 3921 tramp-auto-save-directory)
3922 (buffer-file-name))))
3923 ;; Run plain `make-auto-save-file-name'. There might be an advice when
3924 ;; it is not a magic file name operation (since Emacs 22).
3925 ;; We must deactivate it temporarily.
3926 (if (not (ad-is-active 'make-auto-save-file-name))
3927 (tramp-run-real-handler
3928 'make-auto-save-file-name nil)
3929 ;; else
3930 (ad-deactivate 'make-auto-save-file-name)
3931 (prog1
3932 (tramp-run-real-handler
3933 'make-auto-save-file-name nil)
3934 (ad-activate 'make-auto-save-file-name))))))
3922 3935
3923 3936
3924 ;; CCC grok APPEND, LOCKNAME, CONFIRM 3937 ;; CCC grok APPEND, LOCKNAME, CONFIRM
3925 (defun tramp-handle-write-region 3938 (defun tramp-handle-write-region
3926 (start end filename &optional append visit lockname confirm) 3939 (start end filename &optional append visit lockname confirm)
4331 ;;;###autoload 4344 ;;;###autoload
4332 (defsubst tramp-register-file-name-handlers () 4345 (defsubst tramp-register-file-name-handlers ()
4333 "Add tramp file name handlers to `file-name-handler-alist'." 4346 "Add tramp file name handlers to `file-name-handler-alist'."
4334 (add-to-list 'file-name-handler-alist 4347 (add-to-list 'file-name-handler-alist
4335 (cons tramp-file-name-regexp 'tramp-file-name-handler)) 4348 (cons tramp-file-name-regexp 'tramp-file-name-handler))
4336 (when (or partial-completion-mode (featurep 'ido)) 4349 ;; `partial-completion-mode' is unknown in XEmacs. So we should
4350 ;; load it unconditionally there. In the GNU Emacs case, method/
4351 ;; user/host name completion shall be bound to `partial-completion-mode'.
4352 (when (or (not (boundp 'partial-completion-mode))
4353 (symbol-value 'partial-completion-mode)
4354 (featurep 'ido))
4337 (add-to-list 'file-name-handler-alist 4355 (add-to-list 'file-name-handler-alist
4338 (cons tramp-completion-file-name-regexp 4356 (cons tramp-completion-file-name-regexp
4339 'tramp-completion-file-name-handler)) 4357 'tramp-completion-file-name-handler))
4340 (put 'tramp-completion-file-name-handler 'safe-magic t)) 4358 (put 'tramp-completion-file-name-handler 'safe-magic t))
4341 ;; If jka-compr is already loaded, move it to the front of 4359 ;; If jka-compr is already loaded, move it to the front of
6747 (unless (stringp (nth 8 attr)) 6765 (unless (stringp (nth 8 attr))
6748 (setcar (nthcdr 8 attr) (tramp-file-mode-from-int (nth 8 attr)))) 6766 (setcar (nthcdr 8 attr) (tramp-file-mode-from-int (nth 8 attr))))
6749 ;; Set file's gid change bit. Possible only when id-format is 'integer. 6767 ;; Set file's gid change bit. Possible only when id-format is 'integer.
6750 (when (numberp (nth 3 attr)) 6768 (when (numberp (nth 3 attr))
6751 (setcar (nthcdr 9 attr) 6769 (setcar (nthcdr 9 attr)
6752 (not (= (nth 3 attr) 6770 (not (eql (nth 3 attr)
6753 (tramp-get-remote-gid multi-method method user host))))) 6771 (tramp-get-remote-gid multi-method method user host)))))
6754 ;; Set virtual device number. 6772 ;; Set virtual device number.
6755 (setcar (nthcdr 11 attr) 6773 (setcar (nthcdr 11 attr)
6756 (tramp-get-device multi-method method user host)) 6774 (tramp-get-device multi-method method user host))
6757 attr) 6775 attr)
6758 6776
7198 (key (concat luser "@" lhost))) 7216 (key (concat luser "@" lhost)))
7199 (apply #'password-cache-remove (list key)))))) 7217 (apply #'password-cache-remove (list key))))))
7200 7218
7201 (defun tramp-time-diff (t1 t2) 7219 (defun tramp-time-diff (t1 t2)
7202 "Return the difference between the two times, in seconds. 7220 "Return the difference between the two times, in seconds.
7203 T1 and T2 are time values (as returned by `current-time' for example). 7221 T1 and T2 are time values (as returned by `current-time' for example)."
7204
7205 NOTE: This function will fail if the time difference is too large to
7206 fit in an integer."
7207 ;; Pacify byte-compiler with `symbol-function'. 7222 ;; Pacify byte-compiler with `symbol-function'.
7208 (cond ((and (fboundp 'subtract-time) 7223 (cond ((and (fboundp 'subtract-time)
7209 (fboundp 'float-time)) 7224 (fboundp 'float-time))
7210 (funcall (symbol-function 'float-time) 7225 (funcall (symbol-function 'float-time)
7211 (funcall (symbol-function 'subtract-time) t1 t2))) 7226 (funcall (symbol-function 'subtract-time) t1 t2)))
7212 ((and (fboundp 'subtract-time) 7227 ((and (fboundp 'subtract-time)
7213 (fboundp 'time-to-seconds)) 7228 (fboundp 'time-to-seconds))
7214 (funcall (symbol-function 'time-to-seconds) 7229 (funcall (symbol-function 'time-to-seconds)
7215 (funcall (symbol-function 'subtract-time) t1 t2))) 7230 (funcall (symbol-function 'subtract-time) t1 t2)))
7216 ((fboundp 'itimer-time-difference) 7231 ((fboundp 'itimer-time-difference)
7217 (floor (funcall 7232 (funcall (symbol-function 'itimer-time-difference)
7218 (symbol-function 'itimer-time-difference) 7233 (if (< (length t1) 3) (append t1 '(0)) t1)
7219 (if (< (length t1) 3) (append t1 '(0)) t1) 7234 (if (< (length t2) 3) (append t2 '(0)) t2)))
7220 (if (< (length t2) 3) (append t2 '(0)) t2))))
7221 (t 7235 (t
7222 ;; snarfed from Emacs 21 time-date.el; combining 7236 ;; snarfed from Emacs 21 time-date.el; combining
7223 ;; time-to-seconds and subtract-time 7237 ;; time-to-seconds and subtract-time
7224 (let ((time (let ((borrow (< (cadr t1) (cadr t2)))) 7238 (let ((time (let ((borrow (< (cadr t1) (cadr t2))))
7225 (list (- (car t1) (car t2) (if borrow 1 0)) 7239 (list (- (car t1) (car t2) (if borrow 1 0))