• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/net/

Lines Matching +defs:with +defs:output +defs:to +defs:string

7 ;; (copyright statements below in code to be updated with the above notice)
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
32 ;; This package provides remote file editing, similar to ange-ftp.
33 ;; The difference is that ange-ftp uses FTP to transfer files between
43 ;; and higher. (XEmacs 20 is missing the `with-timeout' macro. Emacs
44 ;; 19 is reported to have other problems. For XEmacs 21, you need the
45 ;; package `fsf-compat' for the `with-timeout' macro.)
47 ;; This version might not work with pre-Emacs 21 VC unless VC is
58 ;; You can use the Web to subscribe, under the following URL:
66 ;; Don't forget to put on your asbestos longjohns, first!
89 ;; feature even if implemented in C, but it appears to be necessary
107 ;; XEmacs is distributed with few Lisp packages. Further packages are
109 ;; Tramp is required in addition to EFS. (But why can't Tramp just
110 ;; disable EFS when Tramp is loaded? Then XEmacs can ship with EFS
113 ;; Tramp only knows how to deal with `file-name-handler-alist', not
117 "Non-nil means to use unified Ange-FTP/Tramp filename syntax.
121 ;; must be done with the `eval-after-load' trick.
173 ;; to pacify Emacs byte-compiler.
181 "Edit remote files with a combination of rsh and rcp or similar programs."
191 "*Whether to send all commands and responses to a debug buffer."
200 Each element looks like (REGEXP . DIRECTORY), with the same meaning like
202 is a local file name, the backup directory is prepended with Tramp file
221 file name, the backup directory is prepended with Tramp file name prefix
230 (string :tag "Backup Dir")
240 The idea is to use a local directory so that auto-saving is faster."
243 string))
250 This shell is used to execute the encoding and decoding command on the
251 local host, so if you want to use `~' in those commands, you should
259 This variable can be used to change the \"/bin/sh\" part. See the
261 variable `tramp-encoding-reads-stdin' to specify whether the commands read
265 mechanisms in tramp.el which automatically determine the right shell to
271 (if (string-match "cmd\\.exe" tramp-encoding-shell)
274 "*Use this switch together with `tramp-encoding-shell' for local commands.
277 :type 'string)
283 Note that the commands always must write to standard output."
290 This variable is similar to `tramp-encoding-shell', but it is only used
292 commands sent to this shell is quite restricted, and if you are
293 careful it works to use CMD.EXE under Windows (instead of a Bourne-ish
299 This variable defaults to the value of `tramp-encoding-shell'."
303 ;; CCC I have changed all occurrences of comint-quote-filename with
306 ;; out to be necessary there, something will need to be done.
310 ;;-Any character in this list is quoted (preceded with a backslash)
311 ;;-because it means something special to the shell. This takes effect
312 ;;-when sending file and directory names to the remote shell.
555 This specifies the function to use to connect to the remote host.
560 This specifies the Bourne shell to use on the remote host. This
561 MUST be a Bourne-like shell. It is normally not necessary to set
562 this to any value other than \"/bin/sh\": tramp wants to use a shell
565 the value that you decide to use. You Have Been Warned.
567 This specifies the name of the program to use for logging in to the
574 This specifies the list of arguments to pass to the above
576 that is, normally you don't want to put \"-a -b\" or \"-f foo\"
581 be used to obtain a literal percent character.
584 This specifies the name of the program to use for remotely copying
588 This specifies the list of parameters to pass to the above mentioned
591 This specifies the parameter to use for the copying program when the
595 This specifies the string to use for terminating the line after
600 not have to be newline or carriage return characters. Other login
601 programs are happy with just one character, the newline character.
605 for all methods; this program is used to log in to the remote site. Then,
606 there are two ways to actually transfer the files between the local and the
608 to do this, set `tramp-copy-program' in the method.
612 this case, the file contents need to be protected since the
617 So, to summarize: if the method is an out-of-band method, then you
626 When using `tramp-open-connection-su' the phrase `open connection to a
628 consistency. No connection is opened to a remote host, but `su' is
629 started on the local host. You are not allowed to specify a remote
633 (cons string
636 (choice (const nil) string))
638 (choice (const nil) string))
640 (choice (const nil) string))
641 (list (const tramp-login-args) (repeat string))
642 (list (const tramp-copy-args) (repeat string))
644 (choice (const nil) string))
646 (choice (const nil) string))
648 (choice (const nil) string))
654 (choice (const nil) string))))))
661 :type '(repeat string))
674 function to be executed, and COMMAND is the shell command used for
677 COMMAND may contain percent escapes. `%u' will be replaced with the
678 user name, `%h' will be replaced with the host name, and `%n' will be
679 replaced with an end-of-line character, as specified in the variable
682 the FUNCTION. For example, the `%u' escape is forbidden with the
686 :type '(repeat (list string function string)))
689 ;; An external copy method seems to be preferred, because it is much
722 "*Default method to use for transferring files.
726 :type 'string)
730 "*Default method to use for specific user/host pairs.
732 specifies the method to use for a file name which does not specify a
738 empty string for the user name.
744 (string :tag "Method"))))
751 "Default list of (FUNCTION FILE) pairs to be examined for rsh methods.")
768 "Default list of (FUNCTION FILE) pairs to be examined for ssh methods.")
774 "Default list of (FUNCTION FILE) pairs to be examined for telnet methods.")
780 "Default list of (FUNCTION FILE) pairs to be examined for su methods.")
786 \(FUNCTION FILE). FUNCTION is responsible to extract user names and host
858 I don't think this ever needs to be changed, so please tell me about it
859 if you need to change this.
863 :type 'string)
871 It seems that people using plink under Windows need to send
876 The default value is to use the same value as `tramp-rsh-end-of-line'."
878 :type 'string)
886 "*List of directories to search for executables on remote host.
887 Please notify me about other semi-standard directories to include here.
890 tilde expansion, all directory names starting with `~' will be ignored."
892 :type '(repeat string))
899 Sometimes the prompt is reported to look like \"login as:\"."
905 "Regexp to match prompts from remote shell.
906 Normally, Tramp expects you to configure `shell-prompt-pattern'
907 correctly, but sometimes it happens that you are connecting to a
911 variable is similar to the default value of `shell-prompt-pattern',
921 The `sudo' program appears to insert a `^@' character into the prompt."
949 (regexp-opt '("Are you sure you want to continue connecting (yes/no)?") t)
951 "Regular expression matching all yes/no queries which need to be confirmed.
952 The confirmation should be done with yes or no.
963 "Regular expression matching all y/n queries which need to be confirmed.
964 The confirmation should be done with y or n.
1005 In fact this expression is empty by intention, it will be used only to
1013 "*Prefix to use for temporary files.
1015 relative to the directory name returned by the function
1017 absolute file name; don't forget to include a prefix for the filename
1020 :type 'string)
1023 "*If non-nil, try to discard garbage sent by remote shell.
1029 "*Alist specifying extra arguments to pass to the remote shell.
1031 matching the shell file name and ARGS is a string specifying the
1034 This variable is only used when Tramp needs to start up another shell
1038 ;; This might be the wrong way to test whether the widget type
1039 ;; `alist' is available. Who knows the right way to test it?
1041 '(alist :key-type string :value-type string)
1042 '(repeat (cons string string))))
1049 :type 'string)
1054 Should always start with \"^\". Derived from `tramp-prefix-format'."
1072 :type 'string)
1088 :type 'string)
1104 :type 'string)
1125 :type 'string)
1140 (defcustom tramp-host-with-port-regexp
1151 :type 'string)
1174 "\\(" tramp-host-with-port-regexp "\\)" tramp-postfix-host-regexp
1189 These numbers are passed directly to `match-string', which see. That
1190 means the opening parentheses are counted to identify the pair.
1221 \(When tramp.el is loaded, this regular expression is prepended to
1276 Multi files allow you to contact a remote host in several hops.
1279 The first element, REGEXP, gives a regular expression to match against
1280 the file name. In this regular expression, `%s' is replaced with the
1281 value of `tramp-multi-file-name-hop-structure'. (Note: in order to
1282 allow multiple hops, you normally want to use something like
1291 LOCALNAME can also be negative, which means to count from the end. Ie, a
1295 string, but I haven't actually tried what happens if it doesn't..."
1300 (integer :tag "Paren pair to match localname")))
1307 "\\(" tramp-host-with-port-regexp "\\)")
1311 element REGEXP is used to match against the hop. Pair number METHOD
1330 "*Describes how to construct a `multi' file name.
1333 The first element PREFIX says how to construct the prefix, the second
1335 LOCALNAME says how to construct the localname (pathname).
1348 Note: the current implementation requires the prefix to contain the
1352 :type '(list string string string))
1355 "*Value of TERM environment variable for logging in to remote host.
1356 Because Tramp wants to parse the output of the remote shell, it is easily
1360 :type 'string)
1367 completion is possible (subject to the variable `completion-ignore-case'),
1387 variable gives the regular expression to search for. Note that the
1389 appended to it.
1402 This list is used for copying/renaming with out-of-band methods.
1424 "List of commands to send to the first remote shell that we see.
1425 These commands will be sent to any shell, and thus they should be
1426 designed to work in such circumstances. Also, restrict the commands
1427 to the bare necessity for getting the remote shell into a state
1428 where it is possible to execute the Bourne-ish shell.
1430 At the moment, the command to execute the Bourne-ish shell uses strange
1431 quoting which `tcsh' tries to correct, so we send the command \"unset
1432 autocorrect\" to the remote host."
1434 :type '(repeat string))
1436 ;; Chunked sending kluge. We set this to 500 for black-listed constellations
1437 ;; known to have a bug in `process-send-string'; some ssh connections appear
1438 ;; to drop bytes when data is sent too quickly. There is also a connection
1447 ;; `open-paren-in-column-0-is-defun-start' set to t.
1448 "*If non-nil, chunksize for sending input to local process.
1449 It is necessary only on systems which have a buggy `process-send-string'
1453 (with-temp-buffer
1463 (process-send-string proc (make-string sent ?\\ ))
1468 (accept-process-output proc 1))
1470 (setq received (string-to-number (match-string 0)))
1475 (message \"You should set `tramp-chunksize' to a maximum of %s\"
1484 the `*scratch*' buffer and then hitting C-j with the cursor after the
1486 \"ssh\" to run without password query, see ssh-agent(1).
1488 You will see the number of bytes sent successfully to the remote host.
1497 When it is necessary to set `tramp-chunksize', you might consider to
1499 \(like \"ssh\"), because setting `tramp-chunksize' to non-nil decreases
1503 this variable to be set as well."
1507 ;; Logging in to a remote host normally requires obtaining a pty. But
1508 ;; Emacs on MacOS X has process-connection-type set to nil by default,
1513 Tramp binds process-connection-type to the value given here before
1514 opening a connection to a remote host."
1521 "Holds the `ls -ild' output for the current buffer.
1522 This variable is local to each buffer. It is not used if the remote
1530 (lambda (x) (base64-encode-string
1533 "Function to call for running the MD5 algorithm.")
1535 (defvar tramp-end-of-output
1539 (prin1-to-string process-environment)
1540 (current-time-string)
1541 ;; (prin1-to-string
1553 "String used to recognize end of output.")
1617 "This command is used to get a long listing with numeric user and group ids.
1618 This variable is automatically made buffer-local to each rsh process buffer
1623 This variable is automatically made buffer-local to each rsh process buffer
1628 This variable is automatically made buffer-local to each rsh process buffer
1633 This variable is automatically made buffer-local to each rsh process buffer
1638 This variable is automatically made buffer-local to each rsh process buffer
1644 This variable is automatically made buffer-local to each rsh process buffer
1648 "Command to use for checking if a file exists.
1649 This variable is automatically made buffer-local to each rsh process buffer
1658 "Shell function to implement `uudecode' to standard output.
1663 ;; Perl script to implement `file-attributes' in a Lisp `read'able
1664 ;; output. If you are hacking on this, note that you get *no* output
1703 "Perl script to produce output suitable for use with `file-attributes'
1707 chdir($ARGV[0]) or printf(\"\\\"Cannot change to $ARGV[0]: $''!''\\\"\\n\"), exit();
1754 output.")
1767 ;; "Perl program to use for encoding a file.
1768 ;; Escape sequence %s is replaced with name of Perl binary.")
1773 ;; "Perl program to use for decoding a file.
1774 ;; Escape sequence %s is replaced with name of Perl binary.")
1777 (defvar tramp-perl-encode-with-module
1779 "Perl program to use for encoding a file.
1780 Escape sequence %s is replaced with name of Perl binary.
1781 This string is passed to `format', so percent characters need to be doubled.
1782 This implementation requires the MIME::Base64 Perl module to be installed
1785 (defvar tramp-perl-decode-with-module
1787 "Perl program to use for decoding a file.
1788 Escape sequence %s is replaced with name of Perl binary.
1789 This string is passed to `format', so percent characters need to be doubled.
1790 This implementation requires the MIME::Base64 Perl module to be installed
1808 # We read in chunks of 54 bytes, to generate output lines
1821 # Not the fastest method, but it is simple: unpack to binary string, split
1822 # by groups of 6 bits and convert back from binary to byte; then map into
1832 "Perl program to use for encoding a file.
1833 Escape sequence %s is replaced with name of Perl binary.
1834 This string is passed to `format', so percent characters need to be doubled.")
1853 # We are going to accumulate into $pending to accept any line length
1861 # any following data is to be discarded
1869 # Easy method: translate from chars to (pregenerated) six-bit packets, join,
1870 # split in 8-bit chunks and convert back to char.
1878 "Perl program to use for decoding a file.
1879 Escape sequence %s is replaced with name of Perl binary.
1880 This string is passed to `format', so percent characters need to be doubled.")
1898 This is used to map a mode number to a permission string.")
1913 "Whether to process echoes from the remote shell.")
1927 "Internal variable to say if `write-region' chooses the right coding.
1929 on the FILENAME argument, even if VISIT was a string.")
1958 (add-name-to-file . tramp-handle-add-name-to-file)
2008 (defsubst tramp-message (level fmt-string &rest args)
2010 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The
2011 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL.
2012 Calls function `message' with FMT-STRING as control string and the remaining
2013 ARGS to actually emit the message (if applicable).
2015 This function expects to be called from the tramp buffer only!"
2017 (apply #'message (concat "tramp: " fmt-string) args)
2027 (tramp-insert-with-face
2029 (concat "# " (apply #'format fmt-string args) "\n"))))))
2032 (multi-method method user host level fmt-string &rest args)
2033 "Like `tramp-message' but temporarily switches to the tramp buffer.
2034 First three args METHOD, USER, and HOST identify the tramp buffer to use,
2035 remaining args passed to `tramp-message'."
2038 (apply 'tramp-message level fmt-string args)))
2049 (defmacro with-parsed-tramp-file-name (filename var &rest body)
2053 Second arg VAR is a symbol. It is used as a variable name to hold
2056 `foo' will be bound to the whole structure, `foo-multi-method' will
2057 be bound to the multi-method component, and so on for `foo-method',
2060 Remaining args are Lisp expressions to be evaluated (inside an implicit
2063 If VAR is nil, then we bind `v' to the structure and `multi-method',
2064 `method', `user', `host', `localname' to the components."
2078 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
2080 (def-edebug-spec with-parsed-tramp-file-name (form symbolp body))
2084 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>")))
2087 "Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete.
2089 The intent is to protect against `obsolete variable' warnings."
2102 The FUNCTION is intended to parse FILE according its syntax.
2132 (add-to-list 'tramp-completion-function-alist
2153 (with-parsed-tramp-file-name linkname l
2163 ;; What to do?
2164 (if (or (null ok-if-already-exists) ; not allowed to exist
2181 ;; that FILENAME belongs to.
2196 (with-parsed-tramp-file-name file nil
2206 (string-match "\\.elc?\\'" file))
2217 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
2228 (with-parsed-tramp-file-name file nil
2235 (with-parsed-tramp-file-name file nil
2240 (with-parsed-tramp-file-name (expand-file-name filename) nil
2241 (let* ((steps (tramp-split-string localname "/"))
2244 (is-dir (string= localname localnamedir))
2250 ;; is hung. Of course, correctness has to come first.
2274 (cond ((string= "." thisstep)
2277 ((string= ".." thisstep)
2285 10 "Follow symlink to %s" symlink-target)
2289 ;; If the symlink was absolute, we'll get a string like
2293 (with-parsed-tramp-file-name symlink-target sym
2301 (append (tramp-split-string symlink-target "/") steps)))
2308 ;; Combine list to form string.
2313 (when (and is-dir (or (string= "" result)
2314 (not (string= (substring result -1) "/"))))
2326 (with-parsed-tramp-file-name filename nil
2337 ;; EFS use device number "-1". In order to be different, we use device number
2350 (with-parsed-tramp-file-name filename nil
2355 (tramp-handle-file-attributes-with-perl multi-method method user host
2357 (tramp-handle-file-attributes-with-ls multi-method method user host
2360 (defun tramp-handle-file-attributes-with-ls
2367 "file attributes with ls: %s"
2376 (tramp-wait-for-output)
2377 ;; parse `ls -l' output ...
2385 (string-match
2390 (small (read (match-string 1 (caddr err))))
2409 ;; if symlink, find out file name pointed to
2417 ;; 0. t for directory, string (name linked to) for symbolic
2420 ;; 1. Number of links to file.
2431 '(0 0) '(0 0) '(0 0) ;CCC how to find out?
2434 ;; 8. File modes, as a string of ten letters or dashes as in ls -l.
2445 (defun tramp-handle-file-attributes-with-perl
2449 "file attributes with perl: %s"
2458 (tramp-wait-for-output)
2470 (with-parsed-tramp-file-name f nil
2477 ;; `tramp-handle-file-attributes-with-ls'.
2486 (tramp-wait-for-output)
2505 (with-current-buffer buf
2512 (with-parsed-tramp-file-name f nil
2522 ;; For compatibility, deal with both the old
2537 (tramp-wait-for-output)
2542 ;; if and only if that agrees with the buffer's record.
2547 (with-parsed-tramp-file-name filename nil
2552 (tramp-decimal-to-octal mode)
2564 (with-parsed-tramp-file-name filename nil
2569 (with-parsed-tramp-file-name filename nil
2574 (with-parsed-tramp-file-name filename nil
2582 ;; newer than). If this breaks, tell me about it and I'll try to do
2593 ;; We try to get the mtime of both files. If they are not
2594 ;; equal to the "dont-know" value, then we subtract the times
2602 ;; still try to run a shell command on the remote host.
2613 (with-parsed-tramp-file-name file1 v1
2614 (with-parsed-tramp-file-name file2 v2
2637 (with-parsed-tramp-file-name filename nil
2639 (tramp-mode-string-to-int
2645 ;; pointing to directories. Surely the most obvious implementation
2652 (with-parsed-tramp-file-name filename nil
2663 (with-parsed-tramp-file-name filename nil
2669 (with-parsed-tramp-file-name filename nil
2681 (with-parsed-tramp-file-name filename nil
2693 (with-parsed-tramp-file-name filename nil
2714 ;; (with-parsed-tramp-file-name directory nil
2718 ;; (eq (string-match tramp-file-name-regexp directory) 0)
2727 ;; Method, host, etc, are unchanged. Does it make sense to try
2728 ;; to avoid parsing the filename?
2729 (with-parsed-tramp-file-name directory nil
2732 (not (string= localname "/")))
2741 (with-parsed-tramp-file-name directory nil
2755 (tramp-wait-for-output)
2760 (when (or (not match) (string-match match x))
2767 (tramp-wait-for-output)
2795 (with-parsed-tramp-file-name directory nil
2803 (tramp-wait-for-output)
2810 (if (and match (not (string-match match (caadr cell))))
2822 (sort (cdr root) (lambda (x y) (string< (car x) (car y))))))))))
2825 ;; files. We use `ls -ad' to get a list of files (including
2826 ;; directories), and `find . -type d \! -name . -prune' to get a list
2830 (with-parsed-tramp-file-name directory nil
2831 (unless (save-match-data (string-match "/" filename))
2843 ;; tagging the directories with a trailing '/'. Because I
2856 ;; Now grab the output.
2857 (tramp-wait-for-output)
2865 (tramp-wait-for-output)
2889 (defun tramp-handle-add-name-to-file
2891 "Like `add-name-to-file' for tramp files."
2892 (with-parsed-tramp-file-name filename v1
2893 (with-parsed-tramp-file-name newname v2
2901 (error "add-name-to-file: %s"
2910 (error "add-name-to-file: file %s already exists" newname))
2916 "error with add-name-to-file, see buffer `%s' for details"
2953 OP must be `copy' or `rename' and indicates the operation to perform.
2954 FILENAME specifies the file to copy or rename, NEWNAME is the name of
2957 KEEP-DATE means to make sure that NEWNAME has the same timestamp
2975 ;; We cannot invoke `with-parsed-tramp-file-name';
2978 (with-parsed-tramp-file-name filename l
2986 (with-parsed-tramp-file-name newname l
3011 ;; default-directory should point to a local
3012 ;; directory if we want to invoke rcp.
3018 (not (string-match "\\([^#]*\\)#\\(.*\\)" v1-host))
3019 (not (string-match "\\([^#]*\\)#\\(.*\\)" v2-host)))
3027 ;; source file into it, then write out the buffer to
3056 "Use an Emacs buffer to copy or rename a file.
3060 (let ((trampbuf (get-buffer-create "*tramp output*"))
3065 " with inline copying across machines")))
3069 ;; We don't want the target file to be compressed, so we let-bind
3070 ;; `jka-compr-inhibit' to t.
3092 ;; CCC: What happens to the timestamp when renaming?
3106 (tramp-wait-for-output)
3115 (pop-to-buffer (current-buffer))
3130 "Invoke rcp program to copy.
3141 ;; We cannot invoke `with-parsed-tramp-file-name';
3144 (with-parsed-tramp-file-name filename l
3164 (with-parsed-tramp-file-name newname l
3184 ;; mechanism to parse extra host args.
3187 (when (string-match "\\([^#]*\\)#\\(.*\\)" v1-host)
3188 (setq copy-args (cons "-P" (cons (match-string 2 v1-host) copy-args)))
3189 (setq v1-host (match-string 1 v1-host)))
3197 (when (string-match "\\([^#]*\\)#\\(.*\\)" v2-host)
3198 (setq copy-args (cons "-P" (cons (match-string 2 v2-host) copy-args)))
3199 (setq v2-host (match-string 1 v2-host)))
3244 (message "Transferring %s to %s..." filename newname)
3259 (message "Transferring %s to %s...done" filename newname)
3273 (with-parsed-tramp-file-name dir nil
3287 (with-parsed-tramp-file-name directory nil
3293 (tramp-wait-for-output))))
3298 (with-parsed-tramp-file-name filename nil
3308 ;; CCC: This does not seem to be enough. Something dies when
3313 (with-parsed-tramp-file-name filename nil
3323 ;; Wait for the remote system to return to us...
3325 (tramp-wait-for-output 120)
3328 (error "Failed to recursively delete %s" filename))))
3332 (with-parsed-tramp-file-name default-directory nil
3343 (tramp-wait-for-output))
3346 ;; changes its contents before insertion due to calling
3349 (with-current-buffer
3351 (buffer-string))))
3356 (tramp-wait-for-output)))))
3362 (with-parsed-tramp-file-name file nil
3380 (if (string-match (car (car suffixes)) localname)
3395 (string-match (car suffix) file)
3414 ;; not sure at all that this is the right way to do it, but let's hope
3415 ;; it works for now, and wait for a guru to point out the Right Way to
3436 (when (string-match "^--dired\\s-+" switches)
3439 (with-parsed-tramp-file-name filename nil
3456 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'.
3485 (tramp-wait-for-output))
3487 ;; out. Let's leave the let-binding in for a while to see
3492 ;; changes its contents before insertion due to calling
3495 (with-current-buffer
3497 (buffer-string)))
3498 ;; On XEmacs, we want to call (exchange-point-and-mark t), but
3500 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to
3501 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>.
3506 (tramp-wait-for-output))
3508 ;; Please test it on various XEmacs versions to see if it works.
3509 ;; ;; Another XEmacs specialty follows. What's the right way to do
3518 ;; Continuation of kluge to pacify byte-compiler.
3523 ;; CCC is this the right thing to do?
3526 (with-parsed-tramp-file-name filename nil
3538 Doesn't do anything if the NAME does not start with a drive letter."
3549 If the localname part of the given filename starts with \"/../\" then
3561 (with-parsed-tramp-file-name name nil
3567 ;; supposed to find such a shell on the remote host. Please
3569 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
3570 (let ((uname (match-string 1 localname))
3571 (fname (match-string 2 localname)))
3573 ;; expanded to the local user home directory but to the
3578 (when (and (string-equal uname "~")
3579 (string-match
3590 (tramp-wait-for-output)
3596 ;; expands to "/". Remove this.
3597 (while (string-match "//" localname)
3602 ;; otherwise use backslash. `default-directory' is bound to
3603 ;; "/", because on Windows there would be problems with UNC
3614 ;; old version follows. it uses ".." to cross file handler
3616 ;; ;; Look if localname starts with "/../" construct. If this is
3618 ;; (if (string-match "^/\\.\\./" localname)
3638 "Whether to display output buffer of `shell-command'.
3641 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer)
3644 `tramp-end-of-output', followed by another newline."
3648 (with-parsed-tramp-file-name default-directory nil
3650 (asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
3652 (unless output-buffer
3653 (setq output-buffer
3658 (set-buffer output-buffer)
3660 (unless (bufferp output-buffer)
3661 (setq output-buffer (current-buffer)))
3662 (set-buffer output-buffer)
3665 ;; which gets the output of the (synchronous) Tramp process
3670 tramp-async-proc (start-process (buffer-name output-buffer)
3671 output-buffer "cat")))
3684 '(lambda (process string)
3685 ;; Write the output into the Tramp Process
3689 (insert string))
3690 ;; Hand-over output to asynchronous process.
3692 (string-match
3693 (regexp-quote tramp-end-of-output) string)))
3695 (setq string
3696 (substring string 0 (1- (match-beginning 0)))))
3697 (process-send-string tramp-async-proc string)
3709 (tramp-wait-for-output)))
3712 ;; changes its contents before insertion due to calling
3715 (with-current-buffer
3717 (buffer-string))))
3725 (tramp-wait-for-output)
3729 (with-current-buffer
3731 (buffer-string)))
3737 (tramp-wait-for-output))
3743 (tramp-wait-for-output)
3751 (display-buffer output-buffer)))
3756 (message "tramp-handle-shell-command called with non-tramp directory: `%s'"
3759 (list command output-buffer error-buffer))))
3783 (with-parsed-tramp-file-name filename nil
3785 ;; We used to bind the following as late as possible.
3824 ;; Here is where loc-enc and loc-dec used to be let-bound.
3837 6 "Decoding remote file %s with function %s..."
3841 ;; says that we need to strip tramp_exit_status
3842 ;; line from the output here. Go to point-max,
3854 6 "Decoding remote file %s with command %s..."
3871 (with-parsed-tramp-file-name filename nil
3884 (with-parsed-tramp-file-name filename nil
3894 ;; `insert-file-contents-literally' takes care to avoid calling
3896 ;; propagate that care to the file-local-copy operation.
3927 (with-parsed-tramp-file-name filename nil
3972 ;; File name must be unique. This is ensured with Emacs 22 (see
3978 (when (and (string-match (car x) buffer-file-name)
3987 ;; jka-compr doesn't like auto-saving, so by appending "~" to the
3993 (tramp-subst-strs-in-string
4022 (error "Cannot append to file using tramp (`%s')" filename))
4024 ;; Following part commented out because we don't know what to do about
4025 ;; file locking, and it does not appear to be a problem to ignore it.
4030 ;; (string= lockname filename))
4039 (with-parsed-tramp-file-name filename nil
4045 (trampbuf (get-buffer-create "*tramp output*"))
4047 ;; We use this to save the value of `last-coding-system-used'
4049 ;; we set `last-coding-system-used' to this saved value.
4051 ;; talking to the remote shell or suchlike won't hose this
4063 ;; modtime data to be clobbered from the temp file. We call
4074 ;; filename does not exist (eq modes nil) it has been renamed to
4078 ;; This is a bit lengthy due to the different methods possible for
4106 ;; the base64.el that comes with pgnus-0.84. If
4108 ;; satisfied, it tries to write to a local file
4111 ;; (CALL-PROCESS-REGION can't write to remote
4125 (pop-to-buffer trampbuf)
4126 (error (concat "Cannot write to `%s', local encoding"
4130 ;; writes to remote file. Because this happens on the
4143 6 "Sending data to remote host...")
4144 (tramp-send-string multi-method method user host
4145 (buffer-string))
4146 ;; wait for remote decoding to complete
4154 "Waiting for remote host to process data...")
4156 (tramp-wait-for-output)
4159 (concat "Couldn't write region to `%s',"
4172 (error "Buffer has changed from `%s' to `%s'"
4187 ;; Call down to the real handler.
4188 ;; Because EFS does not play nicely with TRAMP (both systems match a
4189 ;; TRAMP file name) it is needed to disable efs as well as tramp for the
4196 ;; efs-sifn-handler-function to handle any filename with environment
4199 ;; 2) That TRAMP might want to do the same thing.
4206 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp.
4207 ;; First arg specifies the OPERATION, remaining ARGS are passed to the
4221 First arg specifies the OPERATION, second arg is a list of arguments to
4222 pass to the OPERATION."
4241 First arg specifies the OPERATION, second arg is a list of arguments to
4242 pass to the OPERATION."
4255 ;; in order to be signalled if a new primitive appears. This
4256 ;; scenario is needed because there isn't a way to decide by
4261 "Return file name related to OPERATION file primitive.
4262 ARGS are the arguments OPERATION has been called with."
4294 (list 'add-name-to-file 'copy-file 'expand-file-name
4302 ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
4303 ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
4347 Falls back to normal file name handler if no tramp file name handler exists."
4349 ;; (edebug-trace "%s" (with-output-to-string (backtrace)))
4354 (with-parsed-tramp-file-name filename nil
4365 ;; Nothing to do for us.
4369 ;; In Emacs, there is some concurrency due to timers. If a timer
4370 ;; interrupts Tramp and wishes to use the same connection buffer as
4372 ;; buffer. Therefore, we need to make sure that a timer does not use
4376 ;; `tramp-locked' and `tramp-locker'. `tramp-locked' is set to true
4377 ;; (with setq) to indicate a lock. But Tramp also calls itself during
4378 ;; processing of a single file operation, so we need to allow
4380 ;; -- it is let-bound to t during the execution of the current
4388 Together with `tramp-locker', this implements a locking mechanism
4393 Together with `tramp-locked', this implements a locking mechanism
4398 Fall back to normal file name handler if no Tramp handler exists."
4416 Falls back to normal file name handler if no tramp file name handler exists."
4418 ;; (edebug-trace "%s" (with-output-to-string (backtrace)))
4426 "Add tramp file name handler to `file-name-handler-alist'."
4427 (add-to-list 'file-name-handler-alist
4429 ;; If jka-compr is already loaded, move it to the front of
4438 "Add tramp completion file name handler to `file-name-handler-alist'."
4441 ;; user/host name completion shall be bound to `partial-completion-mode'.
4445 (add-to-list 'file-name-handler-alist
4449 ;; If jka-compr is already loaded, move it to the front of
4481 ;;; Interactions with other packages:
4488 (with-parsed-tramp-file-name name nil
4490 (if (or (string-match "\\*" name)
4491 (string-match "\\?" name)
4492 (string-match "\\[.*\\]" name))
4496 ;; in the file name, but since the echo command is going to
4505 ;;- (tramp-wait-for-output))
4508 (tramp-wait-for-output)
4512 (if (string-equal localname bufstr)
4547 ;; If nil, `tramp-completion-run-real-handler' is called (i.e. forwarding to
4554 ;; file name syntax in order to avoid ambiguities, like in XEmacs ...
4561 ((string-match "^/.*:.*:$" file) nil)
4562 ((string-match
4566 (member (match-string 1 file) (mapcar 'car tramp-methods)))
4581 (funcall (symbol-function 'event-to-character)
4585 (funcall (symbol-function 'event-to-character)
4588 (funcall (symbol-function 'event-to-character)
4600 ;; We need to reset `tramp-completion-mode'.
4621 localname) ;; Nothing to complete
4650 (when car (add-to-list
4659 ;; "/ssh:" does not need to be expanded as hostname.
4662 ;; No method/user/host found to be expanded.
4680 ;; I misuse a little bit the tramp-file-name structure in order to handle
4682 ;; Return value is a list of tramp-file-name structures according to possible
4748 (add-to-list 'result
4769 (when (string-match (nth 0 structure) name)
4771 (match-string (nth 1 structure) name)))
4781 (match-string (nth 2 structure) name)))
4783 (match-string (nth 3 structure) name)))
4785 (match-string (nth 4 structure) name))))
4800 (string-match (concat "^" (regexp-quote partial-method)) method)
4804 ;; Compares partial user and host names with possible completions.
4806 "Returns the most expanded string for user and host name completion.
4812 (string-match (concat "^" (regexp-quote partial-host)) host)
4813 (string-equal partial-user (or user partial-user)))
4821 (and user (string-match (concat "^" (regexp-quote partial-user)) user))
4827 (and host (string-match (concat "^" (regexp-quote partial-host)) host))
4837 "Return a list of (user host) tuples allowed to access.
4842 (with-temp-buffer
4857 "Return a (user host) tuple allowed to access.
4866 (narrow-to-region (point) (tramp-point-at-eol))
4868 (setq result (append (list (match-string 3) (match-string 1)))))
4874 "Return a list of (user host) tuples allowed to access.
4879 (with-temp-buffer
4887 "Return a (user host) tuple allowed to access.
4893 (narrow-to-region (point) (tramp-point-at-eol))
4895 (setq result (list nil (match-string 1))))
4903 "Return a list of (user host) tuples allowed to access.
4908 (with-temp-buffer
4916 "Return a (user host) tuple allowed to access.
4922 (narrow-to-region (point) (tramp-point-at-eol))
4924 (setq result (list nil (match-string 1))))
4932 "Return a list of (user host) tuples allowed to access.
4940 (when (string-match regexp (car files))
4941 (push (list nil (match-string 1 (car files))) result))
4946 "Return a list of (user host) tuples allowed to access.
4955 (when (string-match regexp (car files))
4956 (push (list nil (match-string 1 (car files))) result))
4961 "Return a list of (user host) tuples allowed to access.
4966 (with-temp-buffer
4974 "Return a (user host) tuple allowed to access.
4980 (narrow-to-region (point) (tramp-point-at-eol))
4983 (setq result (list nil (match-string 1)))))
4990 ;; For su-alike methods it would be desirable to return "root@localhost"
4995 "Return a list of (user host) tuples allowed to access.
5002 (with-temp-buffer
5010 "Return a (user host) tuple allowed to access.
5016 (narrow-to-region (point) (tramp-point-at-eol))
5018 (setq result (list (match-string 1) "localhost")))
5024 "Return a list of (user host) tuples allowed to access.
5029 (with-temp-buffer
5037 "Return a (user host) tuple allowed to access.
5046 (narrow-to-region (point) (tramp-point-at-eol))
5048 (setq result (list (match-string 3) (match-string 1))))
5064 (with-current-buffer (tramp-get-buffer multi-method method user host)
5066 (tramp-send-string multi-method method user host
5073 (tramp-wait-for-output)
5139 ;; With GNU Emacs, `format-time-string' has an optional
5143 (symbol-function 'format-time-string))))))
5146 (format-time-string "%Y%m%d%H%M.%S" time t)
5147 (format-time-string "%Y%m%d%H%M.%S" time))))
5149 (with-parsed-tramp-file-name file nil
5158 (pop-to-buffer buf)
5162 (with-temp-buffer
5165 (pop-to-buffer (current-buffer))
5186 string-list)
5188 (setq string-list
5193 string-list))
5197 (apply 'concat (reverse string-list)))))
5200 "Get the connection buffer to be used for USER at HOST using METHOD."
5201 (with-current-buffer
5218 (with-current-buffer
5228 is the program to search for, and DIRLIST gives the list of directories
5229 to search. If IGNORE-TILDE is non-nil, directory names starting
5230 with `~' will be ignored.
5234 This function expects to be in the right *tramp* buffer."
5238 ;; `remove' is in CL, and we want to avoid CL dependencies.
5257 (tramp-wait-for-output)
5265 "Sets the remote environment VAR to existing directories from DIRLIST.
5267 so, it is added to the environment variable VAR."
5283 (tramp-wait-for-output)))
5285 ;; -- communication with external shell --
5292 (tramp-message 9 "Finding command to check if file exists")
5306 ;; command we find that seems to work.
5307 ;; The list of commands to try is as follows:
5331 (error "Couldn't find command to check if file exists"))))
5339 (tramp-wait-for-output)
5341 ((string-match "^~root$" (buffer-string))
5354 (when (string-match (car item) shell)
5369 ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
5371 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s"
5373 tramp-end-of-output
5376 (tramp-wait-for-output)
5410 ;; It would be better to use the CL function `find', but
5432 ;; The following functions are actions to be taken when seeing certain
5441 (process-send-string nil (concat (or user (user-login-name))
5461 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5469 (error "%s" (match-string 1)))
5473 Send \"yes\" to remote process on confirmation, abort otherwise.
5476 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5477 (unless (yes-or-no-p (match-string 0))
5481 (process-send-string p (concat "yes" tramp-rsh-end-of-line))
5486 Send \"y\" to remote process on confirmation, abort otherwise.
5489 (pop-to-buffer (tramp-get-buffer multi-method method user host))
5490 (unless (y-or-n-p (match-string 0))
5494 (process-send-string p (concat "y" tramp-rsh-end-of-line))))
5497 "Tell the remote host which terminal type to use.
5498 The terminal type can be configured with `tramp-terminal-type'."
5502 (process-send-string nil (concat tramp-terminal-type
5537 (process-send-string p (concat user tramp-rsh-end-of-line)))
5569 "Wait for output from the shell and perform one action."
5574 (tramp-accept-process-output p 1)
5598 (with-timeout (timeout)
5611 "Wait for output from the shell and perform one action."
5615 (with-timeout (60 (throw 'tramp-action 'timeout))
5617 (tramp-accept-process-output p 1)
5644 ;; Functions to execute when we have seen the remote shell prompt but
5646 ;; might be sent to any shell, not just a Bourne-ish shell. This
5647 ;; means that the commands need to work in all shells. (It is also
5648 ;; okay for some commands to just fail with an error message, but
5654 "Send list of commands to remote host, in order."
5659 (tramp-message 10 "Sending command to remote shell: %s"
5673 password to the remote host.
5681 Please note that it is NOT possible to use this connection method
5682 together with an out-of-band transfer method! You must use an inline
5685 Maybe the different regular expressions need to be tuned.
5687 * Actually, the telnet program as well as the args to be used can be
5691 (error "Cannot use out-of-band method `%s' with telnet connection method"
5736 queried for a password, this function sends the password to the remote
5745 Kludgy feature: if HOST has the form \"xx#yy\", then yy is assumed to
5746 be a port number for ssh, and \"-p yy\" will be added to the list of
5747 arguments, and xx will be used as the host name to connect to.
5749 * Actually, the rsh program to be used can be specified in the
5755 (if (and user (not (string= user "")))
5776 ;; mechanism to parse extra host args.
5777 (when (string-match "\\([^#]*\\)#\\(.*\\)" host)
5778 (setq login-args (cons "-p" (cons (match-string 2 host) login-args)))
5779 (setq real-host (match-string 1 host)))
5789 (p (if (and user (not (string= user "")))
5806 "Open a connection using the `su' program with METHOD.
5808 name must be equal to the local host name or to `localhost'.
5819 (error "Cannot use out-of-band method `%s' with `su' connection method"
5821 (unless (or (string-match (concat "^" (regexp-quote host))
5823 (string= "localhost" host)
5824 (string= "" host))
5826 "Cannot connect to different host `%s' with `su' connection method"
5866 ;; HHH: Not Changed. Multi method. It is not clear to me how this can
5876 This uses a slightly changed file name syntax. The idea is to say
5877 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file
5878 This will use telnet to log in as u1 to h1, then use rsh from there to
5879 log in as u2 to h2."
5912 (tramp-message 9 "Waiting 60s for local shell to come up...")
5916 (pop-to-buffer (buffer-name))
5927 ;; The multi-funcs don't need to do save-match-data, as that
5936 ;; HHH: Changed. Multi method. Don't know how to handle this in the case
5937 ;; of no user name provided. Hack to make it work as it did before:
5938 ;; changed `user' to `(or user (user-login-name))' in the places where
5942 Uses shell COMMAND to issue a `telnet' command to log in as USER to
5943 HOST. You can use percent escapes in COMMAND: `%h' is replaced with
5944 the host name, and `%n' is replaced with an end of line character, as
5955 (process-send-string p cmd)
5959 ;; HHH: Changed. Multi method. Don't know how to handle this in the case
5960 ;; of no user name provided. Hack to make it work as it did before:
5961 ;; changed `user' to `(or user (user-login-name))' in the places where
5965 Uses shell COMMAND to issue an `rlogin' command to log in as USER to
5967 with the user name, `%h' will be replaced with the host name, and `%n'
5968 will be replaced with the value of `tramp-rsh-end-of-line'. You can use
5969 `%%' if you want to use a literal percent character.
5981 (process-send-string p cmd)
5985 ;; HHH: Changed. Multi method. Don't know how to handle this in the case
5986 ;; of no user name provided. Hack to make it work as it did before:
5987 ;; changed `user' to `(or user (user-login-name))' in the places where
5991 Uses shell COMMAND to issue a `su' command to log in as USER on
5993 host currently logged in to.
5997 You can use percent escapes in the COMMAND. `%u' is replaced with the
5998 user name, and `%n' is replaced with the value of
6008 (process-send-string p cmd)
6014 (defun tramp-accept-process-output
6016 "Like `accept-process-output' for Tramp processes.
6017 This is needed in order to hide `last-coding-system-used', which is set
6020 (accept-process-output process timeout timeout-msecs)))
6023 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds.
6024 Expects the output of PROC to be sent to the current buffer. Returns
6025 the string that matched, or nil. Waits indefinitely if TIMEOUT is
6032 ;; to polling for buggy XEmacsen, but oh, well.
6036 (with-timeout (timeout)
6038 (tramp-accept-process-output proc 1)
6045 (tramp-accept-process-output proc 1)
6051 (append-to-buffer
6067 "Wait for the shell prompt to appear from process PROC within TIMEOUT seconds.
6078 Looks at process PROC to see if a shell prompt appears in TIMEOUT
6079 seconds. If not, it produces an error message with the given ERROR-ARGS."
6081 (pop-to-buffer (buffer-name))
6085 "Prompt for a password and send it to the remote end.
6086 Uses PROMPT as a prompt and sends the password to process P."
6089 (process-send-string
6101 ;; variable tramp-current-user will be set to nil.
6118 to set up. METHOD, USER and HOST specify the connection."
6126 ;; It is useful to set the prompt in the following command because
6131 ;; sign. The following command line sets $PS1 to a sane value, and
6143 (format "remote `%s' to come up"
6163 ;; Check whether the remote host suffers from buggy `send-process-string'.
6169 (tramp-message 9 "Checking remote host type for `send-process-string' bug")
6176 ;; Try to set up the coding system correctly.
6177 ;; CCC this can't be the right way to do it. Hm.
6185 ;; Use MULE to select the right EOL convention for communicating
6186 ;; with the process.
6232 ;; the last time we sent a command, to avoid tramp-send-command to send
6239 tramp-end-of-output
6241 (tramp-wait-for-output))
6244 "Prepare a remote shell before being able to work on it.
6247 tries to find an `ls' command which groks the `-n' option, sets the
6248 locale to C and sets up the remote shell search path."
6250 ;; checks if a file exists. This is done because Tramp wants to use
6251 ;; "test foo; echo $?" to check if various conditions hold, and
6255 ;; with buggy /bin/sh implementations will have a working bash or
6260 ;; output of (tramp-find-shell) to show up along with the output of
6263 ;; I can't work out why this is a problem though. The (tramp-wait-for-output)
6266 ;; After much debugging I couldn't find any problem with the implementation
6290 (tramp-wait-for-output)
6293 ;; Tell remote shell to use standard time format, needed for
6294 ;; parsing `ls -l' output.
6297 (tramp-wait-for-output)
6300 (tramp-wait-for-output)
6303 (tramp-wait-for-output)
6304 ;; Unalias ls(1) to work around issues with those silly people who make it
6308 (tramp-wait-for-output)
6316 (tramp-wait-for-output)
6319 (looking-at (format "\n%s\r?\n" (regexp-quote tramp-end-of-output))))
6326 (tramp-wait-for-output)
6329 (tramp-send-string multi-method method user host tramp-uudecode)
6330 (tramp-wait-for-output)
6344 (tramp-send-string
6350 (tramp-wait-for-output)
6351 (tramp-send-string
6354 (format tramp-perl-encode-with-module tramp-remote-perl)
6357 (tramp-wait-for-output)
6359 (tramp-send-string
6365 (tramp-wait-for-output)
6366 (tramp-send-string
6369 (format tramp-perl-decode-with-module tramp-remote-perl)
6372 (tramp-wait-for-output))))
6382 (tramp-wait-for-output)
6388 ;; Find the right encoding/decoding commands to use.
6392 ;; If encoding/decoding command are given, test to see if they work.
6393 ;; CCC: Maybe it would be useful to run the encoder both locally and
6394 ;; remotely to see if they produce the same result.
6397 (magic-string "xyzzy"))
6406 "Checking to see if encoding/decoding commands work on remote host...")
6410 (tramp-shell-quote-argument magic-string) rem-enc rem-dec))
6411 (tramp-wait-for-output)
6412 (unless (looking-at (regexp-quote magic-string))
6418 5 "Checking to see if encoding/decoding commands work on remote host...done"))))
6422 ;; alternative is to use the Perl version of UU encoding. But then
6431 ;; Unices, in particular AIX and Irix. For AIX, you might want to use
6462 The REMOTE-ENCODING should be a string, giving a command accepting a
6463 plain file on standard input and writing the encoded file to standard
6464 output. The REMOTE-DECODING should also be a string, giving a command
6466 file to standard output.
6475 If they are functions, they will be called with two arguments, start
6476 and end of region, and are expected to replace the region contents
6477 with the encoded or decoded results, respectively.")
6493 ;; called remotely with null input and output. This makes
6495 ;; found. Note that we do not redirect stdout to /dev/null,
6497 ;; actually check the output it gives. And also, when
6498 ;; redirecting "mimencode" output to /dev/null, then as root
6519 ;; If the local encoder or decoder is a string, the
6520 ;; corresponding command has to work locally.
6535 ;; CCC: At this point, maybe we should check that the output
6557 (defun tramp-call-local-coding-command (cmd input output)
6562 OUTPUT can be a string (which specifies a filename), or t (which
6563 means standard output and thus the current buffer), or nil (which
6567 (when (and input (not (string-match "%s" cmd)))
6569 (if (eq output t) t nil) ;output
6574 (if (string-match "%s" cmd) (format cmd input) cmd)
6575 (if (stringp output) (concat "> " output) ""))))
6578 "Maybe open a connection to HOST, logging in as USER, using METHOD.
6588 ;; tries to send some data to the remote end. So that's why we
6589 ;; try to send a command from time to time, then look again
6599 (tramp-wait-for-output 10))
6615 "Send the COMMAND to USER at HOST (logged in using METHOD).
6618 If optional seventh arg NEVEROPEN is non-nil, never try to open the
6619 connection. This is meant to be used from
6629 (tramp-insert-with-face 'bold (format "$ %s\n" command))))
6634 (process-send-string proc
6639 "Send command to remote host and wait for success.
6648 (defun tramp-wait-for-output (&optional timeout)
6649 "Wait for output from remote rsh command."
6654 (end-of-output (concat "^"
6655 (regexp-quote tramp-end-of-output)
6657 ;; Algorithm: get waiting output. See if last line contains
6658 ;; end-of-output sentinel. If not, wait a bit and again get
6659 ;; waiting output. Repeat until timeout expires or end-of-output
6661 ;; end-of-output sentinel never appears.
6670 (with-timeout (timeout)
6672 (tramp-accept-process-output proc 1)
6677 (setq found (looking-at end-of-output))))))
6680 (tramp-accept-process-output proc 1)
6685 (setq found (looking-at end-of-output))))))
6687 ;; the end-of-output sentinel.
6698 ;; Add output to debug buffer if appropriate.
6700 (append-to-buffer
6710 (insert "[[Remote prompt `" end-of-output "' not found"
6714 ;; Return value is whether end-of-output sentinel was found.
6720 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST.
6721 Sends `echo $?' along with the COMMAND for checking the exit status. If
6732 (tramp-wait-for-output)
6742 Similar to `tramp-send-command-and-check' but accepts two more arguments
6743 FMT and ARGS which are passed to `error'."
6746 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more
6748 (pop-to-buffer (current-buffer))
6752 ;; to it in one go. (This happens when sending the Perl
6755 (defun tramp-send-string
6756 (multi-method method user host string)
6757 "Send the STRING to USER at HOST using METHOD.
6759 The STRING is expected to use Unix line-endings, but the lines sent to
6765 (error "Can't send string to remote host -- not logged in"))
6771 (tramp-insert-with-face 'bold (format "$ %s\n" string))))
6773 (setq string
6775 (split-string string "\n")
6777 (unless (or (string= string "")
6778 (string-equal (substring string -1) tramp-rsh-end-of-line))
6779 (setq string (concat string tramp-rsh-end-of-line)))
6780 ;; send the string
6783 (end (length string)))
6787 "Sending chunk from %s to %s"
6789 (process-send-string
6790 proc (substring string pos (min (+ pos tramp-chunksize) end)))
6793 (process-send-string proc string))))
6796 "Send EOF to the remote end.
6801 (error "Can't send EOF to remote host -- not logged in"))
6803 ; (process-send-string proc "\^D")))
6817 (while (prog1 (erase-buffer) (tramp-accept-process-output p 0.25))
6822 (tramp-insert-with-face
6825 (defun tramp-mode-string-to-int (mode-string)
6826 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits."
6827 (let* ((mode-chars (string-to-vector mode-string))
6840 (?r (tramp-octal-to-decimal "00400")) (?- 0)
6843 (?w (tramp-octal-to-decimal "00200")) (?- 0)
6846 (?x (tramp-octal-to-decimal "00100"))
6847 (?S (tramp-octal-to-decimal "04000"))
6848 (?s (tramp-octal-to-decimal "04100"))
6853 (?r (tramp-octal-to-decimal "00040")) (?- 0)
6856 (?w (tramp-octal-to-decimal "00020")) (?- 0)
6859 (?x (tramp-octal-to-decimal "00010"))
6860 (?S (tramp-octal-to-decimal "02000"))
6861 (?s (tramp-octal-to-decimal "02010"))
6866 (?r (tramp-octal-to-decimal "00004")) (?- 0)
6869 (?w (tramp-octal-to-decimal "00002")) (?- 0)
6872 (?x (tramp-octal-to-decimal "00001"))
6873 (?T (tramp-octal-to-decimal "01000"))
6874 (?t (tramp-octal-to-decimal "01001"))
6881 Convert file mode bits to string and set virtual device number.
6883 ;; Convert file mode bits to string.
6899 (let ((string (tramp-make-tramp-file-name multi-method method user host "")))
6900 (unless (assoc string tramp-devices)
6901 (add-to-list 'tramp-devices
6902 (list string (length tramp-devices))))
6903 (list -1 (nth 1 (assoc string tramp-devices)))))
6906 "Turn an integer representing a file mode into an ls(1)-like string."
6921 "Convert a permission bitset into a string.
6933 (defun tramp-decimal-to-octal (i)
6934 "Return a string consisting of the octal digits of I.
6936 (cond ((< i 0) (error "Cannot convert negative number to octal"))
6937 ((not (integerp i)) (error "Cannot convert non-integer to octal"))
6939 (t (concat (tramp-decimal-to-octal (/ i 8))
6940 (number-to-string (% i 8))))))
6943 ;;(defun tramp-octal-to-decimal (ostr)
6944 ;; "Given a string of octal digits, return a decimal number."
6946 ;; ((string= "" ostr) 0)
6952 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest)))))))
6953 ;; Kudos to Gerd Moellmann for this suggestion.
6954 (defun tramp-octal-to-decimal (ostr)
6955 "Given a string of octal digits, return a decimal number."
6957 ;; `save-match' is in `tramp-mode-string-to-int' which calls this.
6958 (unless (string-match "\\`[0-7]*\\'" x)
6959 (error "Non-octal junk in string `%s'" x))
6960 (string-to-number ostr 8)))
6962 (defun tramp-shell-case-fold (string)
6963 "Converts STRING to shell glob pattern which ignores case."
6969 string
6985 (string-match tramp-file-name-regexp name)))
6987 ;; HHH: Changed. Used to assign the return value of (user-login-name)
6988 ;; to the `user' part of the structure if a user name was not
6995 (let* ((match (string-match (nth 0 tramp-file-name-structure) name))
6998 (if match (match-string (nth 1 tramp-file-name-structure) name)
7000 (string-match
7003 (match-string (nth 1 tramp-multi-file-name-structure) name))))
7010 (let ((user (match-string (nth 2 tramp-file-name-structure) name))
7011 (host (match-string (nth 3 tramp-file-name-structure) name))
7012 (localname (match-string (nth 4 tramp-file-name-structure) name)))
7021 "Look up the right method to use in `tramp-default-method-alist'."
7027 (when (and (string-match (or (nth 0 item) "") (or host ""))
7028 (string-match (or (nth 1 item) "") (or user "")))
7034 "Return the right method string to use.
7053 (unless (string-match (format regexp hop-regexp) name)
7055 (setq method (match-string method-index name))
7056 (setq hops (match-string hops-index name))
7059 (setq localname (match-string localname-index name))
7061 (while (string-match hop-regexp hops index)
7064 (cons (match-string hop-method-index hops) hop-methods))
7066 (cons (match-string hop-user-index hops) hop-users))
7068 (cons (match-string hop-host-index hops) hop-hosts))))
7089 ;; with this when USER is nil?
7110 "Create a file name suitable to be passed to `rcp' and workalikes."
7122 ;; Variables local to connection.
7166 (with-current-buffer (tramp-get-buffer multi-method method user host)
7177 (with-current-buffer (tramp-get-buffer multi-method method user host)
7225 ;; Auto saving to a special directory.
7235 "Returns OPERATION if it is the one to be checked"
7256 "Set permissions of autosaved remote files to the original permissions."
7265 ;; auto-saved file belonging to another original file. This could
7268 (or (file-modes bfn) (tramp-octal-to-decimal "0600"))))))
7279 (defun tramp-subst-strs-in-string (alist string)
7280 "Replace all occurrences of the string FROM with TO in STRING.
7286 (to (cdr pr)))
7287 (while (string-match (regexp-quote from) string)
7288 (setq string (replace-match to t t string)))
7290 string))
7292 (defun tramp-insert-with-face (face string)
7293 "Insert text with a specific face."
7295 (insert string)
7332 "Clear password cache for connection related to current-buffer."
7347 ;; Pacify byte-compiler with `symbol-function'.
7353 (fboundp 'time-to-seconds))
7354 (funcall (symbol-function 'time-to-seconds)
7362 ;; time-to-seconds and subtract-time
7371 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
7389 (defun tramp-split-string (string pattern)
7390 "Like `split-string' but omit empty strings.
7391 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\").
7396 If you want to use it for something else, you'll have to check whether
7398 (delete "" (split-string string pattern)))
7416 ;; does not deal well with newline characters. Newline is replaced by
7417 ;; backslash newline. But if, say, the string `a backslash newline b'
7418 ;; is passed to a shell, the shell will expand this into "ab",
7420 ;; It does not appear to be possible to make the function
7421 ;; `shell-quote-argument' work with newlines without making it
7429 ;; This function should produce a string which is grokked by a Unix
7434 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this
7435 ;; function to work with Bourne-like shells.
7441 "Similar to `shell-quote-argument', but groks newlines.
7448 (string= (substring result 0 2) "\\~"))
7450 (while (string-match nl result)
7456 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay
7461 ;; ;; connection to help it's dired process. Not that I have any real
7462 ;; ;; idea *why* this is helpful to dired.
7464 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :)
7469 ;; ;; not to call defadvice unless it's necessary. How do we find out whether
7473 ;; "Cause efs-ftp-path to fail when the path is a TRAMP localname."
7479 ;; This means that Emacs wants to expand wildcards if
7487 (when (string-match "\\[" tramp-prefix-format)
7492 ;; need to be expanded at all.
7494 (if (string-match "[[*?]" (tramp-file-name-localname v))
7518 "Submit a bug report to the TRAMP developers."
7524 tramp-bug-report-address ; to-address
7537 tramp-auto-save-directory ; vars to dump
7557 tramp-end-of-output
7593 possibly can about the problem, what you did to cause it and what the
7596 If you can give a simple set of instructions to make this bug happen
7600 Another useful thing to do is to put (setq tramp-debug-buffer t) in
7601 the ~/.emacs file and to repeat the bug. Then, include the contents
7612 (val (with-current-buffer reporter-eval-buffer
7615 ;; There are characters to be masked.
7617 (string-match
7619 (with-current-buffer reporter-eval-buffer
7620 (set varsym (concat "(base64-decode-string \""
7621 (base64-encode-string val)
7627 ;; Remove string quotation.
7631 "\\((base64-decode-string \\)" "\\\\" ;; \2 \
7636 (insert " ;; variable encoded due to non-printable characters\n"))
7639 ;; Reset VARSYM to old value.
7640 (with-current-buffer reporter-eval-buffer
7670 (when (string-match tramp-buf-regexp (buffer-name b)) b))
7676 (switch-to-buffer (list-buffers-noselect nil))
7688 The buffer(s) above will be appended to this message. If you don't want
7689 to append a buffer because it contains sensible data, or because the buffer
7697 Please note that you have set `tramp-verbose' to a value greater than 9.
7705 (if (y-or-n-p "Do you want to append the buffer(s)? ")
7709 (switch-to-buffer curbuf)
7749 ;; Make sure that we get integration with the VC package.
7750 ;; When it is loaded, we need to pull in the integration module.
7764 ;; This should be implemented via a general mechanism to add
7768 ;; Another approach is to read a netrc file like ~/.authinfo
7774 ;; For reading files from the remote host, we can just parse the output
7775 ;; of `od -b'. For writing files to the remote host, we construct
7777 ;; and which writes the right bytes to the file. We can use printf(1)
7781 ;; two commands to write a null byte:
7787 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't
7789 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using
7796 ;; * When logging in, keep looking for questions according to an alist
7799 ;; * Running CVS remotely doesn't appear to work right. It thinks
7803 ;; * Don't use globbing for directories with many files, as this is
7804 ;; likely to produce long command lines, and some shells choke on
7812 ;; * How to deal with MULE in `insert-file-contents' and `write-region'?
7818 ;; * Also allow to omit user names when doing multi-hop. Not sure yet
7819 ;; what the user names should default to, though.
7824 ;; Of course, this has issues with usability (stale cache bites)
7827 ;; transfer method to use. (Greg Stark)
7832 ;; to do it?
7833 ;; * Make it work for XEmacs 20, which is missing `with-timeout'.
7836 ;; * Change applicable functions to pass a struct tramp-file-name rather
7844 ;; then look if it's the right version (with `perl -v').
7846 ;; gets confused about the file locking status. Try to find out why
7848 ;; * Change `copy-file' to grok the case where the filename handler
7855 ;; ** If `partial-completion-mode' isn't loaded, "/foo:bla" tries to
7856 ;; connect to host "blabla" already if that host is unique. No idea
7857 ;; how to suppress. Maybe not an essential problem.
7858 ;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'.
7862 ;; ** Decide whiche files to take for searching user/host names depending on