annotate lisp/net/tramp-fish.el @ 105768:192f524e5a85

*** empty log message ***
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 26 Oct 2009 09:29:12 +0000
parents f92b20f3ef80
children ae9f17f9fa46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1 ;;; tramp-fish.el --- Tramp access functions for FISH protocol
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 99616
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
4
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
5 ;; Author: Michael Albinus <michael.albinus@gmx.de>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
6 ;; Keywords: comm, processes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
7
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
9
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94403
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94403
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94403
diff changeset
13 ;; (at your option) any later version.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
14
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
18 ;; GNU General Public License for more details.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94403
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23 ;;; Commentary:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25 ;; Access functions for FIles transferred over SHell protocol from Tramp.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 ;; FISH is a protocol developped for the GNU Midnight Commander
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28 ;; <https://savannah.gnu.org/projects/mc>. A client connects to a
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29 ;; remote host via ssh (or rsh, shall be configurable), and starts
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
30 ;; there a fish server via the command "start_fish_server". All
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
31 ;; commands from the client have the form "#FISH_COMMAND\n" (always
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32 ;; one line), followed by equivalent shell commands in case there is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 ;; no fish server running.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
34
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
35 ;; The fish server (or the equivalent shell commands) must return the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
36 ;; response, which is finished by a line "### xxx <optional text>\n".
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 ;; "xxx" stands for 3 digits, representing a return code. Return
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 ;; codes "# 000" and "# 001" are reserved for fallback implementation
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
39 ;; with native shell commands; they are not used inside the server. See
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40 ;; <http://cvs.savannah.gnu.org/viewcvs/mc/vfs/README.fish?root=mc&view=markup>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41 ;; for details of original specification.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
42
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 ;; The GNU Midnight Commander implements the original fish protocol
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44 ;; version 0.0.2. The KDE Konqueror has its own implementation, which
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45 ;; can be found at
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46 ;; <http://websvn.kde.org/branches/KDE/3.5/kdebase/kioslave/fish>. It
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 ;; implements an extended protocol version 0.0.3. Additionally, it
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
48 ;; provides a fish server implementation in Perl (which is the only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
49 ;; implementation I've heard of). The following command reference is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 ;; based on that implementation.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
51
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
52 ;; All commands return either "### 2xx\n" (OK) or "### 5xx <optional text>\n"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53 ;; (NOK). Return codes are mentioned only if they are different from this.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
54 ;; Spaces in any parameter must be escaped by "\ ".
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56 ;; Command/Return Code Comment
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
57 ;;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
58 ;; #FISH initial connection, not used
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
59 ;; in .fishsrv.pl
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
60 ;; ### 100 transfer fish server missing server, or wrong checksum
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
61 ;; version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 ;; #VER a.b.c <commands requested>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64 ;; VER x.y.z <commands offered> .fishsrv.pl response is not uptodate
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
66 ;; #PWD
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
67 ;; /path/to/file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
68
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
69 ;; #CWD /some/path
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
70
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
71 ;; #COPY /path/a /path/b version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
72
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
73 ;; #RENAME /path/a /path/b
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
74
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
75 ;; #SYMLINK /path/a /path/b
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
76
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
77 ;; #LINK /path/a /path/b
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
79 ;; #DELE /some/path
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
80
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
81 ;; #MKD /some/path
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
83 ;; #RMD /some/path
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
84
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
85 ;; #CHOWN user /file/name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
86
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
87 ;; #CHGRP group /file/name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
88
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
89 ;; #CHMOD 1234 file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
90
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
91 ;; #READ <offset> <size> /path/and/filename
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
92 ;; ### 291 successful exit when reading
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
93 ;; ended at eof
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
94 ;; ### 292 successful exit when reading
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
95 ;; did not end at eof
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
97 ;; #WRITE <offset> <size> /path/and/filename
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
98
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
99 ;; #APPEND <size> /path/and/filename version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
101 ;; #LIST /directory
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102 ;; <number of entries> version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
103 ;; ### 100 version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
104 ;; P<unix permissions> <owner>.<group>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
105 ;; S<size>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106 ;; d<3-letters month name> <day> <year or HH:MM>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
107 ;; D<year> <month> <day> <hour> <minute> <second>[.1234]
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
108 ;; E<major-of-device>,<minor>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
109 ;; :<filename>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110 ;; L<filename symlink points to>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111 ;; M<mimetype> version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
112 ;; <blank line to separate items>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 ;; #STAT /file version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
115 ;; like #LIST except for directories
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116 ;; <number of entries>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
117 ;; ### 100
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118 ;; P<unix permissions> <owner>.<group>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
119 ;; S<size>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
120 ;; d<3-letters month name> <day> <year or HH:MM>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121 ;; D<year> <month> <day> <hour> <minute> <second>[.1234]
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122 ;; E<major-of-device>,<minor>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
123 ;; :<filename>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
124 ;; L<filename symlink points to>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
125 ;; <blank line to separate items>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
126
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127 ;; #RETR /some/name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 ;; <filesize>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129 ;; ### 100
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 ;; <binary data> exactly filesize bytes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 ;; ### 200 with no preceding newline
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
133 ;; #STOR <size> /file/name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
134 ;; ### 100
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
135 ;; <data> exactly size bytes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
136 ;; ### 001 partial success
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
137
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
138 ;; #EXEC <command> <tmpfile> version 0.0.3 only
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
139 ;; <tmpfile> must not exists. It contains the output of <command>.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 ;; It can be retrieved afterwards. Last line is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
141 ;; ###RESULT: <returncode>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
143 ;; This implementation is meant as proof of the concept, whether there
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
144 ;; is a better performance compared with the native ssh method. It
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
145 ;; looks like the file information retrieval is slower, especially the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
146 ;; #LIST command. On the other hand, the file contents transmission
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147 ;; seems to perform better than other inline methods, because there is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148 ;; no need for data encoding/decoding, and it supports the APPEND
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
149 ;; parameter of `write-region'. Transfer of binary data fails due to
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
150 ;; Emacs' process input/output handling.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
151
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
152
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
153 ;;; Code:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
154
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
155 (require 'tramp)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
156 (require 'tramp-cache)
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
157 (require 'tramp-compat)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
158
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
159 ;; Define FISH method ...
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
160 (defcustom tramp-fish-method "fish"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
161 "*Method to connect via FISH protocol."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
162 :group 'tramp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
163 :type 'string)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
164
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
165 ;; ... and add it to the method list.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
166 (add-to-list 'tramp-methods (cons tramp-fish-method nil))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
167
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
168 ;; Add a default for `tramp-default-user-alist'. Default is the local user.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169 (add-to-list 'tramp-default-user-alist
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
170 `(,tramp-fish-method nil ,(user-login-name)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
171
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
172 ;; Add completion function for FISH method.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
173 (tramp-set-completion-function
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
174 tramp-fish-method tramp-completion-function-alist-ssh)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
175
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
176 (defconst tramp-fish-continue-prompt-regexp "^### 100.*\n"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
177 "FISH return code OK.")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 ;; It cannot be a defconst, occasionally we bind it locally.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
180 (defvar tramp-fish-ok-prompt-regexp "^### 200\n"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
181 "FISH return code OK.")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
182
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 (defconst tramp-fish-error-prompt-regexp "^### \\(4\\|5\\)[0-9]+.*\n"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
184 "Regexp for possible error strings of FISH servers.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185 Used instead of analyzing error codes of commands.")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 (defcustom tramp-fish-start-fish-server-command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
188 (concat "stty intr \"\" quit \"\" erase \"\" kill \"\" eof \"\" eol \"\" eol2 \"\" swtch \"\" start \"\" stop \"\" susp \"\" rprnt \"\" werase \"\" lnext \"\" flush \"\"; "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
189 "perl .fishsrv.pl "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
190 "`grep 'ARGV\\[0\\]' .fishsrv.pl | "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 "sed -e 's/^[^\"]*\"//' -e 's/\"[^\"]*$//'`; "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192 "exit")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193 "*Command to connect via FISH protocol."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 :group 'tramp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 :type 'string)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 ;; New handlers should be added here.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 (defconst tramp-fish-file-name-handler-alist
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 '(
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 ;; `access-file' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 (add-name-to-file . tramp-fish-handle-add-name-to-file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 ;; `byte-compiler-base-file-name' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 (copy-file . tramp-fish-handle-copy-file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 (delete-directory . tramp-fish-handle-delete-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 (delete-file . tramp-fish-handle-delete-file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 ;; `diff-latest-backup-file' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 (directory-file-name . tramp-handle-directory-file-name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 (directory-files . tramp-handle-directory-files)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 (directory-files-and-attributes . tramp-fish-handle-directory-files-and-attributes)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 ;; `dired-call-process' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 ;; `dired-compress-file' performed by default handler
103530
bd92ac143136 * net/tramp-fish.el (tramp-fish-file-name-handler-alist): Add handler
Michael Albinus <michael.albinus@gmx.de>
parents: 102852
diff changeset
212 (dired-uncache . tramp-handle-dired-uncache)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 (expand-file-name . tramp-fish-handle-expand-file-name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 ;; `file-accessible-directory-p' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215 (file-attributes . tramp-fish-handle-file-attributes)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 (file-directory-p . tramp-fish-handle-file-directory-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
217 (file-executable-p . tramp-fish-handle-file-executable-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 (file-exists-p . tramp-fish-handle-file-exists-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 (file-local-copy . tramp-fish-handle-file-local-copy)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 (file-remote-p . tramp-handle-file-remote-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 (file-modes . tramp-handle-file-modes)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 (file-name-all-completions . tramp-fish-handle-file-name-all-completions)
99616
9dfb3eaac831 * net/tramp-fish.el (tramp-fish-file-name-handler-alist): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 97036
diff changeset
223 (file-name-as-directory . tramp-handle-file-name-as-directory)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 (file-name-completion . tramp-handle-file-name-completion)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
225 (file-name-directory . tramp-handle-file-name-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
226 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227 ;; `file-name-sans-versions' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 (file-newer-than-file-p . tramp-fish-handle-file-newer-than-file-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
229 (file-ownership-preserved-p . ignore)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
230 (file-readable-p . tramp-fish-handle-file-readable-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
231 (file-regular-p . tramp-handle-file-regular-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 (file-symlink-p . tramp-handle-file-symlink-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
233 ;; `file-truename' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
234 (file-writable-p . tramp-fish-handle-file-writable-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235 (find-backup-file-name . tramp-handle-find-backup-file-name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236 ;; `find-file-noselect' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237 ;; `get-file-buffer' performed by default handler
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238 (insert-directory . tramp-fish-handle-insert-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239 (insert-file-contents . tramp-fish-handle-insert-file-contents)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
240 (load . tramp-handle-load)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 (make-directory . tramp-fish-handle-make-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
242 (make-directory-internal . tramp-fish-handle-make-directory-internal)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
243 (make-symbolic-link . tramp-fish-handle-make-symbolic-link)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
244 (rename-file . tramp-fish-handle-rename-file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
245 (set-file-modes . tramp-fish-handle-set-file-modes)
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
246 (set-file-times . tramp-fish-handle-set-file-times)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
247 (set-visited-file-modtime . ignore)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
248 (shell-command . tramp-handle-shell-command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
249 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
250 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
251 (vc-registered . ignore)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
252 (verify-visited-file-modtime . ignore)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
253 (write-region . tramp-fish-handle-write-region)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
254 (executable-find . tramp-fish-handle-executable-find)
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
255 (start-file-process . ignore)
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
256 (process-file . tramp-fish-handle-process-file)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
257 )
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
258 "Alist of handler functions for Tramp FISH method.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
259 Operations not mentioned here will be handled by the default Emacs primitives.")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
260
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
261 (defun tramp-fish-file-name-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
262 "Check if it's a filename for FISH protocol."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
263 (let ((v (tramp-dissect-file-name filename)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
264 (string= (tramp-file-name-method v) tramp-fish-method)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
265
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
266 (defun tramp-fish-file-name-handler (operation &rest args)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
267 "Invoke the FISH related OPERATION.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
268 First arg specifies the OPERATION, second arg is a list of arguments to
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
269 pass to the OPERATION."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
270 (let ((fn (assoc operation tramp-fish-file-name-handler-alist)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
271 (if fn
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
272 (save-match-data (apply (cdr fn) args))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
273 (tramp-run-real-handler operation args))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
274
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
275 (add-to-list 'tramp-foreign-file-name-handler-alist
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
276 (cons 'tramp-fish-file-name-p 'tramp-fish-file-name-handler))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
277
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
278
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
279 ;; File name primitives
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
280
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
281 (defun tramp-fish-handle-add-name-to-file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
282 (filename newname &optional ok-if-already-exists)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
283 "Like `add-name-to-file' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
284 (unless (tramp-equal-remote filename newname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
285 (with-parsed-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
286 (if (tramp-tramp-file-p filename) filename newname) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
287 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
288 v 'file-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
289 "add-name-to-file: %s"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
290 "only implemented for same method, same user, same host")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
291 (with-parsed-tramp-file-name filename v1
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
292 (with-parsed-tramp-file-name newname v2
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
293 (when (and (not ok-if-already-exists)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
294 (file-exists-p newname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
295 (not (numberp ok-if-already-exists))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 (y-or-n-p
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
297 (format
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
298 "File %s already exists; make it a new name anyway? "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
299 newname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
300 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
301 v2 'file-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
302 "add-name-to-file: file %s already exists" newname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
303 (tramp-flush-file-property v2 v2-localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
304 (unless (tramp-fish-send-command-and-check
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
305 v1 (format "#LINK %s %s" v1-localname v2-localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
306 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
307 v1 'file-error "Error with add-name-to-file %s" newname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
308
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309 (defun tramp-fish-handle-copy-file
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
310 (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 "Like `copy-file' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
312 (tramp-fish-do-copy-or-rename-file
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
313 'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314
105352
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
315 (defun tramp-fish-handle-delete-directory (directory &optional recursive)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
316 "Like `delete-directory' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
317 (when (file-exists-p directory)
105352
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
318 (if recursive
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
319 (mapc
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
320 (lambda (file)
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
321 (if (file-directory-p file)
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
322 (delete-directory file recursive)
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
323 (delete-file file)))
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
324 ;; We do not want to delete "." and "..".
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
325 (directory-files
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
326 directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
f92b20f3ef80 * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
Michael Albinus <michael.albinus@gmx.de>
parents: 103530
diff changeset
327 (with-parsed-tramp-file-name
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
328 (directory-file-name (expand-file-name directory)) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
329 (tramp-flush-directory-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
330 (tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
331
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
332 (defun tramp-fish-handle-delete-file (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
333 "Like `delete-file' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
334 (when (file-exists-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
335 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
336 (tramp-flush-file-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
337 (tramp-fish-send-command-and-check v (format "#DELE %s" localname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
338
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
339 (defun tramp-fish-handle-directory-files-and-attributes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
340 (directory &optional full match nosort id-format)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
341 "Like `directory-files-and-attributes' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
342 (mapcar
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
343 (lambda (x)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
344 ;; We cannot call `file-attributes' for backward compatibility reasons.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
345 ;; Its optional parameter ID-FORMAT is introduced with Emacs 22.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
346 (cons x (tramp-fish-handle-file-attributes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
347 (if full x (expand-file-name x directory)) id-format)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
348 (directory-files directory full match nosort)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
349
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
350 (defun tramp-fish-handle-expand-file-name (name &optional dir)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
351 "Like `expand-file-name' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
352 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
353 (setq dir (or dir default-directory "/"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
354 ;; Unless NAME is absolute, concat DIR and NAME.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
355 (unless (file-name-absolute-p name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
356 (setq name (concat (file-name-as-directory dir) name)))
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
357 ;; If NAME is not a Tramp file, run the real handler,
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
358 (if (or (tramp-completion-mode-p) (not (tramp-tramp-file-p name)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
359 (tramp-drop-volume-letter
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
360 (tramp-run-real-handler 'expand-file-name (list name nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
361 ;; Dissect NAME.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
362 (with-parsed-tramp-file-name name nil
94403
f3fa6258dd50 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 93079
diff changeset
363 (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
364 (setq localname (concat "~/" localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
365 ;; Tilde expansion if necessary.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
366 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
367 (let ((uname (match-string 1 localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
368 (fname (match-string 2 localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
369 ;; We cannot apply "~user/", because this is not supported
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
370 ;; by the FISH protocol.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
371 (unless (string-equal uname "~")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
372 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
373 v 'file-error "Tilde expansion not supported for %s" name))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
374 (setq uname
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
375 (with-connection-property v uname
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
376 (tramp-fish-send-command-and-check v "#PWD")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
377 (with-current-buffer (tramp-get-buffer v)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
378 (goto-char (point-min))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
379 (buffer-substring (point) (tramp-compat-line-end-position)))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
380 (setq localname (concat uname fname))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
381 ;; There might be a double slash, for example when "~/"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
382 ;; expands to "/". Remove this.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
383 (while (string-match "//" localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
384 (setq localname (replace-match "/" t t localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
385 ;; No tilde characters in file name, do normal
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
386 ;; expand-file-name (this does "/./" and "/../"). We bind
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
387 ;; `directory-sep-char' here for XEmacs on Windows, which
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
388 ;; would otherwise use backslash. `default-directory' is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
389 ;; bound, because on Windows there would be problems with UNC
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
390 ;; shares or Cygwin mounts.
93079
4af1d1ce512c * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Let-bind
Michael Albinus <michael.albinus@gmx.de>
parents: 91487
diff changeset
391 (let ((directory-sep-char ?/)
4af1d1ce512c * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Let-bind
Michael Albinus <michael.albinus@gmx.de>
parents: 91487
diff changeset
392 (default-directory (tramp-compat-temporary-file-directory)))
4af1d1ce512c * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Let-bind
Michael Albinus <michael.albinus@gmx.de>
parents: 91487
diff changeset
393 (tramp-make-tramp-file-name
4af1d1ce512c * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Let-bind
Michael Albinus <michael.albinus@gmx.de>
parents: 91487
diff changeset
394 method user host
4af1d1ce512c * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Let-bind
Michael Albinus <michael.albinus@gmx.de>
parents: 91487
diff changeset
395 (tramp-drop-volume-letter
94403
f3fa6258dd50 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 93079
diff changeset
396 (tramp-run-real-handler
f3fa6258dd50 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 93079
diff changeset
397 'expand-file-name (list localname))))))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
398
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
399 (defun tramp-fish-handle-file-attributes (filename &optional id-format)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
400 "Like `file-attributes' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
401 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
402 (with-file-property v localname (format "file-attributes-%s" id-format)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
403 (cdr (car (tramp-fish-get-file-entries v localname nil))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
404
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
405 (defun tramp-fish-handle-file-directory-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
406 "Like `file-directory-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
407 (let ((attributes (file-attributes filename)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
408 (and attributes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
409 (or (string-match "d" (nth 8 attributes))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
410 (and (file-symlink-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
411 (with-parsed-tramp-file-name filename nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
412 (file-directory-p
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
413 (tramp-make-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
414 method user host (nth 0 attributes))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
415 t)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
416
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
417 (defun tramp-fish-handle-file-exists-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
418 "Like `file-exists-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
419 (and (file-attributes filename) t))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
420
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
421 (defun tramp-fish-handle-file-executable-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
422 "Like `file-executable-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
423 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
424 (with-file-property v localname "file-executable-p"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
425 (when (file-exists-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
426 (let ((mode-chars (string-to-vector (nth 8 (file-attributes filename))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
427 (home-directory
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
428 (tramp-make-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
429 method user host
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
430 (tramp-get-connection-property v "home-directory" nil))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
431 (or (and (char-equal (aref mode-chars 3) ?x)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
432 (equal (nth 2 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
433 (nth 2 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
434 (and (char-equal (aref mode-chars 6) ?x)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
435 (equal (nth 3 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
436 (nth 3 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
437 (char-equal (aref mode-chars 9) ?x)))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
438
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
439 (defun tramp-fish-handle-file-readable-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
440 "Like `file-readable-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
441 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
442 (with-file-property v localname "file-readable-p"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
443 (when (file-exists-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
444 (let ((mode-chars (string-to-vector (nth 8 (file-attributes filename))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
445 (home-directory
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
446 (tramp-make-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
447 method user host
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
448 (tramp-get-connection-property v "home-directory" nil))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
449 (or (and (char-equal (aref mode-chars 1) ?r)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
450 (equal (nth 2 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
451 (nth 2 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
452 (and (char-equal (aref mode-chars 4) ?r)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
453 (equal (nth 3 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
454 (nth 3 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
455 (char-equal (aref mode-chars 7) ?r)))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
456
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
457 (defun tramp-fish-handle-file-writable-p (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
458 "Like `file-writable-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
459 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
460 (with-file-property v localname "file-writable-p"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
461 (if (not (file-exists-p filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
462 ;; If file doesn't exist, check if directory is writable.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
463 (and (file-directory-p (file-name-directory filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
464 (file-writable-p (file-name-directory filename)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
465 ;; Existing files must be writable.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
466 (let ((mode-chars (string-to-vector (nth 8 (file-attributes filename))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
467 (home-directory
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
468 (tramp-make-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
469 method user host
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
470 (tramp-get-connection-property v "home-directory" nil))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
471 (or (and (char-equal (aref mode-chars 2) ?w)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
472 (equal (nth 2 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
473 (nth 2 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
474 (and (char-equal (aref mode-chars 5) ?w)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
475 (equal (nth 3 (file-attributes filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
476 (nth 3 (file-attributes home-directory))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
477 (char-equal (aref mode-chars 8) ?w)))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
478
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
479 (defun tramp-fish-handle-file-local-copy (filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
480 "Like `file-local-copy' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
481 (with-parsed-tramp-file-name (expand-file-name filename) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
482 (unless (file-exists-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
483 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
484 v 'file-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
485 "Cannot make local copy of non-existing file `%s'" filename))
85041
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
486 (let ((tmpfile (tramp-compat-make-temp-file filename)))
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
487 (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
488 (when (tramp-fish-retrieve-data v)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
489 ;; Save file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
490 (with-current-buffer (tramp-get-buffer v)
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
491 (write-region (point-min) (point-max) tmpfile))
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
492 (tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
493 tmpfile))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
494
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
495 ;; This function should return "foo/" for directories and "bar" for
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
496 ;; files.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
497 (defun tramp-fish-handle-file-name-all-completions (filename directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
498 "Like `file-name-all-completions' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
499 (all-completions
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
500 filename
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
501 (with-parsed-tramp-file-name (expand-file-name directory) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
502 (with-file-property v localname "file-name-all-completions"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
503 (save-match-data
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
504 (let ((entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
505 (with-file-property v localname "file-entries"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
506 (tramp-fish-get-file-entries v localname t))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
507 (mapcar
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
508 (lambda (x)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
509 (list
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
510 (if (string-match "d" (nth 9 x))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
511 (file-name-as-directory (nth 0 x))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
512 (nth 0 x))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
513 entries)))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
514
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
515 (defun tramp-fish-handle-file-newer-than-file-p (file1 file2)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
516 "Like `file-newer-than-file-p' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
517 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
518 ((not (file-exists-p file1)) nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
519 ((not (file-exists-p file2)) t)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
520 (t (tramp-time-less-p (nth 5 (file-attributes file2))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
521 (nth 5 (file-attributes file1))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
522
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
523 (defun tramp-fish-handle-insert-directory
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
524 (filename switches &optional wildcard full-directory-p)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
525 "Like `insert-directory' for Tramp files.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
526 WILDCARD and FULL-DIRECTORY-P are not handled."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
527 (setq filename (expand-file-name filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
528 (when (file-directory-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
529 ;; This check is a little bit strange, but in `dired-add-entry'
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
530 ;; this function is called with a non-directory ...
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
531 (setq filename (file-name-as-directory filename)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
532
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
533 (with-parsed-tramp-file-name filename nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
534 (tramp-flush-file-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
535 (save-match-data
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
536 (let ((entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
537 (with-file-property v localname "file-entries"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
538 (tramp-fish-get-file-entries v localname t))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
539
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
540 ;; Sort entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
541 (setq entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
542 (sort
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
543 entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
544 (lambda (x y)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
545 (if (string-match "t" switches)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
546 ;; Sort by date.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
547 (tramp-time-less-p (nth 6 y) (nth 6 x))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
548 ;; Sort by name.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
549 (string-lessp (nth 0 x) (nth 0 y))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
550
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
551 ;; Print entries.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
552 (mapcar
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
553 (lambda (x)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
554 (insert
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
555 (format
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
556 "%10s %3d %-8s %-8s %8s %s %s%s\n"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
557 (nth 9 x) ; mode
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
558 1 ; hardlinks
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
559 (nth 3 x) ; uid
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
560 (nth 4 x) ; gid
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
561 (nth 8 x) ; size
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
562 (format-time-string
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
563 (if (tramp-time-less-p
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
564 (tramp-time-subtract (current-time) (nth 6 x))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
565 tramp-half-a-year)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
566 "%b %e %R"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
567 "%b %e %Y")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
568 (nth 6 x)) ; date
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
569 (nth 0 x) ; file name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
570 (if (stringp (nth 1 x)) (format " -> %s" (nth 1 x)) "")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
571 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
572 (beginning-of-line))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
573 entries)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
574
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
575 (defun tramp-fish-handle-insert-file-contents
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
576 (filename &optional visit beg end replace)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
577 "Like `insert-file-contents' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
578 (barf-if-buffer-read-only)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
579 (when visit
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
580 (setq buffer-file-name (expand-file-name filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
581 (set-visited-file-modtime)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
582 (set-buffer-modified-p nil))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
583
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
584 (with-parsed-tramp-file-name filename nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
585 (if (not (file-exists-p filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
586 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
587 v 'file-error "File %s not found on remote host" filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
588
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
589 (let ((point (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
590 size)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
591 (tramp-message v 4 "Fetching file %s..." filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
592 (when (tramp-fish-retrieve-data v)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
593 ;; Insert file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
594 (insert
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
595 (with-current-buffer (tramp-get-buffer v)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
596 (let ((beg (or beg (point-min)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
597 (end (min (or end (point-max)) (point-max))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
598 (setq size (- end beg))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
599 (buffer-substring beg end))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
600 (goto-char point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
601 (tramp-message v 4 "Fetching file %s...done" filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
602
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
603 (list (expand-file-name filename) size)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
604
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
605 (defun tramp-fish-handle-make-directory (dir &optional parents)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
606 "Like `make-directory' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
607 (setq dir (directory-file-name (expand-file-name dir)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
608 (unless (file-name-absolute-p dir)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
609 (setq dir (expand-file-name dir default-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
610 (with-parsed-tramp-file-name dir nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
611 (save-match-data
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
612 (let ((ldir (file-name-directory dir)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
613 ;; Make missing directory parts
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
614 (when (and parents (not (file-directory-p ldir)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
615 (make-directory ldir parents))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
616 ;; Just do it
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
617 (when (file-directory-p ldir)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
618 (make-directory-internal dir))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
619 (unless (file-directory-p dir)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
620 (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
621
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
622 (defun tramp-fish-handle-make-directory-internal (directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
623 "Like `make-directory-internal' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
624 (setq directory (directory-file-name (expand-file-name directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
625 (unless (file-name-absolute-p directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
626 (setq directory (expand-file-name directory default-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
627 (when (file-directory-p (file-name-directory directory))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
628 (with-parsed-tramp-file-name directory nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
629 (save-match-data
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
630 (unless
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
631 (tramp-fish-send-command-and-check v (format "#MKD %s" localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
632 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
633 v 'file-error "Couldn't make directory %s" directory))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
634
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
635 (defun tramp-fish-handle-make-symbolic-link
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
636 (filename linkname &optional ok-if-already-exists)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
637 "Like `make-symbolic-link' for Tramp files.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
638 If LINKNAME is a non-Tramp file, it is used verbatim as the target of
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
639 the symlink. If LINKNAME is a Tramp file, only the localname component is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
640 used as the target of the symlink.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
641
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
642 If LINKNAME is a Tramp file and the localname component is relative, then
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
643 it is expanded first, before the localname component is taken. Note that
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
644 this can give surprising results if the user/host for the source and
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
645 target of the symlink differ."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
646 (with-parsed-tramp-file-name linkname nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
647 ;; Do the 'confirm if exists' thing.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
648 (when (file-exists-p linkname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
649 ;; What to do?
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
650 (if (or (null ok-if-already-exists) ; not allowed to exist
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
651 (and (numberp ok-if-already-exists)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
652 (not (yes-or-no-p
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
653 (format
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
654 "File %s already exists; make it a link anyway? "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
655 localname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
656 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
657 v 'file-already-exists "File %s already exists" localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
658 (delete-file linkname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
659
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
660 ;; If FILENAME is a Tramp name, use just the localname component.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
661 (when (tramp-tramp-file-p filename)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
662 (setq filename (tramp-file-name-localname
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
663 (tramp-dissect-file-name (expand-file-name filename)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
664
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
665 ;; Right, they are on the same host, regardless of user, method, etc.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
666 ;; We now make the link on the remote machine. This will occur as the user
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
667 ;; that FILENAME belongs to.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
668 (unless
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
669 (tramp-fish-send-command-and-check
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
670 v (format "#SYMLINK %s %s" filename localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
671 (tramp-error v 'file-error "Error creating symbolic link %s" linkname))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
672
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
673 (defun tramp-fish-handle-rename-file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
674 (filename newname &optional ok-if-already-exists)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
675 "Like `rename-file' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
676 (tramp-fish-do-copy-or-rename-file
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
677 'rename filename newname ok-if-already-exists t))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
678
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
679 (defun tramp-fish-handle-set-file-modes (filename mode)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
680 "Like `set-file-modes' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
681 (with-parsed-tramp-file-name filename nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
682 (tramp-flush-file-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
683 (unless (tramp-fish-send-command-and-check
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
684 v (format "#CHMOD %s %s"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
685 (tramp-decimal-to-octal mode)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
686 (tramp-shell-quote-argument localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
687 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
688 v 'file-error "Error while changing file's mode %s" filename))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
689
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
690 (defun tramp-fish-handle-set-file-times (filename &optional time)
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
691 "Like `set-file-times' for Tramp files."
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
692 (with-parsed-tramp-file-name filename nil
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
693 (let ((time (if (or (null time) (equal time '(0 0))) (current-time) time)))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
694 (zerop (process-file
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
695 "touch" nil nil nil "-t"
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
696 (format-time-string "%Y%m%d%H%M.%S" time)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
697 (tramp-shell-quote-argument localname))))))
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
698
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
699 (defun tramp-fish-handle-write-region
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
700 (start end filename &optional append visit lockname confirm)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
701 "Like `write-region' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
702 (setq filename (expand-file-name filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
703 (with-parsed-tramp-file-name filename nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
704 ;; XEmacs takes a coding system as the seventh argument, not `confirm'
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
705 (when (and (not (featurep 'xemacs))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
706 confirm (file-exists-p filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
707 (unless (y-or-n-p (format "File %s exists; overwrite anyway? "
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
708 filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
709 (tramp-error v 'file-error "File not overwritten")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
710
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
711 (tramp-flush-file-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
712
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
713 ;; Send command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
714 (let ((tramp-fish-ok-prompt-regexp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
715 (concat
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
716 tramp-fish-ok-prompt-regexp "\\|"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
717 tramp-fish-continue-prompt-regexp)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
718 (tramp-fish-send-command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
719 v (format "%s %d %s\n### 100"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
720 (if append "#APPEND" "#STOR") (- end start) localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
721
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
722 ;; Send data, if there are any.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
723 (when (> end start)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
724 (tramp-fish-send-command v (buffer-substring-no-properties start end)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
725
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
726 (when (eq visit t)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
727 (set-visited-file-modtime))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
728
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
729 (defun tramp-fish-handle-executable-find (command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
730 "Like `executable-find' for Tramp files."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
731 (with-temp-buffer
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
732 (if (zerop (process-file "which" nil t nil command))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
733 (progn
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
734 (goto-char (point-min))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
735 (buffer-substring (point-min) (tramp-compat-line-end-position))))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
736
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
737 (defun tramp-fish-handle-process-file
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
738 (program &optional infile destination display &rest args)
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
739 "Like `process-file' for Tramp files."
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
740 ;; The implementation is not complete yet.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
741 (when (and (numberp destination) (zerop destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
742 (error "Implementation does not handle immediate return"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
743
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
744 (with-parsed-tramp-file-name default-directory nil
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
745 (let (command input tmpinput output tmpoutput stderr tmpstderr
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
746 outbuf tmpfile ret)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
747 ;; Compute command.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
748 (setq command (mapconcat 'tramp-shell-quote-argument
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
749 (cons program args) " "))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
750 ;; Determine input.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
751 (if (null infile)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
752 (setq input "/dev/null")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
753 (setq infile (expand-file-name infile))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
754 (if (tramp-equal-remote default-directory infile)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
755 ;; INFILE is on the same remote host.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
756 (setq input (with-parsed-tramp-file-name infile nil localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
757 ;; INFILE must be copied to remote host.
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
758 (setq input (tramp-make-tramp-temp-file v)
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
759 tmpinput (tramp-make-tramp-file-name method user host input))
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
760 (copy-file infile tmpinput t)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
761 (when input (setq command (format "%s <%s" command input)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
762
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
763 ;; Determine output.
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
764 (setq output (tramp-make-tramp-temp-file v)
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
765 tmpoutput (tramp-make-tramp-file-name method user host output))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
766 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
767 ;; Just a buffer
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
768 ((bufferp destination)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
769 (setq outbuf destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
770 ;; A buffer name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
771 ((stringp destination)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
772 (setq outbuf (get-buffer-create destination)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
773 ;; (REAL-DESTINATION ERROR-DESTINATION)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
774 ((consp destination)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
775 ;; output
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
776 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
777 ((bufferp (car destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
778 (setq outbuf (car destination)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
779 ((stringp (car destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
780 (setq outbuf (get-buffer-create (car destination)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
781 ;; stderr
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
782 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
783 ((stringp (cadr destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
784 (setcar (cdr destination) (expand-file-name (cadr destination)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
785 (if (tramp-equal-remote default-directory (cadr destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
786 ;; stderr is on the same remote host.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
787 (setq stderr (with-parsed-tramp-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
788 (cadr destination) nil localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
789 ;; stderr must be copied to remote host. The temporary
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
790 ;; file must be deleted after execution.
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
791 (setq stderr (tramp-make-tramp-temp-file v)
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
792 tmpstderr (tramp-make-tramp-file-name
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
793 method user host stderr))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
794 ;; stderr to be discarded
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
795 ((null (cadr destination))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
796 (setq stderr "/dev/null"))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
797 ;; 't
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
798 (destination
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
799 (setq outbuf (current-buffer))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
800 (when stderr (setq command (format "%s 2>%s" command stderr)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
801
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
802 ;; Goto working directory.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
803 (unless
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
804 (tramp-fish-send-command-and-check
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
805 v (format "#CWD %s" (tramp-shell-quote-argument localname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
806 (tramp-error v 'file-error "No such directory: %s" default-directory))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
807 ;; Send the command. It might not return in time, so we protect it.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
808 (condition-case nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
809 (unwind-protect
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
810 (unless (tramp-fish-send-command-and-check
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
811 v (format
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
812 "#EXEC %s %s"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
813 (tramp-shell-quote-argument command) output))
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
814 (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
815 ;; Check return code.
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
816 (setq tmpfile
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
817 (file-local-copy
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
818 (tramp-make-tramp-file-name method user host output)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
819 (with-temp-buffer
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
820 (insert-file-contents tmpfile)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
821 (goto-char (point-max))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
822 (forward-line -1)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
823 (looking-at "^###RESULT: \\([0-9]+\\)")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
824 (setq ret (string-to-number (match-string 1)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
825 (delete-region (point) (point-max))
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
826 (write-region (point-min) (point-max) tmpfile))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
827 ;; We should show the output anyway.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
828 (when outbuf
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84985
diff changeset
829 (with-current-buffer outbuf (insert-file-contents tmpfile))
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
830 (when display (display-buffer outbuf))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
831 ;; When the user did interrupt, we should do it also.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
832 (error (setq ret 1)))
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
833
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
834 ;; Provide error file.
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
835 (when tmpstderr (rename-file tmpstderr (cadr destination) t))
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
836 ;; Cleanup.
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
837 (when tmpinput (delete-file tmpinput))
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
838 (when tmpoutput (delete-file tmpoutput))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
839 ;; Return exit status.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
840 ret)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
841
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
842
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
843 ;; Internal file name functions
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
844
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
845 (defun tramp-fish-do-copy-or-rename-file
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
846 (op filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
847 "Copy or rename a remote file.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
848 OP must be `copy' or `rename' and indicates the operation to
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
849 perform. FILENAME specifies the file to copy or rename, NEWNAME
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
850 is the name of the new file (for copy) or the new name of the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
851 file (for rename). OK-IF-ALREADY-EXISTS means don't barf if
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
852 NEWNAME exists already. KEEP-DATE means to make sure that
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
853 NEWNAME has the same timestamp as FILENAME.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
854
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
855 This function is invoked by `tramp-fish-handle-copy-file' and
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
856 `tramp-fish-handle-rename-file'. It is an error if OP is neither
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
857 of `copy' and `rename'. FILENAME and NEWNAME must be absolute
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
858 file names."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
859 (unless (memq op '(copy rename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
860 (error "Unknown operation `%s', must be `copy' or `rename'" op))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
861 (let ((t1 (tramp-tramp-file-p filename))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
862 (t2 (tramp-tramp-file-p newname)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
863
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
864 (unless ok-if-already-exists
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
865 (when (and t2 (file-exists-p newname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
866 (with-parsed-tramp-file-name newname nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
867 (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
868 v 'file-already-exists "File %s already exists" newname))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
869
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
870 (prog1
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
871 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
872 ;; Both are Tramp files.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
873 ((and t1 t2)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
874 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
875 ;; Shortcut: if method, host, user are the same for both
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
876 ;; files, we invoke `cp' or `mv' on the remote host
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
877 ;; directly.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
878 ((tramp-equal-remote filename newname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
879 (tramp-fish-do-copy-or-rename-file-directly
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
880 op filename newname keep-date preserve-uid-gid))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
881 ;; No shortcut was possible. So we copy the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
882 ;; file first. If the operation was `rename', we go
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
883 ;; back and delete the original file (if the copy was
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
884 ;; successful). The approach is simple-minded: we
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
885 ;; create a new buffer, insert the contents of the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
886 ;; source file into it, then write out the buffer to
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
887 ;; the target file. The advantage is that it doesn't
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
888 ;; matter which filename handlers are used for the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
889 ;; source and target file.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
890 (t
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
891 (tramp-do-copy-or-rename-file-via-buffer
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
892 op filename newname keep-date))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
893
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
894 ;; One file is a Tramp file, the other one is local.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
895 ((or t1 t2)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
896 ;; Use the generic method via a Tramp buffer.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
897 (tramp-do-copy-or-rename-file-via-buffer
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
898 op filename newname keep-date))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
899
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
900 (t
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
901 ;; One of them must be a Tramp file.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
902 (error "Tramp implementation says this cannot happen")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
903 ;; When newname did exist, we have wrong cached values.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
904 (when t2
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
905 (with-parsed-tramp-file-name newname nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
906 (tramp-flush-file-property v localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
907 (tramp-flush-file-property v (file-name-directory localname)))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
908
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
909 (defun tramp-fish-do-copy-or-rename-file-directly
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
910 (op filename newname keep-date preserve-uid-gid)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
911 "Invokes `COPY' or `RENAME' on the remote system.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
912 OP must be one of `copy' or `rename', indicating `cp' or `mv',
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
913 respectively. VEC specifies the connection. LOCALNAME1 and
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
914 LOCALNAME2 specify the two arguments of `cp' or `mv'. If
85694
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
915 KEEP-DATE is non-nil, preserve the time stamp when copying.
21983e7c844a * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
916 PRESERVE-UID-GID is completely ignored."
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
917 (with-parsed-tramp-file-name filename v1
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
918 (with-parsed-tramp-file-name newname v2
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
919 (tramp-fish-send-command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
920 v1
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
921 (format "%s %s %s"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
922 (if (eq op 'copy) "#COPY" "#RENAME")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
923 (tramp-shell-quote-argument v1-localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
924 (tramp-shell-quote-argument v2-localname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
925 ;; KEEP-DATE handling.
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
926 (when (and keep-date (functionp 'set-file-times))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
927 (set-file-times newname (nth 5 (file-attributes filename))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
928 ;; Set the mode.
102852
da220e3be804 * net/tramp-fish.el (tramp-fish-do-copy-or-rename-file-directly):
Michael Albinus <michael.albinus@gmx.de>
parents: 100908
diff changeset
929 (set-file-modes newname (tramp-default-file-modes filename)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
930
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
931 (defun tramp-fish-get-file-entries (vec localname list)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
932 "Read entries returned by FISH server.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
933 When LIST is true, a #LIST command will be sent, including all entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
934 of a directory. Otherwise, #STAT is sent for just one entry.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
935 Result is a list of (LOCALNAME LINK COUNT UID GID ATIME MTIME CTIME
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
936 SIZE MODE WEIRD INODE DEVICE)."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
937 (block nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
938 (with-current-buffer (tramp-get-buffer vec)
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
939 ;; #LIST does not work properly with trailing "/", at least in
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
940 ;; .fishsrv.pl.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
941 (when (string-match "/$" localname)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
942 (setq localname (concat localname ".")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
943
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
944 (let ((command (format "%s %s" (if list "#LIST" "#STAT") localname))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
945 buffer-read-only num res)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
946
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
947 ;; Send command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
948 (tramp-fish-send-command vec command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
949
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
950 ;; Read number of entries
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
951 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
952 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
953 (unless (integerp (setq num (read (current-buffer)))) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
954 (error (return nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
955 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
956 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
957
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
958 ;; Read return code
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
959 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
960 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
961 (unless (looking-at tramp-fish-continue-prompt-regexp) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
962 (error (return nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
963 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
964 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
965
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
966 ;; Loop the listing
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
967 (dotimes (i num)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
968 (let ((item (tramp-fish-read-file-entry)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
969 ;; Add inode and device.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
970 (add-to-list
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
971 'res (append item
81938
26330ef1aa46 * net/tramp.el (tramp-handle-file-remote-p): Handle optional
Michael Albinus <michael.albinus@gmx.de>
parents: 81769
diff changeset
972 (list (tramp-get-inode vec)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
973 (tramp-get-device vec))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
974
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
975 ;; Read return code
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
976 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
977 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
978 (unless (looking-at tramp-fish-ok-prompt-regexp) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
979 (error (tramp-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
980 vec 'file-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
981 "`%s' does not return a valid Lisp expression: `%s'"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
982 command (buffer-string))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
983 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
984 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
985
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
986 res))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
987
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
988 (defun tramp-fish-read-file-entry ()
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
989 "Parse entry in output buffer.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
990 Result is the list (LOCALNAME LINK COUNT UID GID ATIME MTIME CTIME
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
991 SIZE MODE WEIRD)."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
992 ;; We are called from `tramp-fish-get-file-entries', which sets the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
993 ;; current buffer.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
994 (let (buffer-read-only localname link uid gid mtime size mode)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
995 (block nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
996 (while t
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
997 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
998 ;; P<unix permissions> <owner>.<group>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
999 ((looking-at "^P\\(.+\\)\\s-\\(.+\\)\\.\\(.+\\)$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1000 (setq mode (match-string 1))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1001 (setq uid (match-string 2))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1002 (setq gid (match-string 3))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1003 (when (string-match "^d" mode) (setq link t)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1004 ;; S<size>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1005 ((looking-at "^S\\([0-9]+\\)$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1006 (setq size (string-to-number (match-string 1))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1007 ;; D<year> <month> <day> <hour> <minute> <second>[.1234]
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1008 ((looking-at
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1009 "^D\\([0-9]+\\)\\s-\\([0-9]+\\)\\s-\\([0-9]+\\)\\s-\\([0-9]+\\)\\s-\\([0-9]+\\)\\s-\\(\\S-+\\)$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1010 (setq mtime
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1011 (encode-time
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1012 (string-to-number (match-string 6))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1013 (string-to-number (match-string 5))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1014 (string-to-number (match-string 4))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1015 (string-to-number (match-string 3))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1016 (string-to-number (match-string 2))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1017 (string-to-number (match-string 1)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1018 ;; d<3-letters month name> <day> <year or HH:MM>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1019 ((looking-at "^d") nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1020 ;; E<major-of-device>,<minor>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1021 ((looking-at "^E") nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1022 ;; :<filename>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1023 ((looking-at "^:\\(.+\\)$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1024 (setq localname (match-string 1)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1025 ;; L<filename symlink points to>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1026 ((looking-at "^L\\(.+\\)$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1027 (setq link (match-string 1)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1028 ;; M<mimetype>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1029 ((looking-at "^M\\(.+\\)$") nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1030 ;; last line
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1031 ((looking-at "^$")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1032 (return)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1033 ;; delete line
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1034 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1035 (delete-region (point-min) (point))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1036
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1037 ;; delete trailing empty line
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1038 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1039 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1040
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1041 ;; Return entry in file-attributes format
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1042 (list localname link -1 uid gid '(0 0) mtime '(0 0) size mode nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1043
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1044 (defun tramp-fish-retrieve-data (vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1045 "Reads remote data for FISH protocol.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1046 The data are left in the connection buffer of VEC for further processing.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1047 Returns the size of the data."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1048 (block nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1049 (with-current-buffer (tramp-get-buffer vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1050 ;; The retrieved data might be in binary format, without
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1051 ;; trailing newline. Therefore, the OK prompt might not start
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1052 ;; at the beginning of a line.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1053 (let ((tramp-fish-ok-prompt-regexp "### 200\n")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1054 size)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1055
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1056 ;; Send command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1057 (tramp-fish-send-command
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1058 vec (format "#RETR %s" (tramp-file-name-localname vec)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1059
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1060 ;; Read filesize
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1061 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1062 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
1063 (unless (integerp (setq size (read (current-buffer)))) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1064 (error (return nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1065 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1066 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1067
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1068 ;; Read return code
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1069 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1070 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
1071 (unless (looking-at tramp-fish-continue-prompt-regexp) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1072 (error (return nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1073 (forward-line)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1074 (delete-region (point-min) (point))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1075
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1076 ;; The received data might contain the OK prompt already, so
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1077 ;; there might be outstanding data.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1078 (while (/= (+ size (length tramp-fish-ok-prompt-regexp))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1079 (- (point-max) (point-min)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1080 (tramp-wait-for-regexp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1081 (tramp-get-connection-process vec) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1082 (concat tramp-fish-ok-prompt-regexp "$")))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1083
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1084 ;; Read return code
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1085 (goto-char (+ (point-min) size))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1086 (condition-case nil
84966
fa9dd0b54e54 * net/tramp.el (with-file-property, with-connection-property):
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
1087 (unless (looking-at tramp-fish-ok-prompt-regexp) (error nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1088 (error (return nil)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1089 (delete-region (+ (point-min) size) (point-max))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1090 size))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1091
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1092
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1093 ;; Connection functions
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1094
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1095 (defun tramp-fish-maybe-open-connection (vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1096 "Maybe open a connection VEC.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1097 Does not do anything if a connection is already open, but re-opens the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1098 connection if a previous connection has died for some reason."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1099 (let ((process-connection-type tramp-process-connection-type)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1100 (p (get-buffer-process (tramp-get-buffer vec))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1101
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1102 ;; New connection must be opened.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1103 (unless (and p (processp p) (memq (process-status p) '(run open)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1104
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1105 ;; Set variables for computing the prompt for reading password.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1106 (setq tramp-current-method (tramp-file-name-method vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1107 tramp-current-user (tramp-file-name-user vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1108 tramp-current-host (tramp-file-name-host vec))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1109
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1110 ;; Start new process.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1111 (when (and p (processp p))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1112 (delete-process p))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1113 (setenv "TERM" tramp-terminal-type)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1114 (setenv "PS1" "$ ")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1115 (tramp-message
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1116 vec 3 "Opening connection for %s@%s using %s..."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1117 tramp-current-user tramp-current-host tramp-current-method)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1118
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1119 (let* ((process-connection-type tramp-process-connection-type)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1120 (inhibit-eol-conversion nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1121 (coding-system-for-read 'binary)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1122 (coding-system-for-write 'binary)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1123 ;; This must be done in order to avoid our file name handler.
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
1124 (p (let ((default-directory
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
1125 (tramp-compat-temporary-file-directory)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1126 (start-process
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1127 (or (tramp-get-connection-property vec "process-name" nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1128 (tramp-buffer-name vec))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1129 (tramp-get-connection-buffer vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1130 "ssh" "-l"
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1131 (tramp-file-name-user vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1132 (tramp-file-name-host vec)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1133 (tramp-message vec 6 "%s" (mapconcat 'identity (process-command p) " "))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1134
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1135 ;; Check whether process is alive.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1136 (tramp-set-process-query-on-exit-flag p nil)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1137
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1138 (tramp-process-actions p vec tramp-actions-before-shell 60)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1139 (tramp-fish-send-command vec tramp-fish-start-fish-server-command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1140 (tramp-message
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1141 vec 3
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1142 "Found remote shell prompt on `%s'" (tramp-file-name-host vec))))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1143
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1144 (defun tramp-fish-send-command (vec command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1145 "Send the COMMAND to connection VEC."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1146 (tramp-fish-maybe-open-connection vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1147 (tramp-message vec 6 "%s" command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1148 (tramp-send-string vec command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1149 (tramp-wait-for-regexp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1150 (tramp-get-connection-process vec) nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1151 (concat tramp-fish-ok-prompt-regexp "\\|" tramp-fish-error-prompt-regexp)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1152
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1153 (defun tramp-fish-send-command-and-check (vec command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1154 "Send the COMMAND to connection VEC.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1155 Returns nil if there has been an error message."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1156
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1157 ;; Send command.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1158 (tramp-fish-send-command vec command)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1159
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1160 ;; Read return code.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1161 (with-current-buffer (tramp-get-buffer vec)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1162 (goto-char (point-min))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1163 (looking-at tramp-fish-ok-prompt-regexp)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1164
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1165 (provide 'tramp-fish)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1166 ;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1167 ;;;; TODO:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1168 ;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1169 ;; * Evaluate the MIME information with #LIST or #STAT.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1170 ;
81769
44b53335982a Add arch tagline
Miles Bader <miles@gnu.org>
parents: 81758
diff changeset
1171
44b53335982a Add arch tagline
Miles Bader <miles@gnu.org>
parents: 81758
diff changeset
1172 ;; arch-tag: a66df7df-5f29-42a7-a921-643ceb29db49
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1173 ;;;; tramp-fish.el ends here