comparison lisp/net/tramp.el @ 50338:155b4b78aa3b

* tramp.el: Version 2.0.31 released. (tramp-handle-expand-file-name): Do not allow ".." to cross file handler boundaries, so that "/user@host:/../foo" expands to itself, rather than "/foo". This is intended to work in conjunction with a change in `file-relative-name' which makes sure to use absolute file names if FILE and DIRECTORY have different handlers. (tramp-handle-insert-directory): Comment out XEmacs kludge. Suggested by Katsumi Yamaoka <yamaoka@jpl.org>. * Makefile.in (../info/tramp): Compile Emacs, instead of XEmacs, version of manual. * tramp.texi (Auto-save and Backup): New node.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sat, 29 Mar 2003 15:16:57 +0000
parents a0e8a85259ed
children 7d56636afc9c
comparison
equal deleted inserted replaced
50337:f4504bc1f3bf 50338:155b4b78aa3b
1 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol -*- coding: iso-8859-1; -*- 1 ;;; -*- mode: Emacs-Lisp; coding: iso-8859-1; -*-
2 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol
2 3
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 4 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 5
5 ;; Author: Kai.Grossjohann@CS.Uni-Dortmund.DE 6 ;; Author: kai.grossjohann@gmx.net
6 ;; Keywords: comm, processes 7 ;; Keywords: comm, processes
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
9 10
10 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; GNU Emacs is free software; you can redistribute it and/or modify
27 ;; This package provides remote file editing, similar to ange-ftp. 28 ;; This package provides remote file editing, similar to ange-ftp.
28 ;; The difference is that ange-ftp uses FTP to transfer files between 29 ;; The difference is that ange-ftp uses FTP to transfer files between
29 ;; the local and the remote host, whereas tramp.el uses a combination 30 ;; the local and the remote host, whereas tramp.el uses a combination
30 ;; of rsh and rcp or other work-alike programs, such as ssh/scp. 31 ;; of rsh and rcp or other work-alike programs, such as ssh/scp.
31 ;; 32 ;;
32 ;; For more detailed instructions, please see the info file, which is 33 ;; For more detailed instructions, please see the info file.
33 ;; included in the file `tramp.tar.gz' mentioned below.
34 ;; 34 ;;
35 ;; Notes: 35 ;; Notes:
36 ;; ----- 36 ;; -----
37 ;; 37 ;;
38 ;; This package only works for Emacs 20 and higher, and for XEmacs 21 38 ;; This package only works for Emacs 20 and higher, and for XEmacs 21
44 ;; loaded before tramp.el. Could you please test this and tell me about 44 ;; loaded before tramp.el. Could you please test this and tell me about
45 ;; the result? Thanks. 45 ;; the result? Thanks.
46 ;; 46 ;;
47 ;; Also see the todo list at the bottom of this file. 47 ;; Also see the todo list at the bottom of this file.
48 ;; 48 ;;
49 ;; The current version of tramp.el can be retrieved from the following 49 ;; The current version of Tramp can be retrieved from the following URL:
50 ;; URL: ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz 50 ;; http://savannah.nongnu.org/download/tramp/
51 ;; For your convenience, the *.el file is available separately from
52 ;; the same directory.
53 ;; 51 ;;
54 ;; There's a mailing list for this, as well. Its name is: 52 ;; There's a mailing list for this, as well. Its name is:
55 ;; tramp-devel@mail.freesoftware.fsf.org 53 ;; tramp-devel@mail.freesoftware.fsf.org
56 ;; Send a mail with `help' in the subject (!) to the administration 54 ;; Send a mail with `help' in the subject (!) to the administration
57 ;; address for instructions on joining the list. The administration 55 ;; address for instructions on joining the list. The administration
58 ;; address is: 56 ;; address is:
59 ;; tramp-devel-request@mail.freesoftware.fsf.org 57 ;; tramp-devel-request@mail.freesoftware.fsf.org
60 ;; You can also use the Web to subscribe, under the following URL: 58 ;; You can also use the Web to subscribe, under the following URL:
67 ;; 65 ;;
68 ;; Don't forget to put on your asbestos longjohns, first! 66 ;; Don't forget to put on your asbestos longjohns, first!
69 67
70 ;;; Code: 68 ;;; Code:
71 69
72 ;; In the Tramp CVS repository, the version numer is auto-frobbed from 70 ;; The Tramp version number and bug report address, as prepared by configure.
73 ;; the Makefile, so you should edit the top-level Makefile to change 71 (require 'trampver)
74 ;; the version number.
75 (defconst tramp-version "2.0.30"
76 "This version of tramp.")
77
78 (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"
79 "Email address to send bug reports to.")
80 72
81 (require 'timer) 73 (require 'timer)
82 (require 'format-spec) ;from Gnus 5.8, also in tar ball 74 (require 'format-spec) ;from Gnus 5.8, also in tar ball
83 ;; The explicit check is not necessary in Emacs, which provides the 75 ;; The explicit check is not necessary in Emacs, which provides the
84 ;; feature even if implemented in C, but it appears to be necessary 76 ;; feature even if implemented in C, but it appears to be necessary
1273 (message \"Bytes sent: %s\\tBytes received: %s\" bytes (match-string 0)))) 1265 (message \"Bytes sent: %s\\tBytes received: %s\" bytes (match-string 0))))
1274 1266
1275 Please raise a bug report via \"M-x tramp-bug\" if your system needs 1267 Please raise a bug report via \"M-x tramp-bug\" if your system needs
1276 this variable to be set as well." 1268 this variable to be set as well."
1277 :group 'tramp 1269 :group 'tramp
1278 :type 'integer) 1270 :type '(choice (const nil) integer))
1279 1271
1280 ;;; Internal Variables: 1272 ;;; Internal Variables:
1281 1273
1282 (defvar tramp-buffer-file-attributes nil 1274 (defvar tramp-buffer-file-attributes nil
1283 "Holds the `ls -ild' output for the current buffer. 1275 "Holds the `ls -ild' output for the current buffer.
2829 (concat (file-name-as-directory 2821 (concat (file-name-as-directory
2830 (file-name-nondirectory localname)) ".") 2822 (file-name-nondirectory localname)) ".")
2831 (file-name-nondirectory localname))))) 2823 (file-name-nondirectory localname)))))
2832 (sit-for 1) ;needed for rsh but not ssh? 2824 (sit-for 1) ;needed for rsh but not ssh?
2833 (tramp-wait-for-output)) 2825 (tramp-wait-for-output))
2826 ;; The following let-binding is used by code that's commented
2827 ;; out. Let's leave the let-binding in for a while to see
2828 ;; that the commented-out code is really not needed. Commenting-out
2829 ;; happened on 2003-03-13.
2834 (let ((old-pos (point))) 2830 (let ((old-pos (point)))
2835 (insert-buffer-substring 2831 (insert-buffer-substring
2836 (tramp-get-buffer multi-method method user host)) 2832 (tramp-get-buffer multi-method method user host))
2837 ;; On XEmacs, we want to call (exchange-point-and-mark t), but 2833 ;; On XEmacs, we want to call (exchange-point-and-mark t), but
2838 ;; that doesn't exist on Emacs, so we use this workaround instead. 2834 ;; that doesn't exist on Emacs, so we use this workaround instead.
2841 ;; (let ((zmacs-region-stays t)) 2837 ;; (let ((zmacs-region-stays t))
2842 ;; (exchange-point-and-mark)) 2838 ;; (exchange-point-and-mark))
2843 (save-excursion 2839 (save-excursion
2844 (tramp-send-command multi-method method user host "cd") 2840 (tramp-send-command multi-method method user host "cd")
2845 (tramp-wait-for-output)) 2841 (tramp-wait-for-output))
2846 ;; Another XEmacs specialty follows. What's the right way to do 2842 ;; For the time being, the XEmacs kludge is commented out.
2847 ;; it? 2843 ;; Please test it on various XEmacs versions to see if it works.
2848 (when (and (featurep 'xemacs) 2844 ;; ;; Another XEmacs specialty follows. What's the right way to do
2849 (eq major-mode 'dired-mode)) 2845 ;; ;; it?
2850 (save-excursion 2846 ;; (when (and (featurep 'xemacs)
2851 (require 'dired) 2847 ;; (eq major-mode 'dired-mode))
2852 (dired-insert-set-properties old-pos (point))))))) 2848 ;; (save-excursion
2849 ;; (require 'dired)
2850 ;; (dired-insert-set-properties old-pos (point))))
2851 )))
2853 2852
2854 ;; Continuation of kluge to pacify byte-compiler. 2853 ;; Continuation of kluge to pacify byte-compiler.
2855 ;;(eval-when-compile 2854 ;;(eval-when-compile
2856 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) 2855 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore)
2857 ;; (fmakunbound 'dired-insert-set-properties))) 2856 ;; (fmakunbound 'dired-insert-set-properties)))
2915 (tramp-wait-for-output) 2914 (tramp-wait-for-output)
2916 (goto-char (point-min)) 2915 (goto-char (point-min))
2917 (setq uname (buffer-substring (point) (tramp-line-end-position))) 2916 (setq uname (buffer-substring (point) (tramp-line-end-position)))
2918 (setq localname (concat uname fname)) 2917 (setq localname (concat uname fname))
2919 (erase-buffer))) 2918 (erase-buffer)))
2920 ;; Look if localname starts with "/../" construct. If this is 2919 ;; No tilde characters in file name, do normal
2921 ;; the case, then we return a local name instead of a remote name. 2920 ;; expand-file-name (this does "/./" and "/../"). We bind
2922 (if (string-match "^/\\.\\./" localname) 2921 ;; directory-sep-char here for XEmacs on Windows, which
2923 (expand-file-name (substring localname 3)) 2922 ;; would otherwise use backslash.
2924 ;; No tilde characters in file name, do normal 2923 (let ((directory-sep-char ?/))
2925 ;; expand-file-name (this does "/./" and "/../"). We bind 2924 (tramp-make-tramp-file-name
2926 ;; directory-sep-char here for XEmacs on Windows, which 2925 multi-method method user host
2927 ;; would otherwise use backslash. 2926 (tramp-drop-volume-letter
2928 (let ((directory-sep-char ?/)) 2927 (tramp-run-real-handler 'expand-file-name
2929 (tramp-make-tramp-file-name 2928 (list localname)))))))))
2930 multi-method method user host 2929
2931 (tramp-drop-volume-letter 2930 ;; old version follows. it uses ".." to cross file handler
2932 (tramp-run-real-handler 'expand-file-name 2931 ;; boundaries.
2933 (list localname)))))))))) 2932 ;; ;; Look if localname starts with "/../" construct. If this is
2933 ;; ;; the case, then we return a local name instead of a remote name.
2934 ;; (if (string-match "^/\\.\\./" localname)
2935 ;; (expand-file-name (substring localname 3))
2936 ;; ;; No tilde characters in file name, do normal
2937 ;; ;; expand-file-name (this does "/./" and "/../"). We bind
2938 ;; ;; directory-sep-char here for XEmacs on Windows, which
2939 ;; ;; would otherwise use backslash.
2940 ;; (let ((directory-sep-char ?/))
2941 ;; (tramp-make-tramp-file-name
2942 ;; multi-method method user host
2943 ;; (tramp-drop-volume-letter
2944 ;; (tramp-run-real-handler 'expand-file-name
2945 ;; (list localname))))))))))
2934 2946
2935 ;; Remote commands. 2947 ;; Remote commands.
2936 2948
2937 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) 2949 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer)
2938 "Like `shell-command' for tramp files. 2950 "Like `shell-command' for tramp files.