Mercurial > emacs
annotate lisp/ange-ftp.el @ 10289:9dd21ecf6b0f
(Flength): Handle compiled function as pseudovector.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 30 Dec 1994 01:46:04 +0000 |
parents | 3d95ea97eb9e |
children | 8b26137996f9 |
rev | line source |
---|---|
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
1 ;;; ange-ftp.el --- transparent FTP support for GNU Emacs |
1106 | 2 |
7298 | 3 ;;; Copyright (C) 1989,90,91,92,93,94 Free Software Foundation, Inc. |
1106 | 4 ;;; |
2258 | 5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com) |
6 ;; Keywords: comm | |
1106 | 7 ;;; |
8 ;;; This program is free software; you can redistribute it and/or modify | |
9 ;;; it under the terms of the GNU General Public License as published by | |
2560
50d7841854b3
(ange-ftp-binary-file-name-regexp): Match .z and .z-part-?? files.
Roland McGrath <roland@gnu.org>
parents:
2258
diff
changeset
|
10 ;;; the Free Software Foundation; either version 2, or (at your option) |
1106 | 11 ;;; any later version. |
12 ;;; | |
13 ;;; This program is distributed in the hope that it will be useful, | |
14 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;;; GNU General Public License for more details. | |
17 ;;; | |
18 ;;; A copy of the GNU General Public License can be obtained from this | |
19 ;;; program's author (send electronic mail to ange@hplb.hpl.hp.com) or from | |
20 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA | |
21 ;;; 02139, USA. | |
22 | |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
23 ;;; Commentary: |
1106 | 24 ;;; |
25 ;;; This package attempts to make accessing files and directories using FTP | |
26 ;;; from within GNU Emacs as simple and transparent as possible. A subset of | |
27 ;;; the common file-handling routines are extended to interact with FTP. | |
28 | |
29 ;;; Usage: | |
30 ;;; | |
31 ;;; Some of the common GNU Emacs file-handling operations have been made | |
32 ;;; FTP-smart. If one of these routines is given a filename that matches | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
33 ;;; '/user@host:name' then it will spawn an FTP process connecting to machine |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
34 ;;; 'host' as account 'user' and perform its operation on the file 'name'. |
1106 | 35 ;;; |
36 ;;; For example: if find-file is given a filename of: | |
37 ;;; | |
38 ;;; /ange@anorman:/tmp/notes | |
39 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
40 ;;; then ange-ftp spawns an FTP process, connect to the host 'anorman' as |
1106 | 41 ;;; user 'ange', get the file '/tmp/notes' and pop up a buffer containing the |
42 ;;; contents of that file as if it were on the local filesystem. If ange-ftp | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
43 ;;; needs a password to connect then it reads one in the echo area. |
1106 | 44 |
45 ;;; Extended filename syntax: | |
46 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
47 ;;; The default extended filename syntax is '/user@host:name', where the |
1106 | 48 ;;; 'user@' part may be omitted. This syntax can be customised to a certain |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
49 ;;; extent by changing ange-ftp-name-format. There are limitations. |
1106 | 50 ;;; |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
51 ;;; If the user part is omitted then ange-ftp generates a default user |
1106 | 52 ;;; instead whose value depends on the variable ange-ftp-default-user. |
53 | |
54 ;;; Passwords: | |
55 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
56 ;;; A password is required for each host/user pair. Ange-ftp reads passwords |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
57 ;;; as needed. You can also specify a password with ange-ftp-set-passwd, or |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
58 ;;; in a *valid* ~/.netrc file. |
1106 | 59 |
60 ;;; Passwords for user "anonymous": | |
61 ;;; | |
1174 | 62 ;;; Passwords for the user "anonymous" (or "ftp") are handled |
63 ;;; specially. The variable `ange-ftp-generate-anonymous-password' | |
64 ;;; controls what happens: if the value of this variable is a string, | |
65 ;;; then this is used as the password; if non-nil (the default), then | |
66 ;;; a password is created from the name of the user and the hostname | |
67 ;;; of the machine on which GNU Emacs is running; if nil then the user | |
68 ;;; is prompted for a password as normal. | |
1106 | 69 |
70 ;;; "Dumb" UNIX hosts: | |
71 ;;; | |
72 ;;; The FTP servers on some UNIX machines have problems if the 'ls' command is | |
73 ;;; used. | |
74 ;;; | |
75 ;;; The routine ange-ftp-add-dumb-unix-host can be called to tell ange-ftp to | |
76 ;;; limit itself to the DIR command and not 'ls' for a given UNIX host. Note | |
77 ;;; that this change will take effect for the current GNU Emacs session only. | |
78 ;;; See below for a discussion of non-UNIX hosts. If a large number of | |
79 ;;; machines with similar hostnames have this problem then it is easier to set | |
80 ;;; the value of ange-ftp-dumb-unix-host-regexp in your .emacs file. ange-ftp | |
81 ;;; is unable to automatically recognize dumb unix hosts. | |
82 | |
83 ;;; File name completion: | |
84 ;;; | |
85 ;;; Full file-name completion is supported on UNIX, VMS, CMS, and MTS hosts. | |
86 ;;; To do filename completion, ange-ftp needs a listing from the remote host. | |
87 ;;; Therefore, for very slow connections, it might not save any time. | |
88 | |
89 ;;; FTP processes: | |
90 ;;; | |
91 ;;; When ange-ftp starts up an FTP process, it leaves it running for speed | |
92 ;;; purposes. Some FTP servers will close the connection after a period of | |
93 ;;; time, but ange-ftp should be able to quietly reconnect the next time that | |
94 ;;; the process is needed. | |
95 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
96 ;;; Killing the "*ftp user@host*" buffer also kills the ftp process. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
97 ;;; This should not cause ange-ftp any grief. |
1106 | 98 |
99 ;;; Binary file transfers: | |
100 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
101 ;;; By default ange-ftp transfers files in ASCII mode. If a file being |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
102 ;;; transferred matches the value of ange-ftp-binary-file-name-regexp then |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
103 ;;; binary mode is used for that transfer. |
1106 | 104 |
105 ;;; Account passwords: | |
106 ;;; | |
107 ;;; Some FTP servers require an additional password which is sent by the | |
108 ;;; ACCOUNT command. ange-ftp partially supports this by allowing the user to | |
109 ;;; specify an account password by either calling ange-ftp-set-account, or by | |
110 ;;; specifying an account token in the .netrc file. If the account password | |
111 ;;; is set by either of these methods then ange-ftp will issue an ACCOUNT | |
112 ;;; command upon starting the FTP process. | |
113 | |
114 ;;; Preloading: | |
115 ;;; | |
116 ;;; ange-ftp can be preloaded, but must be put in the site-init.el file and | |
117 ;;; not the site-load.el file in order for the documentation strings for the | |
118 ;;; functions being overloaded to be available. | |
119 | |
120 ;;; Status reports: | |
121 ;;; | |
122 ;;; Most ange-ftp commands that talk to the FTP process output a status | |
123 ;;; message on what they are doing. In addition, ange-ftp can take advantage | |
124 ;;; of the FTP client's HASH command to display the status of transferring | |
125 ;;; files and listing directories. See the documentation for the variables | |
126 ;;; ange-ftp-{ascii,binary}-hash-mark-size, ange-ftp-send-hash and | |
127 ;;; ange-ftp-process-verbose for more details. | |
128 | |
129 ;;; Gateways: | |
130 ;;; | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
131 ;;; Sometimes it is necessary for the FTP process to be run on a different |
1106 | 132 ;;; machine than the machine running GNU Emacs. This can happen when the |
133 ;;; local machine has restrictions on what hosts it can access. | |
134 ;;; | |
135 ;;; ange-ftp has support for running the ftp process on a different (gateway) | |
136 ;;; machine. The way it works is as follows: | |
137 ;;; | |
138 ;;; 1) Set the variable 'ange-ftp-gateway-host' to the name of a machine | |
139 ;;; that doesn't have the access restrictions. | |
140 ;;; | |
141 ;;; 2) Set the variable 'ange-ftp-local-host-regexp' to a regular expression | |
142 ;;; that matches hosts that can be contacted from running a local ftp | |
143 ;;; process, but fails to match hosts that can't be accessed locally. For | |
144 ;;; example: | |
145 ;;; | |
146 ;;; "\\.hp\\.com$\\|^[^.]*$" | |
147 ;;; | |
148 ;;; will match all hosts that are in the .hp.com domain, or don't have an | |
149 ;;; explicit domain in their name, but will fail to match hosts with | |
150 ;;; explicit domains or that are specified by their ip address. | |
151 ;;; | |
152 ;;; 3) Using NFS and symlinks, make sure that there is a shared directory with | |
153 ;;; the *same* name between the local machine and the gateway machine. | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
154 ;;; This directory is necessary for temporary files created by ange-ftp. |
1106 | 155 ;;; |
156 ;;; 4) Set the variable 'ange-ftp-gateway-tmp-name-template' to the name of | |
157 ;;; this directory plus an identifying filename prefix. For example: | |
158 ;;; | |
159 ;;; "/nfs/hplose/ange/ange-ftp" | |
160 ;;; | |
161 ;;; where /nfs/hplose/ange is a directory that is shared between the | |
162 ;;; gateway machine and the local machine. | |
163 ;;; | |
164 ;;; The simplest way of getting a ftp process running on the gateway machine | |
165 ;;; is if you can spawn a remote shell using either 'rsh' or 'remsh'. If you | |
166 ;;; can't do this for some reason such as security then points 7 onwards will | |
167 ;;; discuss an alternative approach. | |
168 ;;; | |
169 ;;; 5) Set the variable ange-ftp-gateway-program to the name of the remote | |
170 ;;; shell process such as 'remsh' or 'rsh' if the default isn't correct. | |
171 ;;; | |
172 ;;; 6) Set the variable ange-ftp-gateway-program-interactive to nil if it | |
173 ;;; isn't already. This tells ange-ftp that you are using a remote shell | |
174 ;;; rather than logging in using telnet or rlogin. | |
175 ;;; | |
176 ;;; That should be all you need to allow ange-ftp to spawn a ftp process on | |
177 ;;; the gateway machine. If you have to use telnet or rlogin to get to the | |
178 ;;; gateway machine then follow the instructions below. | |
179 ;;; | |
180 ;;; 7) Set the variable ange-ftp-gateway-program to the name of the program | |
181 ;;; that lets you log onto the gateway machine. This may be something like | |
182 ;;; telnet or rlogin. | |
183 ;;; | |
184 ;;; 8) Set the variable ange-ftp-gateway-prompt-pattern to a regular | |
185 ;;; expression that matches the prompt you get when you login to the | |
186 ;;; gateway machine. Be very specific here; this regexp must not match | |
187 ;;; *anything* in your login banner except this prompt. | |
188 ;;; shell-prompt-pattern is far too general as it appears to match some | |
189 ;;; login banners from Sun machines. For example: | |
190 ;;; | |
191 ;;; "^$*$ *" | |
192 ;;; | |
193 ;;; 9) Set the variable ange-ftp-gateway-program-interactive to 't' to let | |
194 ;;; ange-ftp know that it has to "hand-hold" the login to the gateway | |
195 ;;; machine. | |
196 ;;; | |
197 ;;; 10) Set the variable ange-ftp-gateway-setup-term-command to a UNIX command | |
198 ;;; that will put the pty connected to the gateway machine into a | |
199 ;;; no-echoing mode, and will strip off carriage-returns from output from | |
200 ;;; the gateway machine. For example: | |
201 ;;; | |
202 ;;; "stty -onlcr -echo" | |
203 ;;; | |
204 ;;; will work on HP-UX machines, whereas: | |
205 ;;; | |
206 ;;; "stty -echo nl" | |
207 ;;; | |
208 ;;; appears to work for some Sun machines. | |
209 ;;; | |
210 ;;; That's all there is to it. | |
211 | |
212 ;;; Smart gateways: | |
213 ;;; | |
214 ;;; If you have a "smart" ftp program that allows you to issue commands like | |
215 ;;; "USER foo@bar" which do nice proxy things, then look at the variables | |
216 ;;; ange-ftp-smart-gateway and ange-ftp-smart-gateway-port. | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
217 ;;; |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
218 ;;; Otherwise, if there is an alternate ftp program that implements proxy in |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
219 ;;; a transparent way (i.e. w/o specifying the proxy host), that will |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
220 ;;; connect you directly to the desired destination host: |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
221 ;;; Set ange-ftp-gateway-ftp-program-name to that program's name. |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
222 ;;; Set ange-ftp-local-host-regexp to a value as stated earlier on. |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
223 ;;; Leave ange-ftp-gateway-host set to nil. |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
224 ;;; Set ange-ftp-smart-gateway to t. |
1106 | 225 |
226 ;;; Tips for using ange-ftp: | |
227 ;;; | |
228 ;;; 1. For dired to work on a host which marks symlinks with a trailing @ in | |
229 ;;; an ls -alF listing, you need to (setq dired-ls-F-marks-symlinks t). | |
230 ;;; Most UNIX systems do not do this, but ULTRIX does. If you think that | |
231 ;;; there is a chance you might connect to an ULTRIX machine (such as | |
232 ;;; prep.ai.mit.edu), then set this variable accordingly. This will have | |
233 ;;; the side effect that dired will have problems with symlinks whose names | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
234 ;;; end in an @. If you get yourself into this situation then editing |
1106 | 235 ;;; dired's ls-switches to remove "F", will temporarily fix things. |
236 ;;; | |
237 ;;; 2. If you know that you are connecting to a certain non-UNIX machine | |
238 ;;; frequently, and ange-ftp seems to be unable to guess its host-type, | |
239 ;;; then setting the appropriate host-type regexp | |
240 ;;; (ange-ftp-vms-host-regexp, ange-ftp-mts-host-regexp, or | |
241 ;;; ange-ftp-cms-host-regexp) accordingly should help. Also, please report | |
242 ;;; ange-ftp's inability to recognize the host-type as a bug. | |
243 ;;; | |
244 ;;; 3. For slow connections, you might get "listing unreadable" error | |
245 ;;; messages, or get an empty buffer for a file that you know has something | |
246 ;;; in it. The solution is to increase the value of ange-ftp-retry-time. | |
247 ;;; Its default value is 5 which is plenty for reasonable connections. | |
248 ;;; However, for some transatlantic connections I set this to 20. | |
249 ;;; | |
250 ;;; 4. Beware of compressing files on non-UNIX hosts. Ange-ftp will do it by | |
251 ;;; copying the file to the local machine, compressing it there, and then | |
252 ;;; sending it back. Binary file transfers between machines of different | |
253 ;;; architectures can be a risky business. Test things out first on some | |
254 ;;; test files. See "Bugs" below. Also, note that ange-ftp copies files by | |
255 ;;; moving them through the local machine. Again, be careful when doing | |
256 ;;; this with binary files on non-Unix machines. | |
257 ;;; | |
258 ;;; 5. Beware that dired over ftp will use your setting of dired-no-confirm | |
259 ;;; (list of dired commands for which confirmation is not asked). You | |
260 ;;; might want to reconsider your setting of this variable, because you | |
261 ;;; might want confirmation for more commands on remote direds than on | |
262 ;;; local direds. For example, I strongly recommend that you not include | |
263 ;;; compress and uncompress in this list. If there is enough demand it | |
264 ;;; might be a good idea to have an alist ange-ftp-dired-no-confirm of | |
265 ;;; pairs ( TYPE . LIST ), where TYPE is an operating system type and LIST | |
266 ;;; is a list of commands for which confirmation would be suppressed. Then | |
267 ;;; remote dired listings would take their (buffer-local) value of | |
268 ;;; dired-no-confirm from this alist. Who votes for this? | |
269 | |
270 ;;; --------------------------------------------------------------------- | |
271 ;;; Non-UNIX support: | |
272 ;;; --------------------------------------------------------------------- | |
273 | |
274 ;;; VMS support: | |
275 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
276 ;;; Ange-ftp has full support for VMS hosts. It |
1106 | 277 ;;; should be able to automatically recognize any VMS machine. However, if it |
278 ;;; fails to do this, you can use the command ange-ftp-add-vms-host. As well, | |
279 ;;; you can set the variable ange-ftp-vms-host-regexp in your .emacs file. We | |
280 ;;; would be grateful if you would report any failures to automatically | |
281 ;;; recognize a VMS host as a bug. | |
282 ;;; | |
283 ;;; Filename Syntax: | |
284 ;;; | |
285 ;;; For ease of *implementation*, the user enters the VMS filename syntax in a | |
286 ;;; UNIX-y way. For example: | |
287 ;;; PUB$:[ANONYMOUS.SDSCPUB.NEXT]README.TXT;1 | |
288 ;;; would be entered as: | |
289 ;;; /PUB$$:/ANONYMOUS/SDSCPUB/NEXT/README.TXT;1 | |
290 ;;; i.e. to log in as anonymous on ymir.claremont.edu and grab the file: | |
291 ;;; [.CSV.POLICY]RULES.MEM | |
292 ;;; you would type: | |
293 ;;; C-x C-f /anonymous@ymir.claremont.edu:CSV/POLICY/RULES.MEM | |
294 ;;; | |
295 ;;; A legal VMS filename is of the form: FILE.TYPE;## | |
296 ;;; where FILE can be up to 39 characters | |
297 ;;; TYPE can be up to 39 characters | |
298 ;;; ## is a version number (an integer between 1 and 32,767) | |
299 ;;; Valid characters in FILE and TYPE are A-Z 0-9 _ - $ | |
300 ;;; $ cannot begin a filename, and - cannot be used as the first or last | |
301 ;;; character. | |
302 ;;; | |
303 ;;; Tips: | |
304 ;;; 1. Although VMS is not case sensitive, EMACS running under UNIX is. | |
305 ;;; Therefore, to access a VMS file, you must enter the filename with upper | |
306 ;;; case letters. | |
307 ;;; 2. To access the latest version of file under VMS, you use the filename | |
308 ;;; without the ";" and version number. You should always edit the latest | |
309 ;;; version of a file. If you want to edit an earlier version, copy it to a | |
310 ;;; new file first. This has nothing to do with ange-ftp, but is simply | |
311 ;;; good VMS operating practice. Therefore, to edit FILE.TXT;3 (say 3 is | |
312 ;;; latest version), do C-x C-f /ymir.claremont.edu:FILE.TXT. If you | |
313 ;;; inadvertently do C-x C-f /ymir.claremont.edu:FILE.TXT;3, you will find | |
314 ;;; that VMS will not allow you to save the file because it will refuse to | |
315 ;;; overwrite FILE.TXT;3, but instead will want to create FILE.TXT;4, and | |
316 ;;; attach the buffer to this file. To get out of this situation, M-x | |
317 ;;; write-file /ymir.claremont.edu:FILE.TXT will attach the buffer to | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
318 ;;; latest version of the file. For this reason, in dired "f" |
1106 | 319 ;;; (dired-find-file), always loads the file sans version, whereas "v", |
320 ;;; (dired-view-file), always loads the explicit version number. The | |
321 ;;; reasoning being that it reasonable to view old versions of a file, but | |
322 ;;; not to edit them. | |
323 ;;; 3. EMACS has a feature in which it does environment variable substitution | |
324 ;;; in filenames. Therefore, to enter a $ in a filename, you must quote it | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
325 ;;; by typing $$. |
1106 | 326 |
327 ;;; MTS support: | |
328 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
329 ;;; Ange-ftp has full support for hosts running |
1106 | 330 ;;; the Michigan terminal system. It should be able to automatically |
331 ;;; recognize any MTS machine. However, if it fails to do this, you can use | |
332 ;;; the command ange-ftp-add-mts-host. As well, you can set the variable | |
333 ;;; ange-ftp-mts-host-regexp in your .emacs file. We would be grateful if you | |
334 ;;; would report any failures to automatically recognize a MTS host as a bug. | |
335 ;;; | |
336 ;;; Filename syntax: | |
337 ;;; | |
338 ;;; MTS filenames are entered in a UNIX-y way. For example, if your account | |
339 ;;; was YYYY, the file FILE in the account XXXX: on mtsg.ubc.ca would be | |
340 ;;; entered as | |
341 ;;; /YYYY@mtsg.ubc.ca:/XXXX:/FILE | |
342 ;;; In other words, MTS accounts are treated as UNIX directories. Of course, | |
343 ;;; to access a file in another account, you must have access permission for | |
344 ;;; it. If FILE were in your own account, then you could enter it in a | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
345 ;;; relative name fashion as |
1106 | 346 ;;; /YYYY@mtsg.ubc.ca:FILE |
347 ;;; MTS filenames can be up to 12 characters. Like UNIX, the structure of the | |
348 ;;; filename does not contain a TYPE (i.e. it can have as many "."'s as you | |
349 ;;; like.) MTS filenames are always in upper case, and hence be sure to enter | |
350 ;;; them as such! MTS is not case sensitive, but an EMACS running under UNIX | |
351 ;;; is. | |
352 | |
353 ;;; CMS support: | |
354 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
355 ;;; Ange-ftp has full support for hosts running |
1106 | 356 ;;; CMS. It should be able to automatically recognize any CMS machine. |
357 ;;; However, if it fails to do this, you can use the command | |
358 ;;; ange-ftp-add-cms-host. As well, you can set the variable | |
359 ;;; ange-ftp-cms-host-regexp in your .emacs file. We would be grateful if you | |
360 ;;; would report any failures to automatically recognize a CMS host as a bug. | |
361 ;;; | |
362 ;;; Filename syntax: | |
363 ;;; | |
364 ;;; CMS filenames are entered in a UNIX-y way. In otherwords, minidisks are | |
365 ;;; treated as UNIX directories. For example to access the file READ.ME in | |
366 ;;; minidisk *.311 on cuvmb.cc.columbia.edu, you would enter | |
367 ;;; /anonymous@cuvmb.cc.columbia.edu:/*.311/READ.ME | |
368 ;;; If *.301 is the default minidisk for this account, you could access | |
369 ;;; FOO.BAR on this minidisk as | |
370 ;;; /anonymous@cuvmb.cc.columbia.edu:FOO.BAR | |
371 ;;; CMS filenames are of the form FILE.TYPE, where both FILE and TYPE can be | |
372 ;;; up to 8 characters. Again, beware that CMS filenames are always upper | |
373 ;;; case, and hence must be entered as such. | |
374 ;;; | |
375 ;;; Tips: | |
376 ;;; 1. CMS machines, with the exception of anonymous accounts, nearly always | |
377 ;;; need an account password. To have ange-ftp send an account password, | |
378 ;;; you can either include it in your .netrc file, or use | |
379 ;;; ange-ftp-set-account. | |
380 ;;; 2. Ange-ftp cannot send "write passwords" for a minidisk. Hopefully, we | |
381 ;;; can fix this. | |
382 ;;; | |
383 ;;; ------------------------------------------------------------------ | |
384 ;;; Bugs: | |
385 ;;; ------------------------------------------------------------------ | |
386 ;;; | |
387 ;;; 1. Umask problems: | |
388 ;;; Be warned that files created by using ange-ftp will take account of the | |
389 ;;; umask of the ftp daemon process rather than the umask of the creating | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
390 ;;; user. This is particularly important when logging in as the root user. |
1106 | 391 ;;; The way that I tighten up the ftp daemon's umask under HP-UX is to make |
392 ;;; sure that the umask is changed to 027 before I spawn /etc/inetd. I | |
393 ;;; suspect that there is something similar on other systems. | |
394 ;;; | |
395 ;;; 2. Some combinations of FTP clients and servers break and get out of sync | |
396 ;;; when asked to list a non-existent directory. Some of the ai.mit.edu | |
397 ;;; machines cause this problem for some FTP clients. Using | |
7418
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
398 ;;; ange-ftp-kill-ftp-process can restart the ftp process, which |
1106 | 399 ;;; should get things back in synch. |
400 ;;; | |
401 ;;; 3. Ange-ftp does not check to make sure that when creating a new file, | |
402 ;;; you provide a valid filename for the remote operating system. | |
403 ;;; If you do not, then the remote FTP server will most likely | |
404 ;;; translate your filename in some way. This may cause ange-ftp to | |
405 ;;; get confused about what exactly is the name of the file. The | |
406 ;;; most common causes of this are using lower case filenames on systems | |
407 ;;; which support only upper case, and using filenames which are too | |
408 ;;; long. | |
409 ;;; | |
410 ;;; 4. Null (blank) passwords confuse both ange-ftp and some FTP daemons. | |
411 ;;; | |
412 ;;; 5. Ange-ftp likes to use pty's to talk to its FTP processes. If GNU Emacs | |
413 ;;; for some reason creates a FTP process that only talks via pipes then | |
414 ;;; ange-ftp won't be getting the information it requires at the time that | |
415 ;;; it wants it since pipes flush at different times to pty's. One | |
416 ;;; disgusting way around this problem is to talk to the FTP process via | |
417 ;;; rlogin which does the 'right' things with pty's. | |
418 ;;; | |
419 ;;; 6. For CMS support, we send too many cd's. Since cd's are cheap, I haven't | |
420 ;;; worried about this too much. Eventually, we should have some caching | |
421 ;;; of the current minidisk. | |
422 ;;; | |
423 ;;; 7. Some CMS machines do not assign a default minidisk when you ftp them as | |
424 ;;; anonymous. It is then necessary to guess a valid minidisk name, and cd | |
425 ;;; to it. This is (understandably) beyond ange-ftp. | |
426 ;;; | |
427 ;;; 8. Remote to remote copying of files on non-Unix machines can be risky. | |
428 ;;; Depending on the variable ange-ftp-binary-file-name-regexp, ange-ftp | |
429 ;;; will use binary mode for the copy. Between systems of different | |
430 ;;; architecture, this still may not be enough to guarantee the integrity | |
431 ;;; of binary files. Binary file transfers from VMS machines are | |
432 ;;; particularly problematical. Should ange-ftp-binary-file-name-regexp be | |
433 ;;; an alist of OS type, regexp pairs? | |
434 ;;; | |
435 ;;; 9. The code to do compression of files over ftp is not as careful as it | |
436 ;;; should be. It deletes the old remote version of the file, before | |
437 ;;; actually checking if the local to remote transfer of the compressed | |
438 ;;; file succeeds. Of course to delete the original version of the file | |
439 ;;; after transferring the compressed version back is also dangerous, | |
440 ;;; because some OS's have severe restrictions on the length of filenames, | |
441 ;;; and when the compressed version is copied back the "-Z" or ".Z" may be | |
442 ;;; truncated. Then, ange-ftp would delete the only remaining version of | |
443 ;;; the file. Maybe ange-ftp should make backups when it compresses files | |
444 ;;; (of course, the backup "~" could also be truncated off, sigh...). | |
445 ;;; Suggestions? | |
446 ;;; | |
447 | |
448 ;;; 10. If a dir listing is attempted for an empty directory on (at least | |
449 ;;; some) VMS hosts, an ftp error is given. This is really an ftp bug, and | |
450 ;;; I don't know how to get ange-ftp work to around it. | |
451 ;;; | |
452 ;;; 11. Bombs on filenames that start with a space. Deals well with filenames | |
453 ;;; containing spaces, but beware that the remote ftpd may not like them | |
454 ;;; much. | |
455 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
456 ;;; 12. The dired support for non-Unix-like systems does not currently work. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
457 ;;; It needs to be reimplemented by modifying the parse-...-listing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
458 ;;; functions to convert the directory listing to ls -l format. |
1106 | 459 ;;; |
460 ;;; 13. The famous @ bug. As mentioned above in TIPS, ULTRIX marks symlinks | |
461 ;;; with a trailing @ in a ls -alF listing. In order to account for this | |
462 ;;; ange-ftp looks to chop trailing @'s off of symlink names when it is | |
463 ;;; parsing a listing with the F switch. This will cause ange-ftp to | |
464 ;;; incorrectly get the name of a symlink on a non-ULTRIX host if its name | |
465 ;;; ends in an @. ange-ftp will correct itself if you take F out of the | |
466 ;;; dired ls switches (C-u s will allow you to edit the switches). The | |
467 ;;; dired buffer will be automatically reverted, which will allow ange-ftp | |
468 ;;; to fix its files hashtable. A cookie to anyone who can think of a | |
469 ;;; fast, sure-fire way to recognize ULTRIX over ftp. | |
470 | |
471 ;;; If you find any bugs or problems with this package, PLEASE either e-mail | |
472 ;;; the above author, or send a message to the ange-ftp-lovers mailing list | |
473 ;;; below. Ideas and constructive comments are especially welcome. | |
474 | |
475 ;;; ange-ftp-lovers: | |
476 ;;; | |
477 ;;; ange-ftp has its own mailing list modestly called ange-ftp-lovers. All | |
478 ;;; users of ange-ftp are welcome to subscribe (see below) and to discuss | |
479 ;;; aspects of ange-ftp. New versions of ange-ftp are posted periodically to | |
480 ;;; the mailing list. | |
481 ;;; | |
482 ;;; To [un]subscribe to ange-ftp-lovers, or to report mailer problems with the | |
483 ;;; list, please mail one of the following addresses: | |
484 ;;; | |
485 ;;; ange-ftp-lovers-request@anorman.hpl.hp.com | |
486 ;;; or | |
487 ;;; ange-ftp-lovers-request%anorman.hpl.hp.com@hplb.hpl.hp.com | |
488 ;;; | |
489 ;;; Please don't forget the -request part. | |
490 ;;; | |
491 ;;; For mail to be posted directly to ange-ftp-lovers, send to one of the | |
492 ;;; following addresses: | |
493 ;;; | |
494 ;;; ange-ftp-lovers@anorman.hpl.hp.com | |
495 ;;; or | |
496 ;;; ange-ftp-lovers%anorman.hpl.hp.com@hplb.hpl.hp.com | |
497 ;;; | |
498 ;;; Alternatively, there is a mailing list that only gets announcements of new | |
499 ;;; ange-ftp releases. This is called ange-ftp-lovers-announce, and can be | |
500 ;;; subscribed to by e-mailing to the -request address as above. Please make | |
501 ;;; it clear in the request which mailing list you wish to join. | |
502 | |
503 ;;; The latest version of ange-ftp can usually be obtained via anonymous ftp | |
504 ;;; from: | |
505 ;;; alpha.gnu.ai.mit.edu:ange-ftp/ange-ftp.tar.Z | |
506 ;;; or: | |
507 ;;; ugle.unit.no:/pub/gnu/emacs-lisp/ange-ftp.tar.Z | |
508 ;;; or: | |
509 ;;; archive.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/packages/ange-ftp.tar.Z | |
510 | |
511 ;;; The archives for ange-ftp-lovers can be found via anonymous ftp under: | |
512 ;;; | |
513 ;;; ftp.reed.edu:pub/mailing-lists/ange-ftp/ | |
514 | |
515 ;;; ----------------------------------------------------------- | |
516 ;;; Technical information on this package: | |
517 ;;; ----------------------------------------------------------- | |
518 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
519 ;;; ange-ftp works by putting a handler on file-name-handler-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
520 ;;; which is called by many primitives, and a few non-primitives, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
521 ;;; whenever they see a file name of the appropriate sort. |
1106 | 522 |
523 ;;; Checklist for adding non-UNIX support for TYPE | |
524 ;;; | |
525 ;;; The following functions may need TYPE versions: | |
526 ;;; (not all functions will be needed for every OS) | |
527 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
528 ;;; ange-ftp-fix-name-for-TYPE |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
529 ;;; ange-ftp-fix-dir-name-for-TYPE |
1106 | 530 ;;; ange-ftp-TYPE-host |
531 ;;; ange-ftp-TYPE-add-host | |
532 ;;; ange-ftp-parse-TYPE-listing | |
533 ;;; ange-ftp-TYPE-delete-file-entry | |
534 ;;; ange-ftp-TYPE-add-file-entry | |
535 ;;; ange-ftp-TYPE-file-name-as-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
536 ;;; ange-ftp-TYPE-make-compressed-filename |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
537 ;;; ange-ftp-TYPE-file-name-sans-versions |
1106 | 538 ;;; |
539 ;;; Variables: | |
540 ;;; | |
541 ;;; ange-ftp-TYPE-host-regexp | |
542 ;;; May need to add TYPE to ange-ftp-dumb-host-types | |
543 ;;; | |
544 ;;; Check the following functions for OS dependent coding: | |
545 ;;; | |
546 ;;; ange-ftp-host-type | |
547 ;;; ange-ftp-guess-host-type | |
548 ;;; ange-ftp-allow-child-lookup | |
549 | |
550 ;;; Host type conventions: | |
551 ;;; | |
552 ;;; The function ange-ftp-host-type and the variable ange-ftp-dired-host-type | |
553 ;;; (mostly) follow the following conventions for remote host types. At | |
554 ;;; least, I think that future code should try to follow these conventions, | |
555 ;;; and the current code should eventually be made compliant. | |
556 ;;; | |
557 ;;; nil = local host type, whatever that is (probably unix). | |
558 ;;; Think nil as in "not a remote host". This value is used by | |
559 ;;; ange-ftp-dired-host-type for local buffers. | |
560 ;;; | |
561 ;;; t = a remote host of unknown type. Think t is in true, it's remote. | |
562 ;;; Currently, 'unix is used as the default remote host type. | |
563 ;;; Maybe we should use t. | |
564 ;;; | |
565 ;;; 'type = a remote host of TYPE type. | |
566 ;;; | |
567 ;;; 'type:list = a remote host of TYPE type, using a specialized ftp listing | |
568 ;;; program called list. This is currently only used for Unix | |
569 ;;; dl (descriptive listings), when ange-ftp-dired-host-type | |
570 ;;; is set to 'unix:dl. | |
571 | |
572 ;;; Bug report codes: | |
573 ;;; | |
574 ;;; Because of their naive faith in this code, there are certain situations | |
575 ;;; which the writers of this program believe could never happen. However, | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
576 ;;; being realists they have put calls to `error' in the program at these |
1106 | 577 ;;; points. These errors provide a code, which is an integer, greater than 1. |
578 ;;; To aid debugging. the error codes, and the functions in which they reside | |
579 ;;; are listed below. | |
580 ;;; | |
581 ;;; 1: See ange-ftp-ls | |
582 ;;; | |
583 | |
584 ;;; ----------------------------------------------------------- | |
585 ;;; Hall of fame: | |
586 ;;; ----------------------------------------------------------- | |
587 ;;; | |
588 ;;; Thanks to Roland McGrath for improving the filename syntax handling, | |
589 ;;; for suggesting many enhancements and for numerous cleanups to the code. | |
590 ;;; | |
591 ;;; Thanks to Jamie Zawinski for bugfixes and for ideas such as gateways. | |
592 ;;; | |
593 ;;; Thanks to Ken Laprade for improved .netrc parsing, password reading, and | |
594 ;;; dired / shell auto-loading. | |
595 ;;; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
596 ;;; Thanks to Sebastian Kremer for dired support and for many ideas and |
1106 | 597 ;;; bugfixes. |
598 ;;; | |
599 ;;; Thanks to Joe Wells for bugfixes, the original non-UNIX system support, | |
600 ;;; VOS support, and hostname completion. | |
601 ;;; | |
602 ;;; Thanks to Nakagawa Takayuki for many good ideas, filename-completion, help | |
603 ;;; with file-name expansion, efficiency worries, stylistic concerns and many | |
604 ;;; bugfixes. | |
605 ;;; | |
606 ;;; Thanks to Sandy Rutherford who re-wrote most of ange-ftp to support VMS, | |
607 ;;; MTS, CMS and UNIX-dls. Sandy also added dired-support for non-UNIX OS and | |
608 ;;; auto-recognition of the host type. | |
609 ;;; | |
610 ;;; Thanks to Dave Smith who wrote the info file for ange-ftp. | |
611 ;;; | |
612 ;;; Finally, thanks to Keith Waclena, Mark D. Baushke, Terence Kelleher, Ping | |
613 ;;; Zhou, Edward Vielmetti, Jack Repenning, Mike Balenger, Todd Kaufmann, | |
614 ;;; Kjetil Svarstad, Tom Wurgler, Linus Tolke, Niko Makila, Carl Edman, Bill | |
615 ;;; Trost, Dave Brennan, Dan Jacobson, Andy Scott, Steve Anderson, Sanjay | |
616 ;;; Mathur, the folks on the ange-ftp-lovers mailing list and many others | |
617 ;;; whose names I've forgotten who have helped to debug and fix problems with | |
618 ;;; ange-ftp.el. | |
619 | |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
620 |
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
621 ;;; Code: |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
622 (require 'comint) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
623 |
1106 | 624 ;;;; ------------------------------------------------------------ |
625 ;;;; User customization variables. | |
626 ;;;; ------------------------------------------------------------ | |
627 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
628 (defvar ange-ftp-name-format |
1106 | 629 '("^/\\(\\([^@/:]*\\)@\\)?\\([^@/:]*\\):\\(.*\\)" . (3 2 4)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
630 "*Format of a fully expanded remote file name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
631 This is a list of the form \(REGEXP HOST USER NAME\), |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
632 where REGEXP is a regular expression matching |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
633 the full remote name, and HOST, USER, and NAME are the numbers of |
1106 | 634 parenthesized expressions in REGEXP for the components (in that order).") |
635 | |
636 ;; ange-ftp-multi-skip-msgs should only match ###-, where ### is one of | |
637 ;; the number codes corresponding to ange-ftp-good-msgs or ange-ftp-fatal-msgs. | |
638 ;; Otherwise, ange-ftp will go into multi-skip mode, and never come out. | |
639 | |
640 (defvar ange-ftp-multi-msgs | |
3620
219ff1cb76f4
(ange-ftp-multi-msgs): Add 331-.
Richard M. Stallman <rms@gnu.org>
parents:
3611
diff
changeset
|
641 "^220-\\|^230-\\|^226\\|^25.-\\|^221-\\|^200-\\|^331-\\|^4[25]1-\\|^530-" |
7042 | 642 "*Regular expression matching the start of a multiline ftp reply.") |
1106 | 643 |
644 (defvar ange-ftp-good-msgs | |
645 "^220 \\|^230 \\|^226 \\|^25. \\|^221 \\|^200 \\|^[Hh]ash mark" | |
7042 | 646 "*Regular expression matching ftp \"success\" messages.") |
1106 | 647 |
648 ;; CMS and the odd VMS machine say 200 Port rather than 200 PORT. | |
649 ;; Also CMS machines use a multiline 550- reply to say that you | |
650 ;; don't have write permission. ange-ftp gets into multi-line skip | |
651 ;; mode and hangs. Have it ignore 550- instead. It will then barf | |
652 ;; when it gets the 550 line, as it should. | |
653 | |
654 (defvar ange-ftp-skip-msgs | |
655 (concat "^200 \\(PORT\\|Port\\) \\|^331 \\|^150 \\|^350 \\|^[0-9]+ bytes \\|" | |
656 "^Connected \\|^$\\|^Remote system\\|^Using\\|^ \\|Password:\\|" | |
657 "^local:\\|^Trying\\|^125 \\|^550-\\|^221 .*oodbye") | |
7042 | 658 "*Regular expression matching ftp messages that can be ignored.") |
1106 | 659 |
660 (defvar ange-ftp-fatal-msgs | |
661 (concat "^ftp: \\|^Not connected\\|^530 \\|^4[25]1 \\|rcmd: \\|" | |
662 "^No control connection\\|unknown host\\|^lost connection") | |
7042 | 663 "*Regular expression matching ftp messages that indicate serious errors. |
664 These mean that the FTP process should (or already has) been killed.") | |
1106 | 665 |
666 (defvar ange-ftp-gateway-fatal-msgs | |
667 "No route to host\\|Connection closed\\|No such host\\|Login incorrect" | |
7042 | 668 "*Regular expression matching login failure messages from rlogin/telnet.") |
1106 | 669 |
670 (defvar ange-ftp-xfer-size-msgs | |
671 "^150 .* connection for .* (\\([0-9]+\\) bytes)" | |
672 "*Regular expression used to determine the number of bytes in a FTP transfer.") | |
673 | |
674 (defvar ange-ftp-tmp-name-template "/tmp/ange-ftp" | |
675 "*Template used to create temporary files.") | |
676 | |
677 (defvar ange-ftp-gateway-tmp-name-template "/tmp/ange-ftp" | |
678 "*Template used to create temporary files when ftp-ing through a gateway. | |
679 Files starting with this prefix need to be accessible from BOTH the local | |
680 machine and the gateway machine, and need to have the SAME name on both | |
681 machines, that is, /tmp is probably NOT what you want, since that is rarely | |
682 cross-mounted.") | |
683 | |
684 (defvar ange-ftp-netrc-filename "~/.netrc" | |
685 "*File in .netrc format to search for passwords.") | |
686 | |
687 (defvar ange-ftp-disable-netrc-security-check nil | |
688 "*If non-nil avoid checking permissions on the .netrc file.") | |
689 | |
690 (defvar ange-ftp-default-user nil | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
691 "*User name to use when none is specied in a file name. |
1106 | 692 If nil, then the name under which the user is logged in is used. |
693 If non-nil but not a string, the user is prompted for the name.") | |
694 | |
695 (defvar ange-ftp-default-password nil | |
696 "*Password to use when the user is the same as ange-ftp-default-user.") | |
697 | |
698 (defvar ange-ftp-default-account nil | |
699 "*Account password to use when the user is the same as ange-ftp-default-user.") | |
700 | |
1174 | 701 (defvar ange-ftp-generate-anonymous-password t |
9627
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
702 "*If t, use value of `user-mail-address' as password for anonymous ftp. |
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
703 If a string, then use that string as the password. |
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
704 If nil, prompt the user for a password.") |
1106 | 705 |
706 (defvar ange-ftp-dumb-unix-host-regexp nil | |
7042 | 707 "*If non-nil, regexp matching hosts on which `dir' command lists directory.") |
1106 | 708 |
709 (defvar ange-ftp-binary-file-name-regexp | |
2560
50d7841854b3
(ange-ftp-binary-file-name-regexp): Match .z and .z-part-?? files.
Roland McGrath <roland@gnu.org>
parents:
2258
diff
changeset
|
710 (concat "\\.[zZ]$\\|\\.lzh$\\|\\.arc$\\|\\.zip$\\|\\.zoo$\\|\\.tar$\\|" |
1106 | 711 "\\.dvi$\\|\\.ps$\\|\\.elc$\\|TAGS$\\|\\.gif$\\|" |
5171
85aadd2a80ba
(ange-ftp-binary-file-name-regexp): Accept .tgz and .taz files.
Richard M. Stallman <rms@gnu.org>
parents:
5067
diff
changeset
|
712 "\\.EXE\\(;[0-9]+\\)?$\\|\\.[zZ]-part-..$\\|\\.gz$\\|" |
85aadd2a80ba
(ange-ftp-binary-file-name-regexp): Accept .tgz and .taz files.
Richard M. Stallman <rms@gnu.org>
parents:
5067
diff
changeset
|
713 "\\.taz$\\|\\.tgz$") |
1106 | 714 "*If a file matches this regexp then it is transferred in binary mode.") |
715 | |
716 (defvar ange-ftp-gateway-host nil | |
717 "*Name of host to use as gateway machine when local FTP isn't possible.") | |
718 | |
719 (defvar ange-ftp-local-host-regexp ".*" | |
7042 | 720 "*Regexp selecting hosts which can be reached directly with ftp. |
721 For other hosts the FTP process is started on \`ange-ftp-gateway-host\' | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
722 instead, and/or reached via \`ange-ftp-gateway-ftp-program-name\'.") |
1106 | 723 |
724 (defvar ange-ftp-gateway-program-interactive nil | |
7042 | 725 "*If non-nil then the gateway program should give a shell prompt. |
726 Both telnet and rlogin do something like this.") | |
1106 | 727 |
728 (defvar ange-ftp-gateway-program (if (eq system-type 'hpux) "remsh" "rsh") | |
7042 | 729 "*Name of program to spawn a shell on the gateway machine. |
730 Valid candidates are rsh (remsh on hp-ux), telnet and rlogin. See | |
731 also the gateway variable above.") | |
1106 | 732 |
5265
7305f7204c67
(ange-ftp-hash-mark-msgs): Make match more general.
Richard M. Stallman <rms@gnu.org>
parents:
5171
diff
changeset
|
733 (defvar ange-ftp-gateway-prompt-pattern "^[^#$%>;\n]*[#$%>;] *" |
7042 | 734 "*Regexp matching prompt after complete login sequence on gateway machine. |
735 A match for this means the shell is now awaiting input. Make this regexp as | |
1106 | 736 strict as possible; it shouldn't match *anything* at all except the user's |
737 initial prompt. The above string will fail under most SUN-3's since it | |
738 matches the login banner.") | |
739 | |
740 (defvar ange-ftp-gateway-setup-term-command | |
741 (if (eq system-type 'hpux) | |
742 "stty -onlcr -echo\n" | |
743 "stty -echo nl\n") | |
7042 | 744 "*Set up terminal after logging in to the gateway machine. |
745 This command should stop the terminal from echoing each command, and | |
746 arrange to strip out trailing ^M characters.") | |
1106 | 747 |
748 (defvar ange-ftp-smart-gateway nil | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
749 "*Non-nil means the ftp gateway and/or the gateway ftp program is smart. |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
750 Don't bother telnetting, etc., already connected to desired host transparently, |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
751 or just issue a user@host command in case \`ange-ftp-gateway-host\' is non-nil.") |
1106 | 752 |
753 (defvar ange-ftp-smart-gateway-port "21" | |
754 "*Port on gateway machine to use when smart gateway is in operation.") | |
755 | |
756 (defvar ange-ftp-send-hash t | |
757 "*If non-nil, send the HASH command to the FTP client.") | |
758 | |
759 (defvar ange-ftp-binary-hash-mark-size nil | |
760 "*Default size, in bytes, between hash-marks when transferring a binary file. | |
761 If NIL, this variable will be locally overridden if the FTP client outputs a | |
762 suitable response to the HASH command. If non-NIL then this value takes | |
763 precedence over the local value.") | |
764 | |
765 (defvar ange-ftp-ascii-hash-mark-size 1024 | |
766 "*Default size, in bytes, between hash-marks when transferring an ASCII file. | |
767 This variable is buffer-local and will be locally overridden if the FTP client | |
768 outputs a suitable response to the HASH command.") | |
769 | |
770 (defvar ange-ftp-process-verbose t | |
771 "*If non-NIL then be chatty about interaction with the FTP process.") | |
772 | |
773 (defvar ange-ftp-ftp-program-name "ftp" | |
774 "*Name of FTP program to run.") | |
775 | |
776 (defvar ange-ftp-gateway-ftp-program-name "ftp" | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
777 "*Name of FTP program to run when accessing non-local hosts. |
1106 | 778 Some AT&T folks claim to use something called `pftp' here.") |
779 | |
780 (defvar ange-ftp-ftp-program-args '("-i" "-n" "-g" "-v") | |
781 "*A list of arguments passed to the FTP program when started.") | |
782 | |
783 (defvar ange-ftp-nslookup-program nil | |
784 "*If non-NIL then a string naming nslookup program." ) | |
785 | |
786 (defvar ange-ftp-make-backup-files () | |
3416
5bd76dd4c6bd
(ange-ftp-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3394
diff
changeset
|
787 "*Non-nil means make backup files for \"magic\" remote files.") |
1106 | 788 |
789 (defvar ange-ftp-retry-time 5 | |
7042 | 790 "*Number of seconds to wait before retry if file or listing doesn't arrive. |
791 This might need to be increased for very slow connections.") | |
1106 | 792 |
793 (defvar ange-ftp-auto-save 0 | |
794 "If 1, allows ange-ftp files to be auto-saved. | |
795 If 0, suppresses auto-saving of ange-ftp files. | |
796 Don't use any other value.") | |
797 | |
798 ;;;; ------------------------------------------------------------ | |
799 ;;;; Hash table support. | |
800 ;;;; ------------------------------------------------------------ | |
801 | |
802 (require 'backquote) | |
803 | |
804 (defun ange-ftp-make-hashtable (&optional size) | |
805 "Make an obarray suitable for use as a hashtable. | |
806 SIZE, if supplied, should be a prime number." | |
807 (make-vector (or size 31) 0)) | |
808 | |
809 (defun ange-ftp-map-hashtable (fun tbl) | |
810 "Call FUNCTION on each key and value in HASHTABLE." | |
811 (mapatoms | |
812 (function | |
813 (lambda (sym) | |
814 (funcall fun (get sym 'key) (get sym 'val)))) | |
815 tbl)) | |
816 | |
817 (defmacro ange-ftp-make-hash-key (key) | |
818 "Convert KEY into a suitable key for a hashtable." | |
819 (` (if (stringp (, key)) | |
820 (, key) | |
821 (prin1-to-string (, key))))) | |
822 | |
823 (defun ange-ftp-get-hash-entry (key tbl) | |
824 "Return the value associated with KEY in HASHTABLE." | |
825 (let ((sym (intern-soft (ange-ftp-make-hash-key key) tbl))) | |
826 (and sym (get sym 'val)))) | |
827 | |
828 (defun ange-ftp-put-hash-entry (key val tbl) | |
829 "Record an association between KEY and VALUE in HASHTABLE." | |
830 (let ((sym (intern (ange-ftp-make-hash-key key) tbl))) | |
831 (put sym 'val val) | |
832 (put sym 'key key))) | |
833 | |
834 (defun ange-ftp-del-hash-entry (key tbl) | |
835 "Copy all symbols except KEY in HASHTABLE and return modified hashtable." | |
836 (let* ((len (length tbl)) | |
837 (new-tbl (ange-ftp-make-hashtable len)) | |
838 (i (1- len))) | |
839 (ange-ftp-map-hashtable | |
840 (function | |
841 (lambda (k v) | |
842 (or (equal k key) | |
843 (ange-ftp-put-hash-entry k v new-tbl)))) | |
844 tbl) | |
845 (while (>= i 0) | |
846 (aset tbl i (aref new-tbl i)) | |
847 (setq i (1- i))) | |
848 tbl)) | |
849 | |
850 (defun ange-ftp-hash-entry-exists-p (key tbl) | |
851 "Return whether there is an association for KEY in TABLE." | |
852 (intern-soft (ange-ftp-make-hash-key key) tbl)) | |
853 | |
854 (defun ange-ftp-hash-table-keys (tbl) | |
1233 | 855 "Return a sorted list of all the active keys in TABLE, as strings." |
1106 | 856 (sort (all-completions "" tbl) |
857 (function string-lessp))) | |
858 | |
859 ;;;; ------------------------------------------------------------ | |
860 ;;;; Internal variables. | |
861 ;;;; ------------------------------------------------------------ | |
862 | |
863 (defvar ange-ftp-data-buffer-name " *ftp data*" | |
864 "Buffer name to hold directory listing data received from ftp process.") | |
865 | |
866 (defvar ange-ftp-netrc-modtime nil | |
867 "Last modified time of the netrc file from file-attributes.") | |
868 | |
869 (defvar ange-ftp-user-hashtable (ange-ftp-make-hashtable) | |
870 "Hash table holding associations between HOST, USER pairs.") | |
871 | |
872 (defvar ange-ftp-passwd-hashtable (ange-ftp-make-hashtable) | |
873 "Mapping between a HOST, USER pair and a PASSWORD for them.") | |
874 | |
875 (defvar ange-ftp-account-hashtable (ange-ftp-make-hashtable) | |
876 "Mapping between a HOST, USER pair and a ACCOUNT password for them.") | |
877 | |
878 (defvar ange-ftp-files-hashtable (ange-ftp-make-hashtable 97) | |
879 "Hash table for storing directories and their respective files.") | |
880 | |
881 (defvar ange-ftp-ls-cache-lsargs nil | |
882 "Last set of args used by ange-ftp-ls.") | |
883 | |
884 (defvar ange-ftp-ls-cache-file nil | |
885 "Last file passed to ange-ftp-ls.") | |
886 | |
887 (defvar ange-ftp-ls-cache-res nil | |
888 "Last result returned from ange-ftp-ls.") | |
889 | |
890 (defconst ange-ftp-expand-dir-hashtable (ange-ftp-make-hashtable)) | |
891 | |
892 (defconst ange-ftp-expand-dir-regexp "^5.0 \\([^: ]+\\):") | |
893 | |
894 ;; These are local variables in each FTP process buffer. | |
895 (defvar ange-ftp-hash-mark-unit nil) | |
896 (defvar ange-ftp-hash-mark-count nil) | |
897 (defvar ange-ftp-xfer-size nil) | |
898 (defvar ange-ftp-process-string nil) | |
899 (defvar ange-ftp-process-result-line nil) | |
900 (defvar ange-ftp-process-busy nil) | |
901 (defvar ange-ftp-process-result nil) | |
902 (defvar ange-ftp-process-multi-skip nil) | |
903 (defvar ange-ftp-process-msg nil) | |
904 (defvar ange-ftp-process-continue nil) | |
905 (defvar ange-ftp-last-percent nil) | |
906 | |
907 ;; These variables are bound by one function and examined by another. | |
908 ;; Leave them void globally for error checking. | |
909 (defvar ange-ftp-this-file) | |
910 (defvar ange-ftp-this-dir) | |
911 (defvar ange-ftp-this-user) | |
912 (defvar ange-ftp-this-host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
913 (defvar ange-ftp-this-msg) |
1106 | 914 (defvar ange-ftp-completion-ignored-pattern) |
915 (defvar ange-ftp-trample-marker) | |
916 | |
917 ;; New error symbols. | |
918 (put 'ftp-error 'error-conditions '(ftp-error file-error error)) | |
919 ;; (put 'ftp-error 'error-message "FTP error") | |
920 | |
921 ;;; ------------------------------------------------------------ | |
922 ;;; Enhanced message support. | |
923 ;;; ------------------------------------------------------------ | |
924 | |
925 (defun ange-ftp-message (fmt &rest args) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
926 "Display message in echo area, but indicate if truncated. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
927 Args are as in `message': a format string, plus arguments to be formatted." |
1106 | 928 (let ((msg (apply (function format) fmt args)) |
929 (max (window-width (minibuffer-window)))) | |
930 (if (>= (length msg) max) | |
931 (setq msg (concat "> " (substring msg (- 3 max))))) | |
932 (message "%s" msg))) | |
933 | |
934 (defun ange-ftp-abbreviate-filename (file &optional new) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
935 "Abbreviate the file name FILE relative to the default-directory. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
936 If the optional parameter NEW is given and the non-directory parts match, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
937 only return the directory part of FILE." |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
938 (save-match-data |
1106 | 939 (if (and default-directory |
940 (string-match (concat "^" | |
941 (regexp-quote default-directory) | |
942 ".") file)) | |
943 (setq file (substring file (1- (match-end 0))))) | |
944 (if (and new | |
945 (string-equal (file-name-nondirectory file) | |
946 (file-name-nondirectory new))) | |
947 (setq file (file-name-directory file))) | |
948 (or file "./"))) | |
949 | |
950 ;;;; ------------------------------------------------------------ | |
951 ;;;; User / Host mapping support. | |
952 ;;;; ------------------------------------------------------------ | |
953 | |
954 (defun ange-ftp-set-user (host user) | |
955 "For a given HOST, set or change the default USER." | |
956 (interactive "sHost: \nsUser: ") | |
957 (ange-ftp-put-hash-entry host user ange-ftp-user-hashtable)) | |
958 | |
959 (defun ange-ftp-get-user (host) | |
960 "Given a HOST, return the default USER." | |
961 (ange-ftp-parse-netrc) | |
962 (let ((user (ange-ftp-get-hash-entry host ange-ftp-user-hashtable))) | |
963 (or user | |
964 (prog1 | |
965 (setq user | |
966 (cond ((stringp ange-ftp-default-user) | |
967 ;; We have a default name. Use it. | |
968 ange-ftp-default-user) | |
969 (ange-ftp-default-user | |
970 ;; Ask the user. | |
971 (let ((enable-recursive-minibuffers t)) | |
972 (read-string (format "User for %s: " host) | |
973 (user-login-name)))) | |
974 ;; Default to the user's login name. | |
975 (t | |
976 (user-login-name)))) | |
977 (ange-ftp-set-user host user))))) | |
978 | |
979 ;;;; ------------------------------------------------------------ | |
980 ;;;; Password support. | |
981 ;;;; ------------------------------------------------------------ | |
982 | |
983 (defun ange-ftp-read-passwd (prompt &optional default) | |
984 "Read a password, echoing `.' for each character typed. | |
985 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. | |
986 Optional DEFAULT is password to start with." | |
987 (let ((pass (if default default "")) | |
988 (c 0) | |
989 (echo-keystrokes 0) | |
990 (cursor-in-echo-area t)) | |
991 (while (progn (message "%s%s" | |
992 prompt | |
993 (make-string (length pass) ?.)) | |
994 (setq c (read-char)) | |
995 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) | |
996 (if (= c ?\C-u) | |
997 (setq pass "") | |
998 (if (and (/= c ?\b) (/= c ?\177)) | |
999 (setq pass (concat pass (char-to-string c))) | |
1000 (if (> (length pass) 0) | |
1001 (setq pass (substring pass 0 -1)))))) | |
1002 (message "") | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1003 (ange-ftp-repaint-minibuffer) |
1106 | 1004 pass)) |
1005 | |
1006 (defmacro ange-ftp-generate-passwd-key (host user) | |
1007 (` (concat (, host) "/" (, user)))) | |
1008 | |
1009 (defmacro ange-ftp-lookup-passwd (host user) | |
1010 (` (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key (, host) (, user)) | |
1011 ange-ftp-passwd-hashtable))) | |
1012 | |
1013 (defun ange-ftp-set-passwd (host user passwd) | |
1014 "For a given HOST and USER, set or change the associated PASSWORD." | |
1015 (interactive (list (read-string "Host: ") | |
1016 (read-string "User: ") | |
1017 (ange-ftp-read-passwd "Password: "))) | |
1018 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1019 passwd | |
1020 ange-ftp-passwd-hashtable)) | |
1021 | |
1022 (defun ange-ftp-get-host-with-passwd (user) | |
1023 "Given a USER, return a host we know the password for." | |
1024 (ange-ftp-parse-netrc) | |
1025 (catch 'found-one | |
1026 (ange-ftp-map-hashtable | |
1027 (function (lambda (host val) | |
1028 (if (ange-ftp-lookup-passwd host user) | |
1029 (throw 'found-one host)))) | |
1030 ange-ftp-user-hashtable) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1031 (save-match-data |
1106 | 1032 (ange-ftp-map-hashtable |
1033 (function | |
1034 (lambda (key value) | |
1035 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1036 (let ((host (substring key 0 (match-beginning 1)))) | |
1037 (if (and (string-equal user (substring key (match-end 1))) | |
1038 value) | |
1039 (throw 'found-one host)))))) | |
1040 ange-ftp-passwd-hashtable)) | |
1041 nil)) | |
1042 | |
1043 (defun ange-ftp-get-passwd (host user) | |
1044 "Return the password for specified HOST and USER, asking user if necessary." | |
1045 (ange-ftp-parse-netrc) | |
1046 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
1047 ;; look up password in the hash table first; user might have overridden the |
1106 | 1048 ;; defaults. |
1049 (cond ((ange-ftp-lookup-passwd host user)) | |
1050 | |
1051 ;; see if default user and password set from the .netrc file. | |
1052 ((and (stringp ange-ftp-default-user) | |
1053 ange-ftp-default-password | |
1054 (string-equal user ange-ftp-default-user)) | |
1055 ange-ftp-default-password) | |
1056 | |
1057 ;; anonymous ftp password is handled specially since there is an | |
1058 ;; unwritten rule about how that is used on the Internet. | |
1059 ((and (or (string-equal user "anonymous") | |
1060 (string-equal user "ftp")) | |
1061 ange-ftp-generate-anonymous-password) | |
1062 (if (stringp ange-ftp-generate-anonymous-password) | |
1063 ange-ftp-generate-anonymous-password | |
9627
449fc86a0f4f
(ange-ftp-get-passwd): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
9070
diff
changeset
|
1064 user-mail-address)) |
1106 | 1065 |
1066 ;; see if same user has logged in to other hosts; if so then prompt | |
1067 ;; with the password that was used there. | |
1068 (t | |
1069 (let* ((other (ange-ftp-get-host-with-passwd user)) | |
1070 (passwd (if other | |
1071 | |
1072 ;; found another machine with the same user. | |
1073 ;; Try that account. | |
1074 (ange-ftp-read-passwd | |
1075 (format "passwd for %s@%s (same as %s@%s): " | |
1076 user host user other) | |
1077 (ange-ftp-lookup-passwd other user)) | |
1078 | |
1079 ;; I give up. Ask the user for the password. | |
1080 (ange-ftp-read-passwd | |
1081 (format "Password for %s@%s: " user host))))) | |
1082 (ange-ftp-set-passwd host user passwd) | |
1083 passwd)))) | |
1084 | |
1085 ;;;; ------------------------------------------------------------ | |
1086 ;;;; Account support | |
1087 ;;;; ------------------------------------------------------------ | |
1088 | |
1089 ;; Account passwords must be either specified in the .netrc file, or set | |
1090 ;; manually by calling ange-ftp-set-account. For the moment, ange-ftp doesn't | |
1091 ;; check to see whether the FTP process is actually prompting for an account | |
1092 ;; password. | |
1093 | |
1094 (defun ange-ftp-set-account (host user account) | |
1095 "For a given HOST and USER, set or change the associated ACCOUNT password." | |
1096 (interactive (list (read-string "Host: ") | |
1097 (read-string "User: ") | |
1098 (ange-ftp-read-passwd "Account password: "))) | |
1099 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) | |
1100 account | |
1101 ange-ftp-account-hashtable)) | |
1102 | |
1103 (defun ange-ftp-get-account (host user) | |
1104 "Given a HOST and USER, return the FTP account." | |
1105 (ange-ftp-parse-netrc) | |
1106 (or (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key host user) | |
1107 ange-ftp-account-hashtable) | |
1108 (and (stringp ange-ftp-default-user) | |
1109 (string-equal user ange-ftp-default-user) | |
1110 ange-ftp-default-account))) | |
1111 | |
1112 ;;;; ------------------------------------------------------------ | |
1113 ;;;; ~/.netrc support | |
1114 ;;;; ------------------------------------------------------------ | |
1115 | |
1116 (defun ange-ftp-chase-symlinks (file) | |
1233 | 1117 "Return the filename that FILE references, following all symbolic links." |
1106 | 1118 (let (temp) |
1119 (while (setq temp (ange-ftp-real-file-symlink-p file)) | |
1120 (setq file | |
1121 (if (file-name-absolute-p temp) | |
1122 temp | |
1123 (concat (file-name-directory file) temp))))) | |
1124 file) | |
1125 | |
7042 | 1126 ;; Move along current line looking for the value of the TOKEN. |
1127 ;; Valid separators between TOKEN and its value are commas and | |
1128 ;; whitespace. Second arg LIMIT is a limit for the search. | |
1129 | |
1106 | 1130 (defun ange-ftp-parse-netrc-token (token limit) |
1131 (if (search-forward token limit t) | |
1132 (let (beg) | |
1133 (skip-chars-forward ", \t\r\n" limit) | |
1134 (if (eq (following-char) ?\") ;quoted token value | |
1135 (progn (forward-char 1) | |
1136 (setq beg (point)) | |
1137 (skip-chars-forward "^\"" limit) | |
1138 (forward-char 1) | |
1139 (buffer-substring beg (1- (point)))) | |
1140 (setq beg (point)) | |
1141 (skip-chars-forward "^, \t\r\n" limit) | |
1142 (buffer-substring beg (point)))))) | |
1143 | |
7042 | 1144 ;; Extract the values for the tokens `machine', `login', |
1145 ;; `password' and `account' in the current buffer. If successful, | |
1146 ;; record the information found. | |
1147 | |
1106 | 1148 (defun ange-ftp-parse-netrc-group () |
1149 (let ((start (point)) | |
8397
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1150 (end (save-excursion |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1151 (if (looking-at "machine\\>") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1152 ;; Skip `machine' and the machine name that follows. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1153 (progn |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1154 (skip-chars-forward "^ \t\n") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1155 (skip-chars-forward " \t\n") |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1156 (skip-chars-forward "^ \t\n")) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1157 ;; Skip `default'. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1158 (skip-chars-forward "^ \t\n")) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1159 ;; Find start of the next `machine' or `default' |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1160 ;; or the end of the buffer. |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1161 (if (re-search-forward "machine\\>\\|default\\>" nil t) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1162 (match-beginning 0) |
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1163 (point-max)))) |
1106 | 1164 machine login password account) |
1165 (setq machine (ange-ftp-parse-netrc-token "machine" end) | |
1166 login (ange-ftp-parse-netrc-token "login" end) | |
1167 password (ange-ftp-parse-netrc-token "password" end) | |
1168 account (ange-ftp-parse-netrc-token "account" end)) | |
1169 (if (and machine login) | |
1170 ;; found a `machine` token. | |
1171 (progn | |
1172 (ange-ftp-set-user machine login) | |
1173 (ange-ftp-set-passwd machine login password) | |
1174 (and account | |
1175 (ange-ftp-set-account machine login account))) | |
1176 (goto-char start) | |
1177 (if (search-forward "default" end t) | |
1178 ;; found a `default' token | |
1179 (progn | |
1180 (setq login (ange-ftp-parse-netrc-token "login" end) | |
1181 password (ange-ftp-parse-netrc-token "password" end) | |
1182 account (ange-ftp-parse-netrc-token "account" end)) | |
1183 (and login | |
1184 (setq ange-ftp-default-user login)) | |
1185 (and password | |
1186 (setq ange-ftp-default-password password)) | |
1187 (and account | |
1188 (setq ange-ftp-default-account account))))) | |
1189 (goto-char end))) | |
1190 | |
7042 | 1191 ;; Read in ~/.netrc, if one exists. If ~/.netrc file exists and has |
1192 ;; the correct permissions then extract the \`machine\', \`login\', | |
1193 ;; \`password\' and \`account\' information from within. | |
1194 | |
1106 | 1195 (defun ange-ftp-parse-netrc () |
1196 ;; We set this before actually doing it to avoid the possibility | |
1197 ;; of an infinite loop if ange-ftp-netrc-filename is an FTP file. | |
1198 (interactive) | |
1199 (let* ((file (ange-ftp-chase-symlinks | |
1200 (ange-ftp-real-expand-file-name ange-ftp-netrc-filename))) | |
1201 (attr (ange-ftp-real-file-attributes file))) | |
1202 (if (and attr ; file exists. | |
1203 (not (equal (nth 5 attr) ange-ftp-netrc-modtime))) ; file changed | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1204 (save-match-data |
1106 | 1205 (if (or ange-ftp-disable-netrc-security-check |
1206 (and (eq (nth 2 attr) (user-uid)) ; Same uids. | |
1207 (string-match ".r..------" (nth 8 attr)))) | |
1208 (save-excursion | |
1209 ;; we are cheating a bit here. I'm trying to do the equivalent | |
1210 ;; of find-file on the .netrc file, but then nuke it afterwards. | |
1211 ;; with the bit of logic below we should be able to have | |
1212 ;; encrypted .netrc files. | |
1213 (set-buffer (generate-new-buffer "*ftp-.netrc*")) | |
1214 (ange-ftp-real-insert-file-contents file) | |
1215 (setq buffer-file-name file) | |
1216 (setq default-directory (file-name-directory file)) | |
1217 (normal-mode t) | |
1218 (mapcar 'funcall find-file-hooks) | |
1219 (setq buffer-file-name nil) | |
1220 (goto-char (point-min)) | |
8397
4cb8a2ab8f60
(ange-ftp-parse-netrc-group): Don't move back to line
Richard M. Stallman <rms@gnu.org>
parents:
7923
diff
changeset
|
1221 (skip-chars-forward " \t\n") |
1106 | 1222 (while (not (eobp)) |
1223 (ange-ftp-parse-netrc-group)) | |
1224 (kill-buffer (current-buffer))) | |
1225 (ange-ftp-message "%s either not owned by you or badly protected." | |
1226 ange-ftp-netrc-filename) | |
1227 (sit-for 1)) | |
1228 (setq ange-ftp-netrc-modtime (nth 5 attr)))))) | |
1229 | |
7042 | 1230 ;; Return a list of prefixes of the form 'user@host:' to be used when |
1231 ;; completion is done in the root directory. | |
1232 | |
1106 | 1233 (defun ange-ftp-generate-root-prefixes () |
1234 (ange-ftp-parse-netrc) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1235 (save-match-data |
1106 | 1236 (let (res) |
1237 (ange-ftp-map-hashtable | |
1238 (function | |
1239 (lambda (key value) | |
1240 (if (string-match "^[^/]*\\(/\\).*$" key) | |
1241 (let ((host (substring key 0 (match-beginning 1))) | |
1242 (user (substring key (match-end 1)))) | |
1243 (setq res (cons (list (concat user "@" host ":")) | |
1244 res)))))) | |
1245 ange-ftp-passwd-hashtable) | |
1246 (ange-ftp-map-hashtable | |
1247 (function (lambda (host user) | |
1248 (setq res (cons (list (concat host ":")) | |
1249 res)))) | |
1250 ange-ftp-user-hashtable) | |
1251 (or res (list nil))))) | |
1252 | |
1253 ;;;; ------------------------------------------------------------ | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1254 ;;;; Remote file name syntax support. |
1106 | 1255 ;;;; ------------------------------------------------------------ |
1256 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1257 (defmacro ange-ftp-ftp-name-component (n ns name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1258 "Extract the Nth ftp file name component from NS." |
1106 | 1259 (` (let ((elt (nth (, n) (, ns)))) |
1260 (if (match-beginning elt) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1261 (substring (, name) (match-beginning elt) (match-end elt)))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1262 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1263 (defvar ange-ftp-ftp-name-arg "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1264 (defvar ange-ftp-ftp-name-res nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1265 |
7042 | 1266 ;; Parse NAME according to `ange-ftp-name-format' (which see). |
1267 ;; Returns a list (HOST USER NAME), or nil if NAME does not match the format. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1268 (defun ange-ftp-ftp-name (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1269 (if (string-equal name ange-ftp-ftp-name-arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1270 ange-ftp-ftp-name-res |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1271 (setq ange-ftp-ftp-name-arg name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1272 ange-ftp-ftp-name-res |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1273 (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1274 (if (string-match (car ange-ftp-name-format) name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1275 (let* ((ns (cdr ange-ftp-name-format)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1276 (host (ange-ftp-ftp-name-component 0 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1277 (user (ange-ftp-ftp-name-component 1 ns name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1278 (name (ange-ftp-ftp-name-component 2 ns name))) |
1106 | 1279 (if (zerop (length user)) |
1280 (setq user (ange-ftp-get-user host))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1281 (list host user name)) |
1106 | 1282 nil))))) |
1283 | |
7042 | 1284 ;; Take a FULLNAME that matches according to ange-ftp-name-format and |
1285 ;; replace the name component with NAME. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1286 (defun ange-ftp-replace-name-component (fullname name) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1287 (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1288 (if (string-match (car ange-ftp-name-format) fullname) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1289 (let* ((ns (cdr ange-ftp-name-format)) |
1106 | 1290 (elt (nth 2 ns))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1291 (concat (substring fullname 0 (match-beginning elt)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1292 name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1293 (substring fullname (match-end elt))))))) |
1106 | 1294 |
1295 ;;;; ------------------------------------------------------------ | |
1296 ;;;; Miscellaneous utils. | |
1297 ;;;; ------------------------------------------------------------ | |
1298 | |
1299 ;; (setq ange-ftp-tmp-keymap (make-sparse-keymap)) | |
1300 ;; (define-key ange-ftp-tmp-keymap "\C-m" 'exit-minibuffer) | |
1301 | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1302 (defun ange-ftp-repaint-minibuffer () |
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1303 "Clear any existing minibuffer message; let the minibuffer contents show." |
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1304 (message nil)) |
1106 | 1305 |
7042 | 1306 ;; Return the name of the buffer that collects output from the ftp process |
1307 ;; connected to the given HOST and USER pair. | |
1106 | 1308 (defun ange-ftp-ftp-process-buffer (host user) |
1309 (concat "*ftp " user "@" host "*")) | |
1310 | |
7042 | 1311 ;; Display the last chunk of output from the ftp process for the given HOST |
1312 ;; USER pair, and signal an error including MSG in the text. | |
1106 | 1313 (defun ange-ftp-error (host user msg) |
1314 (let ((cur (selected-window)) | |
1315 (pop-up-windows t)) | |
1316 (pop-to-buffer | |
1317 (get-buffer-create | |
1318 (ange-ftp-ftp-process-buffer host user))) | |
1319 (goto-char (point-max)) | |
1320 (select-window cur)) | |
1321 (signal 'ftp-error (list (format "FTP Error: %s" msg)))) | |
1322 | |
1323 (defun ange-ftp-set-buffer-mode () | |
3230
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
1324 "Set correct modes for the current buffer if visiting a remote file." |
1106 | 1325 (if (and (stringp buffer-file-name) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1326 (ange-ftp-ftp-name buffer-file-name)) |
1106 | 1327 (progn |
3230
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
1328 (make-local-variable 'make-backup-files) |
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
1329 (setq make-backup-files ange-ftp-make-backup-files) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
1330 (auto-save-mode ange-ftp-auto-save)))) |
1106 | 1331 |
1332 (defun ange-ftp-kill-ftp-process (buffer) | |
1242
82774f4b69dd
(ange-ftp-kill-ftp-process): Delete spurious ".
Richard M. Stallman <rms@gnu.org>
parents:
1233
diff
changeset
|
1333 "Kill the FTP process associated with BUFFER. |
1233 | 1334 If the BUFFER's visited filename or default-directory is an ftp filename |
1106 | 1335 then kill the related ftp process." |
1336 (interactive "bKill FTP process associated with buffer: ") | |
1337 (if (null buffer) | |
1338 (setq buffer (current-buffer))) | |
1339 (let ((file (or (buffer-file-name) default-directory))) | |
1340 (if file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1341 (let ((parsed (ange-ftp-ftp-name (expand-file-name file)))) |
1106 | 1342 (if parsed |
1343 (let ((host (nth 0 parsed)) | |
1344 (user (nth 1 parsed))) | |
1345 (kill-buffer (ange-ftp-ftp-process-buffer host user)))))))) | |
1346 | |
1347 (defun ange-ftp-quote-string (string) | |
1348 "Quote any characters in STRING that may confuse the ftp process." | |
1349 (apply (function concat) | |
1350 (mapcar (function | |
1351 (lambda (char) | |
1352 (if (or (<= char ? ) | |
1353 (> char ?\~) | |
1354 (= char ?\") | |
1355 (= char ?\\)) | |
1356 (vector ?\\ char) | |
1357 (vector char)))) | |
1358 string))) | |
1359 | |
1360 (defun ange-ftp-barf-if-not-directory (directory) | |
1361 (or (file-directory-p directory) | |
1362 (signal 'file-error | |
1363 (list "Opening directory" | |
1364 (if (file-exists-p directory) | |
1365 "not a directory" | |
1366 "no such file or directory") | |
1367 directory)))) | |
1368 | |
1369 ;;;; ------------------------------------------------------------ | |
1370 ;;;; FTP process filter support. | |
1371 ;;;; ------------------------------------------------------------ | |
1372 | |
1373 (defun ange-ftp-process-handle-line (line proc) | |
7042 | 1374 "Look at the given LINE from the ftp process PROC. |
1375 Try to categorize it into one of four categories: | |
1376 good, skip, fatal, or unknown." | |
1106 | 1377 (cond ((string-match ange-ftp-xfer-size-msgs line) |
1378 (setq ange-ftp-xfer-size | |
1379 (ash (string-to-int (substring line | |
1380 (match-beginning 1) | |
1381 (match-end 1))) | |
1382 -10))) | |
1383 ((string-match ange-ftp-skip-msgs line) | |
1384 t) | |
1385 ((string-match ange-ftp-good-msgs line) | |
1386 (setq ange-ftp-process-busy nil | |
1387 ange-ftp-process-result t | |
1388 ange-ftp-process-result-line line)) | |
9664 | 1389 ;; Check this before checking for errors. |
1390 ;; Otherwise the last line of these three seems to be an error: | |
1391 ;; 230-see a significant impact from the move. For those of you who can't | |
1392 ;; 230-use DNS to resolve hostnames and get an error message like | |
1393 ;; 230-"ftp.stsci.edu: unknown host", the new IP address will be... | |
9662
ca4987708cc0
(ange-ftp-process-handle-line): Check for a
Richard M. Stallman <rms@gnu.org>
parents:
9627
diff
changeset
|
1394 ((string-match ange-ftp-multi-msgs line) |
ca4987708cc0
(ange-ftp-process-handle-line): Check for a
Richard M. Stallman <rms@gnu.org>
parents:
9627
diff
changeset
|
1395 (setq ange-ftp-process-multi-skip t)) |
1106 | 1396 ((string-match ange-ftp-fatal-msgs line) |
1397 (delete-process proc) | |
1398 (setq ange-ftp-process-busy nil | |
1399 ange-ftp-process-result-line line)) | |
1400 (ange-ftp-process-multi-skip | |
1401 t) | |
1402 (t | |
1403 (setq ange-ftp-process-busy nil | |
1404 ange-ftp-process-result-line line)))) | |
1405 | |
1406 (defun ange-ftp-set-xfer-size (host user bytes) | |
1407 "Set the size of the next FTP transfer in bytes." | |
1408 (let ((proc (ange-ftp-get-process host user))) | |
1409 (if proc | |
1410 (let ((buf (process-buffer proc))) | |
1411 (if buf | |
1412 (save-excursion | |
1413 (set-buffer buf) | |
1414 (setq ange-ftp-xfer-size (ash bytes -10)))))))) | |
1415 | |
1416 (defun ange-ftp-process-handle-hash (str) | |
1417 "Remove hash marks from STRING and display count so far." | |
1418 (setq str (concat (substring str 0 (match-beginning 0)) | |
1419 (substring str (match-end 0))) | |
1420 ange-ftp-hash-mark-count (+ (- (match-end 0) | |
1421 (match-beginning 0)) | |
1422 ange-ftp-hash-mark-count)) | |
1423 (and ange-ftp-process-msg | |
1424 ange-ftp-process-verbose | |
1425 (not (eq (selected-window) (minibuffer-window))) | |
1426 (not (boundp 'search-message)) ;screws up isearch otherwise | |
1427 (not cursor-in-echo-area) ;screws up y-or-n-p otherwise | |
1428 (let ((kbytes (ash (* ange-ftp-hash-mark-unit | |
1429 ange-ftp-hash-mark-count) | |
1430 -6))) | |
1431 (if (zerop ange-ftp-xfer-size) | |
1432 (ange-ftp-message "%s...%dk" ange-ftp-process-msg kbytes) | |
1433 (let ((percent (/ (* 100 kbytes) ange-ftp-xfer-size))) | |
1434 ;; cut out the redisplay of identical %-age messages. | |
1435 (if (not (eq percent ange-ftp-last-percent)) | |
1436 (progn | |
1437 (setq ange-ftp-last-percent percent) | |
1438 (ange-ftp-message "%s...%d%%" ange-ftp-process-msg percent))))))) | |
1439 str) | |
1440 | |
7042 | 1441 ;; Call the function specified by CONT. CONT can be either a function |
1442 ;; or a list of a function and some args. The first two parameters | |
1443 ;; passed to the function will be RESULT and LINE. The remaining args | |
1444 ;; will be taken from CONT if a list was passed. | |
1445 | |
1106 | 1446 (defun ange-ftp-call-cont (cont result line) |
1447 (if cont | |
1448 (if (and (listp cont) | |
1449 (not (eq (car cont) 'lambda))) | |
1450 (apply (car cont) result line (cdr cont)) | |
1451 (funcall cont result line)))) | |
1452 | |
7042 | 1453 ;; Build up a complete line of output from the ftp PROCESS and pass it |
1454 ;; on to ange-ftp-process-handle-line to deal with. | |
1455 | |
1106 | 1456 (defun ange-ftp-process-filter (proc str) |
1457 (let ((buffer (process-buffer proc)) | |
1458 (old-buffer (current-buffer))) | |
1459 | |
1460 ;; see if the buffer is still around... it could have been deleted. | |
1461 (if (buffer-name buffer) | |
1462 (unwind-protect | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1463 (progn |
1106 | 1464 (set-buffer (process-buffer proc)) |
1465 | |
1466 ;; handle hash mark printing | |
1467 (and ange-ftp-hash-mark-unit | |
1468 ange-ftp-process-busy | |
1469 (string-match "^#+$" str) | |
1470 (setq str (ange-ftp-process-handle-hash str))) | |
6822
69c4ca88cf5e
(ange-ftp-process-filter, ange-ftp-gwp-filter): Call comint-output-filter.
Karl Heuer <kwzh@gnu.org>
parents:
6309
diff
changeset
|
1471 (comint-output-filter proc str) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1472 ;; Replace STR by the result of the comint processing. |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1473 (setq str (buffer-substring comint-last-output-start |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1474 (process-mark proc))) |
1106 | 1475 (if ange-ftp-process-busy |
1476 (progn | |
1477 (setq ange-ftp-process-string (concat ange-ftp-process-string | |
1478 str)) | |
1479 | |
1480 ;; if we gave an empty password to the USER command earlier | |
1481 ;; then we should send a null password now. | |
1482 (if (string-match "Password: *$" ange-ftp-process-string) | |
1483 (send-string proc "\n")))) | |
1484 (while (and ange-ftp-process-busy | |
1485 (string-match "\n" ange-ftp-process-string)) | |
1486 (let ((line (substring ange-ftp-process-string | |
1487 0 | |
1488 (match-beginning 0)))) | |
1489 (setq ange-ftp-process-string (substring ange-ftp-process-string | |
1490 (match-end 0))) | |
1491 (while (string-match "^ftp> *" line) | |
1492 (setq line (substring line (match-end 0)))) | |
1493 (ange-ftp-process-handle-line line proc))) | |
1494 | |
1495 ;; has the ftp client finished? if so then do some clean-up | |
1496 ;; actions. | |
1497 (if (not ange-ftp-process-busy) | |
1498 (progn | |
1499 ;; reset the xfer size | |
1500 (setq ange-ftp-xfer-size 0) | |
1501 | |
1502 ;; issue the "done" message since we've finished. | |
1503 (if (and ange-ftp-process-msg | |
1504 ange-ftp-process-verbose | |
1505 ange-ftp-process-result) | |
1506 (progn | |
1507 (ange-ftp-message "%s...done" ange-ftp-process-msg) | |
1603
3e621a2a9cfe
* ange-ftp.el (ange-ftp-repaint-buffer): Give this a non-hacky
Jim Blandy <jimb@redhat.com>
parents:
1535
diff
changeset
|
1508 (ange-ftp-repaint-minibuffer) |
1106 | 1509 (setq ange-ftp-process-msg nil))) |
1510 | |
1511 ;; is there a continuation we should be calling? if so, | |
1512 ;; we'd better call it, making sure we only call it once. | |
1513 (if ange-ftp-process-continue | |
1514 (let ((cont ange-ftp-process-continue)) | |
1515 (setq ange-ftp-process-continue nil) | |
1516 (ange-ftp-call-cont cont | |
1517 ange-ftp-process-result | |
1518 ange-ftp-process-result-line)))))) | |
1519 (set-buffer old-buffer))))) | |
1520 | |
1521 (defun ange-ftp-process-sentinel (proc str) | |
1522 "When ftp process changes state, nuke all file-entries in cache." | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1523 (let ((name (process-name proc))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1524 (if (string-match "\\*ftp \\([^@]+\\)@\\([^*]+\\)*" name) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1525 (let ((user (substring name (match-beginning 1) (match-end 1))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1526 (host (substring name (match-beginning 2) (match-end 2)))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1527 (ange-ftp-wipe-file-entries host user)))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1528 (setq ange-ftp-ls-cache-file nil)) |
1106 | 1529 |
1530 ;;;; ------------------------------------------------------------ | |
1531 ;;;; Gateway support. | |
1532 ;;;; ------------------------------------------------------------ | |
1533 | |
1534 (defun ange-ftp-use-gateway-p (host) | |
1535 "Returns whether to access this host via a normal (non-smart) gateway." | |
1536 ;; yes, I know that I could simplify the following expression, but it is | |
1537 ;; clearer (to me at least) this way. | |
1538 (and (not ange-ftp-smart-gateway) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1539 (save-match-data |
1106 | 1540 (not (string-match ange-ftp-local-host-regexp host))))) |
1541 | |
1542 (defun ange-ftp-use-smart-gateway-p (host) | |
1543 "Returns whether to access this host via a smart gateway." | |
1544 (and ange-ftp-smart-gateway | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1545 (save-match-data |
1106 | 1546 (not (string-match ange-ftp-local-host-regexp host))))) |
1547 | |
1548 | |
1549 ;;; ------------------------------------------------------------ | |
1550 ;;; Temporary file location and deletion... | |
1551 ;;; ------------------------------------------------------------ | |
1552 | |
1553 (defvar ange-ftp-tmp-name-files ()) | |
1554 (defvar ange-ftp-tmp-name-hashtable (ange-ftp-make-hashtable 10)) | |
1555 (defvar ange-ftp-pid nil) | |
1556 | |
1557 (defun ange-ftp-get-pid () | |
1558 "Half-hearted attempt to get the current process's id." | |
1559 (setq ange-ftp-pid (substring (make-temp-name "") 1))) | |
1560 | |
1561 (defun ange-ftp-make-tmp-name (host) | |
1562 "This routine will return the name of a new file." | |
1563 (let* ((template (if (ange-ftp-use-gateway-p host) | |
1564 ange-ftp-gateway-tmp-name-template | |
1565 ange-ftp-tmp-name-template)) | |
1566 (pid (or ange-ftp-pid (ange-ftp-get-pid))) | |
1567 (start ?a) | |
1568 file entry) | |
1569 (while | |
1570 (progn | |
1571 (setq file (format "%s%c%s" template start pid)) | |
1572 (setq entry (intern file ange-ftp-tmp-name-hashtable)) | |
1573 (or (memq entry ange-ftp-tmp-name-files) | |
1574 (ange-ftp-real-file-exists-p file))) | |
1575 (if (> (setq start (1+ start)) ?z) | |
1576 (progn | |
1577 (setq template (concat template "X")) | |
1578 (setq start ?a)))) | |
1579 (setq ange-ftp-tmp-name-files | |
1580 (cons entry ange-ftp-tmp-name-files)) | |
1581 file)) | |
1582 | |
1583 (defun ange-ftp-del-tmp-name (temp) | |
1584 (setq ange-ftp-tmp-name-files | |
1585 (delq (intern temp ange-ftp-tmp-name-hashtable) | |
1586 ange-ftp-tmp-name-files)) | |
1587 (condition-case () | |
1588 (ange-ftp-real-delete-file temp) | |
1589 (error nil))) | |
1590 | |
1591 ;;;; ------------------------------------------------------------ | |
1592 ;;;; Interactive gateway program support. | |
1593 ;;;; ------------------------------------------------------------ | |
1594 | |
1595 (defvar ange-ftp-gwp-running t) | |
1596 (defvar ange-ftp-gwp-status nil) | |
1597 | |
1598 (defun ange-ftp-gwp-sentinel (proc str) | |
1599 (setq ange-ftp-gwp-running nil)) | |
1600 | |
1601 (defun ange-ftp-gwp-filter (proc str) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1602 (comint-output-filter proc str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1603 ;; Replace STR by the result of the comint processing. |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1604 (setq str (buffer-substring comint-last-output-start (process-mark proc))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1605 (cond ((string-match "login: *$" str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1606 (send-string proc |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1607 (concat |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1608 (let ((ange-ftp-default-user t)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1609 (ange-ftp-get-user ange-ftp-gateway-host)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1610 "\n"))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1611 ((string-match "Password: *$" str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1612 (send-string proc |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1613 (concat |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1614 (ange-ftp-get-passwd ange-ftp-gateway-host |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1615 (ange-ftp-get-user |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1616 ange-ftp-gateway-host)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1617 "\n"))) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1618 ((string-match ange-ftp-gateway-fatal-msgs str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1619 (delete-process proc) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1620 (setq ange-ftp-gwp-running nil)) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1621 ((string-match ange-ftp-gateway-prompt-pattern str) |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1622 (setq ange-ftp-gwp-running nil |
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1623 ange-ftp-gwp-status t)))) |
1106 | 1624 |
1625 (defun ange-ftp-gwp-start (host user name args) | |
1626 "Login to the gateway machine and fire up an ftp process." | |
1627 (let* ((gw-user (ange-ftp-get-user ange-ftp-gateway-host)) | |
7042 | 1628 ;; It would be nice to make process-connection-type nil, |
1629 ;; but that doesn't work: ftp never responds. | |
1630 ;; Can anyone find a fix for that? | |
1631 (proc (let ((process-connection-type t)) | |
7664
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1632 (start-process name name |
7042 | 1633 ange-ftp-gateway-program |
1634 ange-ftp-gateway-host))) | |
1106 | 1635 (ftp (mapconcat (function identity) args " "))) |
1636 (process-kill-without-query proc) | |
1637 (set-process-sentinel proc (function ange-ftp-gwp-sentinel)) | |
1638 (set-process-filter proc (function ange-ftp-gwp-filter)) | |
7664
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1639 (save-excursion |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1640 (set-buffer (process-buffer proc)) |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1641 (internal-ange-ftp-mode) |
c363ad97af4a
(ange-ftp-gwp-start): Call internal-ange-ftp-mode.
Richard M. Stallman <rms@gnu.org>
parents:
7418
diff
changeset
|
1642 (set-marker (process-mark proc) (point))) |
1106 | 1643 (setq ange-ftp-gwp-running t |
1644 ange-ftp-gwp-status nil) | |
1645 (ange-ftp-message "Connecting to gateway %s..." ange-ftp-gateway-host) | |
1646 (while ange-ftp-gwp-running ;perform login sequence | |
1647 (accept-process-output proc)) | |
1648 (if (not ange-ftp-gwp-status) | |
1649 (ange-ftp-error host user "unable to login to gateway")) | |
1650 (ange-ftp-message "Connecting to gateway %s...done" ange-ftp-gateway-host) | |
1651 (setq ange-ftp-gwp-running t | |
1652 ange-ftp-gwp-status nil) | |
1653 (process-send-string proc ange-ftp-gateway-setup-term-command) | |
1654 (while ange-ftp-gwp-running ;zap ^M's and double echoing. | |
1655 (accept-process-output proc)) | |
1656 (if (not ange-ftp-gwp-status) | |
1657 (ange-ftp-error host user "unable to set terminal modes on gateway")) | |
1658 (setq ange-ftp-gwp-running t | |
1659 ange-ftp-gwp-status nil) | |
1660 (process-send-string proc (concat "exec " ftp "\n")) ;spawn ftp process | |
1661 proc)) | |
1662 | |
1663 ;;;; ------------------------------------------------------------ | |
1664 ;;;; Support for sending commands to the ftp process. | |
1665 ;;;; ------------------------------------------------------------ | |
1666 | |
1667 (defun ange-ftp-raw-send-cmd (proc cmd &optional msg cont nowait) | |
1668 "Low-level routine to send the given ftp CMD to the ftp PROCESS. | |
1669 MSG is an optional message to output before and after the command. | |
1670 If CONT is non-NIL then it is either a function or a list of function and | |
1671 some arguments. The function will be called when the ftp command has completed. | |
1672 If CONT is NIL then this routine will return \( RESULT . LINE \) where RESULT | |
1673 is whether the command was successful, and LINE is the line from the FTP | |
1674 process that caused the command to complete. | |
1675 If NOWAIT is given then the routine will return immediately the command has | |
1676 been queued with no result. CONT will still be called, however." | |
1677 (if (memq (process-status proc) '(run open)) | |
1678 (save-excursion | |
1679 (set-buffer (process-buffer proc)) | |
1680 (while ange-ftp-process-busy | |
3000
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1681 ;; This is a kludge to let user quit in case ftp gets hung. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1682 ;; It matters because this function can be called from the filter. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1683 ;; It is bad to allow quitting in a filter, but getting hung |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1684 ;; is worse. By binding quit-flag to nil, we might avoid |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1685 ;; most of the probability of getting screwed because the user |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1686 ;; wants to quit some command. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1687 (let ((quit-flag nil) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1688 (inhibit-quit nil)) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1689 (accept-process-output))) |
1106 | 1690 (setq ange-ftp-process-string "" |
1691 ange-ftp-process-result-line "" | |
1692 ange-ftp-process-busy t | |
1693 ange-ftp-process-result nil | |
1694 ange-ftp-process-multi-skip nil | |
1695 ange-ftp-process-msg msg | |
1696 ange-ftp-process-continue cont | |
1697 ange-ftp-hash-mark-count 0 | |
1698 ange-ftp-last-percent -1 | |
1699 cmd (concat cmd "\n")) | |
1700 (and msg ange-ftp-process-verbose (ange-ftp-message "%s..." msg)) | |
1701 (goto-char (point-max)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1702 (move-marker comint-last-input-start (point)) |
1106 | 1703 ;; don't insert the password into the buffer on the USER command. |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1704 (save-match-data |
1106 | 1705 (if (string-match "^user \"[^\"]*\"" cmd) |
1706 (insert (substring cmd 0 (match-end 0)) " Turtle Power!\n") | |
1707 (insert cmd))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1708 (move-marker comint-last-input-end (point)) |
1106 | 1709 (send-string proc cmd) |
1710 (set-marker (process-mark proc) (point)) | |
1711 (if nowait | |
1712 nil | |
1713 ;; hang around for command to complete | |
1714 (while ange-ftp-process-busy | |
3000
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1715 ;; This is a kludge to let user quit in case ftp gets hung. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1716 ;; It matters because this function can be called from the filter. |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1717 (let ((quit-flag nil) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1718 (inhibit-quit nil)) |
0fdd43a27e15
(ange-ftp-raw-send-cmd): Allow quitting during accept-process-output.
Richard M. Stallman <rms@gnu.org>
parents:
2560
diff
changeset
|
1719 (accept-process-output proc))) |
1106 | 1720 (if cont |
1721 nil ;cont has already been called | |
1722 (cons ange-ftp-process-result ange-ftp-process-result-line)))))) | |
1723 | |
1724 (defun ange-ftp-nslookup-host (host) | |
1725 "Attempt to resolve the given HOSTNAME using nslookup if possible." | |
1726 (interactive "sHost: ") | |
1727 (if ange-ftp-nslookup-program | |
6192
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1728 (let ((default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1729 (if (file-accessible-directory-p default-directory) |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1730 default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1731 exec-directory)) |
7042 | 1732 ;; It would be nice to make process-connection-type nil, |
1733 ;; but that doesn't work: ftp never responds. | |
1734 ;; Can anyone find a fix for that? | |
1735 (proc (let ((process-connection-type t)) | |
1736 (start-process " *nslookup*" " *nslookup*" | |
1737 ange-ftp-nslookup-program host))) | |
1106 | 1738 (res host)) |
1739 (process-kill-without-query proc) | |
1740 (save-excursion | |
1741 (set-buffer (process-buffer proc)) | |
1742 (while (memq (process-status proc) '(run open)) | |
1743 (accept-process-output proc)) | |
1744 (goto-char (point-min)) | |
1745 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t) | |
1746 (setq res (buffer-substring (match-beginning 1) | |
1747 (match-end 1)))) | |
1748 (kill-buffer (current-buffer))) | |
1749 res) | |
1750 host)) | |
1751 | |
1752 (defun ange-ftp-start-process (host user name) | |
1753 "Spawn a new ftp process ready to connect to machine HOST and give it NAME. | |
1754 If HOST is only ftp-able through a gateway machine then spawn a shell | |
1755 on the gateway machine to do the ftp instead." | |
1756 (let* ((use-gateway (ange-ftp-use-gateway-p host)) | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1757 (use-smart-ftp (and (not ange-ftp-gateway-host) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1758 (ange-ftp-use-smart-gateway-p host))) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1759 (ftp-prog (if (or use-gateway |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1760 use-smart-ftp) |
1106 | 1761 ange-ftp-gateway-ftp-program-name |
1762 ange-ftp-ftp-program-name)) | |
1763 (args (append (list ftp-prog) ange-ftp-ftp-program-args)) | |
7418
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1764 ;; Without the following binding, ange-ftp-start-process |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1765 ;; recurses on file-accessible-directory-p, since it needs to |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1766 ;; restart its process in order to determine anything about |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1767 ;; default-directory. |
26587880d2b4
(ange-ftp-start-process): Bind file-name-handler-alist to nil
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1768 (file-name-handler-alist) |
6192
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1769 (default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1770 (if (file-accessible-directory-p default-directory) |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1771 default-directory |
b7fa2446073e
(ange-ftp-nslookup-host, ange-ftp-start-process):
Richard M. Stallman <rms@gnu.org>
parents:
5984
diff
changeset
|
1772 exec-directory)) |
1106 | 1773 proc) |
7042 | 1774 ;; It would be nice to make process-connection-type nil, |
1775 ;; but that doesn't work: ftp never responds. | |
1776 ;; Can anyone find a fix for that? | |
1777 (let ((process-connection-type t)) | |
1778 (if use-gateway | |
1779 (if ange-ftp-gateway-program-interactive | |
1780 (setq proc (ange-ftp-gwp-start host user name args)) | |
1781 (setq proc (apply 'start-process name name | |
1782 (append (list ange-ftp-gateway-program | |
1783 ange-ftp-gateway-host) | |
1784 args)))) | |
1785 (setq proc (apply 'start-process name name args)))) | |
1106 | 1786 (process-kill-without-query proc) |
1787 (save-excursion | |
1788 (set-buffer (process-buffer proc)) | |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1789 (internal-ange-ftp-mode)) |
1106 | 1790 (set-process-sentinel proc (function ange-ftp-process-sentinel)) |
1791 (set-process-filter proc (function ange-ftp-process-filter)) | |
1792 (accept-process-output proc) ;wait for ftp startup message | |
1793 proc)) | |
1794 | |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1795 (defun internal-ange-ftp-mode () |
7113
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1796 "Major mode for interacting with the FTP process. |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1797 |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1798 \\{comint-mode-map}" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1799 (interactive) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1800 (comint-mode) |
3502
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1801 (setq major-mode 'internal-ange-ftp-mode) |
c2b4a5b9c8d5
(internal-ange-ftp-mode): Renamed from ange-ftp-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
3441
diff
changeset
|
1802 (setq mode-name "Internal Ange-ftp") |
1106 | 1803 (let ((proc (get-buffer-process (current-buffer)))) |
1804 (goto-char (point-max)) | |
1805 (set-marker (process-mark proc) (point)) | |
1806 (make-local-variable 'ange-ftp-process-string) | |
1807 (setq ange-ftp-process-string "") | |
1808 (make-local-variable 'ange-ftp-process-busy) | |
1809 (make-local-variable 'ange-ftp-process-result) | |
1810 (make-local-variable 'ange-ftp-process-msg) | |
1811 (make-local-variable 'ange-ftp-process-multi-skip) | |
1812 (make-local-variable 'ange-ftp-process-result-line) | |
1813 (make-local-variable 'ange-ftp-process-continue) | |
1814 (make-local-variable 'ange-ftp-hash-mark-count) | |
1815 (make-local-variable 'ange-ftp-binary-hash-mark-size) | |
1816 (make-local-variable 'ange-ftp-ascii-hash-mark-size) | |
1817 (make-local-variable 'ange-ftp-hash-mark-unit) | |
1818 (make-local-variable 'ange-ftp-xfer-size) | |
1819 (make-local-variable 'ange-ftp-last-percent) | |
1820 (setq ange-ftp-hash-mark-count 0) | |
1821 (setq ange-ftp-xfer-size 0) | |
7113
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1822 (setq ange-ftp-process-result-line "") |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1823 |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1824 (setq comint-prompt-regexp "^ftp> ") |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1825 (make-local-variable 'paragraph-start) |
61a2355759aa
(internal-ange-ftp-mode): Set comint-prompt-regexp and paragraph-start.
Richard M. Stallman <rms@gnu.org>
parents:
7043
diff
changeset
|
1826 (setq paragraph-start comint-prompt-regexp))) |
1106 | 1827 |
1828 (defun ange-ftp-smart-login (host user pass account proc) | |
1829 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1830 PROC is the FTP-client's process. This routine uses the smart-gateway | |
1831 host specified in ``ange-ftp-gateway-host''." | |
1832 (let ((result (ange-ftp-raw-send-cmd | |
1833 proc | |
1834 (format "open %s %s" | |
1835 (ange-ftp-nslookup-host ange-ftp-gateway-host) | |
1836 ange-ftp-smart-gateway-port) | |
1837 (format "Opening FTP connection to %s via %s" | |
1838 host | |
1839 ange-ftp-gateway-host)))) | |
1840 (or (car result) | |
1841 (ange-ftp-error host user | |
1842 (concat "OPEN request failed: " | |
1843 (cdr result)))) | |
1844 (setq result (ange-ftp-raw-send-cmd | |
1845 proc (format "user \"%s\"@%s %s %s" | |
1846 user | |
1847 (ange-ftp-nslookup-host host) | |
1848 pass | |
1849 account) | |
1850 (format "Logging in as user %s@%s" | |
1851 user host))) | |
1852 (or (car result) | |
1853 (progn | |
1854 (ange-ftp-set-passwd host user nil) ; reset password | |
1855 (ange-ftp-set-account host user nil) ; reset account | |
1856 (ange-ftp-error host user | |
1857 (concat "USER request failed: " | |
1858 (cdr result))))))) | |
1859 | |
1860 (defun ange-ftp-normal-login (host user pass account proc) | |
1861 "Connect to the FTP-server on HOST as USER using PASSWORD and ACCOUNT. | |
1862 PROC is the process to the FTP-client." | |
1863 (let ((result (ange-ftp-raw-send-cmd | |
1864 proc | |
1865 (format "open %s" (ange-ftp-nslookup-host host)) | |
1866 (format "Opening FTP connection to %s" host)))) | |
1867 (or (car result) | |
1868 (ange-ftp-error host user | |
1869 (concat "OPEN request failed: " | |
1870 (cdr result)))) | |
1871 (setq result (ange-ftp-raw-send-cmd | |
1872 proc | |
1873 (format "user \"%s\" %s %s" user pass account) | |
1874 (format "Logging in as user %s@%s" user host))) | |
1875 (or (car result) | |
1876 (progn | |
1877 (ange-ftp-set-passwd host user nil) ;reset password. | |
1878 (ange-ftp-set-account host user nil) ;reset account. | |
1879 (ange-ftp-error host user | |
1880 (concat "USER request failed: " | |
1881 (cdr result))))))) | |
1882 | |
5480
f193f880c524
(ange-ftp-hash-mark-msgs): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5350
diff
changeset
|
1883 ;; ange@hplb.hpl.hp.com says this should not be changed. |
1106 | 1884 (defvar ange-ftp-hash-mark-msgs |
5480
f193f880c524
(ange-ftp-hash-mark-msgs): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5350
diff
changeset
|
1885 "[hH]ash mark [^0-9]*\\([0-9]+\\)" |
1106 | 1886 "*Regexp matching the FTP client's output upon doing a HASH command.") |
1887 | |
1888 (defun ange-ftp-guess-hash-mark-size (proc) | |
1889 (if ange-ftp-send-hash | |
1890 (save-excursion | |
1891 (set-buffer (process-buffer proc)) | |
1892 (let* ((status (ange-ftp-raw-send-cmd proc "hash")) | |
1893 (result (car status)) | |
1894 (line (cdr status))) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
1895 (save-match-data |
1106 | 1896 (if (string-match ange-ftp-hash-mark-msgs line) |
1897 (let ((size (string-to-int | |
1898 (substring line | |
1899 (match-beginning 1) | |
1900 (match-end 1))))) | |
1901 (setq ange-ftp-ascii-hash-mark-size size | |
1902 ange-ftp-hash-mark-unit (ash size -4)) | |
1903 | |
1904 ;; if a default value for this is set, use that value. | |
1905 (or ange-ftp-binary-hash-mark-size | |
1906 (setq ange-ftp-binary-hash-mark-size size))))))))) | |
1907 | |
1908 (defun ange-ftp-get-process (host user) | |
7042 | 1909 "Return an FTP subprocess connected to HOST and logged in as USER. |
1910 Create a new process if needed." | |
1106 | 1911 (let* ((name (ange-ftp-ftp-process-buffer host user)) |
1912 (proc (get-process name))) | |
1913 (if (and proc (memq (process-status proc) '(run open))) | |
1914 proc | |
1915 (let ((pass (ange-ftp-quote-string | |
1916 (ange-ftp-get-passwd host user))) | |
1917 (account (ange-ftp-quote-string | |
1918 (ange-ftp-get-account host user)))) | |
1919 ;; grab a suitable process. | |
1920 (setq proc (ange-ftp-start-process host user name)) | |
1921 | |
1922 ;; login to FTP server. | |
9070
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1923 (if (and (ange-ftp-use-smart-gateway-p host) |
b261d80c1b23
(ange-ftp-start-process): Add use-smart-ftp code.
Richard M. Stallman <rms@gnu.org>
parents:
8397
diff
changeset
|
1924 ange-ftp-gateway-host) |
1106 | 1925 (ange-ftp-smart-login host user pass account proc) |
1926 (ange-ftp-normal-login host user pass account proc)) | |
1927 | |
1928 ;; Tell client to send back hash-marks as progress. It isn't usually | |
1929 ;; fatal if this command fails. | |
1930 (ange-ftp-guess-hash-mark-size proc) | |
1931 | |
1932 ;; Guess at the host type. | |
1933 (ange-ftp-guess-host-type host user) | |
1934 | |
1935 ;; Run any user-specified hooks. Note that proc, host and user are | |
1936 ;; dynamically bound at this point. | |
1937 (run-hooks 'ange-ftp-process-startup-hook)) | |
1938 proc))) | |
1939 | |
1940 ;; Variables for caching host and host-type | |
1941 (defvar ange-ftp-host-cache nil) | |
1942 (defvar ange-ftp-host-type-cache nil) | |
1943 | |
1944 ;; If ange-ftp-host-type is called with the optional user | |
1945 ;; argument, it will attempt to guess the host type by connecting | |
1946 ;; as user, if necessary. For efficiency, I have tried to give this | |
1947 ;; optional second argument only when necessary. Have I missed any calls | |
1948 ;; to ange-ftp-host-type where it should have been supplied? | |
1949 | |
1950 (defun ange-ftp-host-type (host &optional user) | |
1951 "Return a symbol which represents the type of the HOST given. | |
1952 If the optional argument USER is given, attempts to guess the | |
1953 host-type by logging in as USER." | |
1954 (if (eq host ange-ftp-host-cache) | |
1955 ange-ftp-host-type-cache | |
1956 ;; Trigger an ftp connection, in case we need to guess at the host type. | |
1957 (if (and user (ange-ftp-get-process host user) (eq host ange-ftp-host-cache)) | |
1958 ange-ftp-host-type-cache | |
1959 (setq ange-ftp-host-cache host | |
1960 ange-ftp-host-type-cache | |
1961 (cond ((ange-ftp-dumb-unix-host host) | |
1962 'dumb-unix) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1963 ;; ((and (fboundp 'ange-ftp-vos-host) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1964 ;; (ange-ftp-vos-host host)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1965 ;; 'vos) |
1106 | 1966 ((and (fboundp 'ange-ftp-vms-host) |
1967 (ange-ftp-vms-host host)) | |
1968 'vms) | |
1969 ((and (fboundp 'ange-ftp-mts-host) | |
1970 (ange-ftp-mts-host host)) | |
1971 'mts) | |
1972 ((and (fboundp 'ange-ftp-cms-host) | |
1973 (ange-ftp-cms-host host)) | |
1974 'cms) | |
1975 (t | |
1976 'unix)))))) | |
1977 | |
1978 ;; It would be nice to abstract the functions ange-ftp-TYPE-host and | |
1979 ;; ange-ftp-add-TYPE-host. The trick is to abstract these functions | |
1980 ;; without sacrificing speed. Also, having separate variables | |
1981 ;; ange-ftp-TYPE-regexp is more user friendly then requiring the user to | |
1982 ;; set an alist to indicate that a host is of a given type. Even with | |
1983 ;; automatic host type recognition, setting a regexp is still a good idea | |
1984 ;; (for efficiency) if you log into a particular non-UNIX host frequently. | |
1985 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1986 (defvar ange-ftp-fix-name-func-alist nil |
7042 | 1987 "Alist saying how to convert file name to the host's syntax. |
1988 Association list of \( TYPE \. FUNC \) pairs, where FUNC is a routine | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1989 which can change a UNIX file name into a name more suitable for a host of type |
1106 | 1990 TYPE.") |
1991 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1992 (defvar ange-ftp-fix-dir-name-func-alist nil |
7042 | 1993 "Alist saying how to convert directory name to the host's syntax. |
1994 Association list of \( TYPE \. FUNC \) pairs, where FUNC is a routine | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
1995 which can change UNIX directory name into a directory name more suitable |
1106 | 1996 for a host of type TYPE.") |
1997 | |
1998 ;; *** Perhaps the sense of this variable should be inverted, since there | |
1999 ;; *** is only 1 host type that can take ls-style listing options. | |
2000 (defvar ange-ftp-dumb-host-types '(dumb-unix) | |
2001 "List of host types that can't take UNIX ls-style listing options.") | |
2002 | |
2003 (defun ange-ftp-send-cmd (host user cmd &optional msg cont nowait) | |
2004 "Find an ftp process connected to HOST logged in as USER and send it CMD. | |
2005 MSG is an optional status message to be output before and after issuing the | |
2006 command. | |
2007 See the documentation for ange-ftp-raw-send-cmd for a description of CONT | |
2008 and NOWAIT." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2009 ;; Handle conversion to remote file name syntax and remote ls option |
1106 | 2010 ;; capability. |
2011 (let ((cmd0 (car cmd)) | |
2012 (cmd1 (nth 1 cmd)) | |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2013 (ange-ftp-this-user user) |
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2014 (ange-ftp-this-host host) |
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2015 (ange-ftp-this-msg msg) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2016 cmd2 cmd3 host-type fix-name-func) |
1106 | 2017 |
2018 (cond | |
2019 | |
2020 ;; pwd case (We don't care what host-type.) | |
2021 ((null cmd1)) | |
2022 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2023 ;; cmd == 'dir "remote-name" "local-name" "ls-switches" |
1106 | 2024 ((progn |
2025 (setq cmd2 (nth 2 cmd) | |
2026 host-type (ange-ftp-host-type host user)) | |
2027 ;; This will trigger an FTP login, if one doesn't exist | |
2028 (eq cmd0 'dir)) | |
2029 (setq cmd1 (funcall | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2030 (or (cdr (assq host-type ange-ftp-fix-dir-name-func-alist)) |
1106 | 2031 'identity) |
2032 cmd1) | |
2033 cmd3 (nth 3 cmd)) | |
2034 ;; Need to deal with the HP-UX ftp bug. This should also allow | |
2035 ;; us to resolve symlinks to directories on SysV machines. (Sebastian will | |
2036 ;; be happy.) | |
2037 (and (eq host-type 'unix) | |
2038 (string-match "/$" cmd1) | |
2039 (not (string-match "R" cmd3)) | |
2040 (setq cmd1 (concat cmd1 "."))) | |
2041 ;; If the remote ls can take switches, put them in | |
2042 (or (memq host-type ange-ftp-dumb-host-types) | |
2043 (setq cmd0 'ls | |
2044 cmd1 (format "\"%s %s\"" cmd3 cmd1)))) | |
2045 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2046 ;; First argument is the remote name |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
2047 ((progn |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2048 (setq fix-name-func (or (cdr (assq host-type |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2049 ange-ftp-fix-name-func-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2050 'identity)) |
1106 | 2051 (memq cmd0 '(get delete mkdir rmdir cd))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2052 (setq cmd1 (funcall fix-name-func cmd1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2053 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2054 ;; Second argument is the remote name |
1106 | 2055 ((memq cmd0 '(append put chmod)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2056 (setq cmd2 (funcall fix-name-func cmd2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2057 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2058 ;; Both arguments are remote names |
1106 | 2059 ((eq cmd0 'rename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2060 (setq cmd1 (funcall fix-name-func cmd1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2061 cmd2 (funcall fix-name-func cmd2)))) |
1106 | 2062 |
2063 ;; Turn the command into one long string | |
2064 (setq cmd0 (symbol-name cmd0)) | |
2065 (setq cmd (concat cmd0 | |
2066 (and cmd1 (concat " " cmd1)) | |
2067 (and cmd2 (concat " " cmd2)))) | |
2068 | |
2069 ;; Actually send the resulting command. | |
2070 (let (afsc-result | |
2071 afsc-line) | |
2072 (ange-ftp-raw-send-cmd | |
2073 (ange-ftp-get-process host user) | |
2074 cmd | |
2075 msg | |
2076 (list | |
2077 (function (lambda (result line host user | |
2078 cmd msg cont nowait) | |
2079 (or cont | |
2080 (setq afsc-result result | |
2081 afsc-line line)) | |
2082 (if result | |
2083 (ange-ftp-call-cont cont result line) | |
2084 (ange-ftp-raw-send-cmd | |
2085 (ange-ftp-get-process host user) | |
2086 cmd | |
2087 msg | |
2088 (list | |
2089 (function (lambda (result line cont) | |
2090 (or cont | |
2091 (setq afsc-result result | |
2092 afsc-line line)) | |
2093 (ange-ftp-call-cont cont result line))) | |
2094 cont) | |
2095 nowait)))) | |
2096 host user cmd msg cont nowait) | |
2097 nowait) | |
2098 | |
2099 (if nowait | |
2100 nil | |
2101 (if cont | |
2102 nil | |
2103 (cons afsc-result afsc-line)))))) | |
2104 | |
2105 ;; It might be nice to message users about the host type identified, | |
2106 ;; but there is so much other messaging going on, it would not be | |
2107 ;; seen. No point in slowing things down just so users can read | |
2108 ;; a host type message. | |
2109 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2110 (defconst ange-ftp-cms-name-template |
1106 | 2111 (concat |
2112 "^[-A-Z0-9$*][-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?" | |
2113 "[-A-Z0-9$*]?[-A-Z0-9$*]?[-A-Z0-9$*]?\\.[0-9][0-9][0-9A-Z]$")) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2114 (defconst ange-ftp-vms-name-template |
1106 | 2115 "^[-A-Z0-9_$]+:\\[[-A-Z0-9_$]+\\(\\.[-A-Z0-9_$]+\\)*\\]$") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2116 (defconst ange-ftp-mts-name-template |
1106 | 2117 "^[A-Z0-9._][A-Z0-9._][A-Z0-9._][A-Z0-9._]:$") |
2118 | |
2119 (defun ange-ftp-guess-host-type (host user) | |
7042 | 2120 "Guess at the the host type of HOST. |
2121 Works by doing a pwd and examining the directory syntax." | |
1106 | 2122 (let ((host-type (ange-ftp-host-type host)) |
2123 (key (concat host "/" user "/~"))) | |
2124 (if (eq host-type 'unix) | |
2125 ;; Note that ange-ftp-host-type returns unix as the default value. | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2126 (save-match-data |
1106 | 2127 (let* ((result (ange-ftp-get-pwd host user)) |
2128 (dir (car result)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2129 fix-name-func) |
1106 | 2130 (cond ((null dir) |
2131 (message "Warning! Unable to get home directory") | |
2132 (sit-for 1) | |
2133 (if (string-match | |
2134 "^450 No current working directory defined$" | |
2135 (cdr result)) | |
2136 | |
2137 ;; We'll assume that if pwd bombs with this | |
2138 ;; error message, then it's CMS. | |
2139 (progn | |
2140 (ange-ftp-add-cms-host host) | |
2141 (setq ange-ftp-host-cache host | |
2142 ange-ftp-host-type-cache 'cms)))) | |
2143 | |
2144 ;; try for VMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2145 ((string-match ange-ftp-vms-name-template dir) |
1106 | 2146 (ange-ftp-add-vms-host host) |
2147 ;; The add-host functions clear the host type cache. | |
2148 ;; Therefore, need to set the cache afterwards. | |
2149 (setq ange-ftp-host-cache host | |
2150 ange-ftp-host-type-cache 'vms)) | |
2151 | |
2152 ;; try for MTS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2153 ((string-match ange-ftp-mts-name-template dir) |
1106 | 2154 (ange-ftp-add-mts-host host) |
2155 (setq ange-ftp-host-cache host | |
2156 ange-ftp-host-type-cache 'mts)) | |
2157 | |
2158 ;; try for CMS | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2159 ((string-match ange-ftp-cms-name-template dir) |
1106 | 2160 (ange-ftp-add-cms-host host) |
2161 (setq ange-ftp-host-cache host | |
2162 ange-ftp-host-type-cache 'cms)) | |
2163 | |
2164 ;; assume UN*X | |
2165 (t | |
2166 (setq ange-ftp-host-cache host | |
2167 ange-ftp-host-type-cache 'unix))) | |
2168 | |
2169 ;; Now that we have done a pwd, might as well put it in | |
2170 ;; the expand-dir hashtable. | |
2171 (let ((ange-ftp-this-user user) | |
2172 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2173 (setq fix-name-func (cdr (assq ange-ftp-host-type-cache |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2174 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2175 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2176 (setq dir (funcall fix-name-func dir 'reverse)))) |
1106 | 2177 (ange-ftp-put-hash-entry key dir |
2178 ange-ftp-expand-dir-hashtable)))) | |
2179 | |
2180 ;; In the special case of CMS make sure that know the | |
2181 ;; expansion of the home minidisk now, because we will | |
2182 ;; be doing a lot of cd's. | |
2183 (if (and (eq host-type 'cms) | |
2184 (not (ange-ftp-hash-entry-exists-p | |
2185 key ange-ftp-expand-dir-hashtable))) | |
2186 (let ((dir (car (ange-ftp-get-pwd host user)))) | |
2187 (if dir | |
2188 (ange-ftp-put-hash-entry key (concat "/" dir) | |
2189 ange-ftp-expand-dir-hashtable) | |
2190 (message "Warning! Unable to get home directory") | |
2191 (sit-for 1)))))) | |
2192 | |
2193 | |
2194 ;;;; ------------------------------------------------------------ | |
2195 ;;;; Remote file and directory listing support. | |
2196 ;;;; ------------------------------------------------------------ | |
2197 | |
7042 | 2198 ;; Returns whether HOST's FTP server doesn't like \'ls\' or \'dir\' commands |
2199 ;; to take switch arguments. | |
1106 | 2200 (defun ange-ftp-dumb-unix-host (host) |
2201 (and ange-ftp-dumb-unix-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2202 (save-match-data |
1106 | 2203 (string-match ange-ftp-dumb-unix-host-regexp host)))) |
2204 | |
2205 (defun ange-ftp-add-dumb-unix-host (host) | |
2206 "Interactively adds a given HOST to ange-ftp-dumb-unix-host-regexp." | |
2207 (interactive | |
2208 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2209 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2210 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 2211 (if (not (ange-ftp-dumb-unix-host host)) |
2212 (setq ange-ftp-dumb-unix-host-regexp | |
2213 (concat "^" (regexp-quote host) "$" | |
2214 (and ange-ftp-dumb-unix-host-regexp "\\|") | |
2215 ange-ftp-dumb-unix-host-regexp) | |
2216 ange-ftp-host-cache nil))) | |
2217 | |
2218 (defvar ange-ftp-parse-list-func-alist nil | |
7042 | 2219 "Alist saying how to parse directory listings for certain OS types. |
2220 Association list of \( TYPE \. FUNC \) pairs. The FUNC is a routine | |
1106 | 2221 which can parse the output from a DIR listing for a host of type TYPE.") |
2222 | |
2223 ;; With no-error nil, this function returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2224 ;; an error if file is not an ange-ftp-name |
1106 | 2225 ;; (This should never happen.) |
2226 ;; an error if either the listing is unreadable or there is an ftp error. | |
2227 ;; the listing (a string), if everything works. | |
2228 ;; | |
2229 ;; With no-error t, it returns: | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2230 ;; an error if not an ange-ftp-name |
1106 | 2231 ;; error if listing is unreable (most likely caused by a slow connection) |
2232 ;; nil if ftp error (this is because although asking to list a nonexistent | |
2233 ;; directory on a remote unix machine usually (except | |
2234 ;; maybe for dumb hosts) returns an ls error, but no | |
2235 ;; ftp error, if the same is done on a VMS machine, | |
2236 ;; an ftp error is returned. Need to trap the error | |
2237 ;; so we can go on and try to list the parent.) | |
2238 ;; the listing, if everything works. | |
2239 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2240 ;; If WILDCARD is non-nil, then this implements the guts of insert-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2241 ;; in the wildcard case. Then we make a relative directory listing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2242 ;; of FILE within the directory specified by `default-directory'. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2243 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2244 (defun ange-ftp-ls (file lsargs parse &optional no-error wildcard) |
1106 | 2245 "Return the output of an `DIR' or `ls' command done over ftp. |
2246 FILE is the full name of the remote file, LSARGS is any args to pass to the | |
2247 `ls' command, and PARSE specifies that the output should be parsed and stored | |
2248 away in the internal cache." | |
2249 ;; If parse is t, we assume that file is a directory. i.e. we only parse | |
2250 ;; full directory listings. | |
2251 (let* ((ange-ftp-this-file (ange-ftp-expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2252 (parsed (ange-ftp-ftp-name ange-ftp-this-file))) |
1106 | 2253 (if parsed |
2254 (let* ((host (nth 0 parsed)) | |
2255 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2256 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2257 (key (directory-file-name ange-ftp-this-file)) |
2258 (host-type (ange-ftp-host-type host user)) | |
2259 (dumb (memq host-type ange-ftp-dumb-host-types)) | |
2260 result | |
2261 temp | |
2262 lscmd parse-func) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2263 (if (string-equal name "") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2264 (setq name |
1106 | 2265 (ange-ftp-real-file-name-as-directory |
2266 (ange-ftp-expand-dir host user "~")))) | |
2267 (if (and ange-ftp-ls-cache-file | |
2268 (string-equal key ange-ftp-ls-cache-file) | |
2269 ;; Don't care about lsargs for dumb hosts. | |
2270 (or dumb (string-equal lsargs ange-ftp-ls-cache-lsargs))) | |
2271 ange-ftp-ls-cache-res | |
2272 (setq temp (ange-ftp-make-tmp-name host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2273 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2274 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2275 (ange-ftp-cd host user (file-name-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2276 (setq lscmd (list 'dir file temp lsargs))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2277 (setq lscmd (list 'dir name temp lsargs))) |
1106 | 2278 (unwind-protect |
2279 (if (car (setq result (ange-ftp-send-cmd | |
2280 host | |
2281 user | |
2282 lscmd | |
2283 (format "Listing %s" | |
2284 (ange-ftp-abbreviate-filename | |
2285 ange-ftp-this-file))))) | |
2286 (save-excursion | |
2287 (set-buffer (get-buffer-create | |
2288 ange-ftp-data-buffer-name)) | |
2289 (erase-buffer) | |
2290 (if (ange-ftp-real-file-readable-p temp) | |
2291 (ange-ftp-real-insert-file-contents temp) | |
2292 (sleep-for ange-ftp-retry-time) | |
2293 ;wait for file to possibly appear | |
2294 (if (ange-ftp-real-file-readable-p temp) | |
2295 ;; Try again. | |
2296 (ange-ftp-real-insert-file-contents temp) | |
2297 (ange-ftp-error host user | |
2298 (format | |
2299 "list data file %s not readable" | |
2300 temp)))) | |
2301 (if parse | |
2302 (ange-ftp-set-files | |
2303 ange-ftp-this-file | |
2304 (if (setq | |
2305 parse-func | |
2306 (cdr (assq host-type | |
2307 ange-ftp-parse-list-func-alist))) | |
2308 (funcall parse-func) | |
2309 (ange-ftp-parse-dired-listing lsargs)))) | |
2310 (setq ange-ftp-ls-cache-file key | |
2311 ange-ftp-ls-cache-lsargs lsargs | |
2312 ; For dumb hosts-types this is | |
2313 ; meaningless but harmless. | |
2314 ange-ftp-ls-cache-res (buffer-string)) | |
2315 ;; (kill-buffer (current-buffer)) | |
2316 ange-ftp-ls-cache-res) | |
2317 (if no-error | |
2318 nil | |
2319 (ange-ftp-error host user | |
2320 (concat "DIR failed: " (cdr result))))) | |
2321 (ange-ftp-del-tmp-name temp)))) | |
2322 (error "Should never happen. Please report. Bug ref. no.: 1")))) | |
2323 | |
2324 ;;;; ------------------------------------------------------------ | |
2325 ;;;; Directory information caching support. | |
2326 ;;;; ------------------------------------------------------------ | |
2327 | |
2328 (defconst ange-ftp-date-regexp | |
2329 (concat | |
2330 " \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct" | |
2331 "\\|Nov\\|Dec\\) +[0-3]?[0-9] ")) | |
2332 | |
2333 (defvar ange-ftp-add-file-entry-alist nil | |
7043
acf840ff5c1c
(ange-ftp-add-file-entry-alist): Fix typo in prev change.
Richard M. Stallman <rms@gnu.org>
parents:
7042
diff
changeset
|
2334 "Alist saying how to add file entries on certain OS types. |
7042 | 2335 Association list of pairs \( TYPE \. FUNC \), where FUNC |
1106 | 2336 is a function to be used to add a file entry for the OS TYPE. The |
2337 main reason for this alist is to deal with file versions in VMS.") | |
2338 | |
2339 (defvar ange-ftp-delete-file-entry-alist nil | |
7042 | 2340 "Alist saying how to delete files on certain OS types. |
2341 Association list of pairs \( TYPE \. FUNC \), where FUNC | |
1106 | 2342 is a function to be used to delete a file entry for the OS TYPE. |
7042 | 2343 The main reason for this alist is to deal with file versions in VMS.") |
1106 | 2344 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2345 (defun ange-ftp-add-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2346 "Add a file entry for file NAME, if its directory info exists." |
1106 | 2347 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2348 (car (ange-ftp-ftp-name name))) |
1106 | 2349 ange-ftp-add-file-entry-alist)) |
2350 'ange-ftp-internal-add-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2351 name dir-p) |
1106 | 2352 (setq ange-ftp-ls-cache-file nil)) |
2353 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2354 (defun ange-ftp-delete-file-entry (name &optional dir-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2355 "Delete the file entry for file NAME, if its directory info exists." |
1106 | 2356 (funcall (or (cdr (assq (ange-ftp-host-type |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2357 (car (ange-ftp-ftp-name name))) |
1106 | 2358 ange-ftp-delete-file-entry-alist)) |
2359 'ange-ftp-internal-delete-file-entry) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2360 name dir-p) |
1106 | 2361 (setq ange-ftp-ls-cache-file nil)) |
2362 | |
2363 (defmacro ange-ftp-parse-filename () | |
2364 ;;Extract the filename from the current line of a dired-like listing. | |
2365 (` (let ((eol (progn (end-of-line) (point)))) | |
2366 (beginning-of-line) | |
2367 (if (re-search-forward ange-ftp-date-regexp eol t) | |
2368 (progn | |
2369 (skip-chars-forward " ") | |
2370 (skip-chars-forward "^ " eol) | |
2371 (skip-chars-forward " " eol) | |
2372 ;; We bomb on filenames starting with a space. | |
2373 (buffer-substring (point) eol)))))) | |
2374 | |
2375 ;; This deals with the F switch. Should also do something about | |
2376 ;; unquoting names obtained with the SysV b switch and the GNU Q | |
2377 ;; switch. See Sebastian's dired-get-filename. | |
2378 | |
2379 (defmacro ange-ftp-ls-parser () | |
2380 ;; Note that switches is dynamically bound. | |
2381 ;; Meant to be called by ange-ftp-parse-dired-listing | |
2382 (` (let ((tbl (ange-ftp-make-hashtable)) | |
2383 (used-F (and (stringp switches) | |
2384 (string-match "F" switches))) | |
2385 file-type symlink directory file) | |
2386 (while (setq file (ange-ftp-parse-filename)) | |
2387 (beginning-of-line) | |
2388 (skip-chars-forward "\t 0-9") | |
2389 (setq file-type (following-char) | |
2390 directory (eq file-type ?d)) | |
2391 (if (eq file-type ?l) | |
2392 (if (string-match " -> " file) | |
2393 (setq symlink (substring file (match-end 0)) | |
2394 file (substring file 0 (match-beginning 0))) | |
2395 ;; Shouldn't happen | |
2396 (setq symlink "")) | |
2397 (setq symlink nil)) | |
2398 ;; Only do a costly regexp search if the F switch was used. | |
2399 (if (and used-F | |
2400 (not (string-equal file "")) | |
2401 (looking-at | |
2402 ".[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)")) | |
2403 (let ((socket (eq file-type ?s)) | |
2404 (executable | |
2405 (and (not symlink) ; x bits don't mean a thing for symlinks | |
2406 (string-match "[xst]" | |
2407 (concat | |
2408 (buffer-substring | |
2409 (match-beginning 1) | |
2410 (match-end 1)) | |
2411 (buffer-substring | |
2412 (match-beginning 2) | |
2413 (match-end 2)) | |
2414 (buffer-substring | |
2415 (match-beginning 3) | |
2416 (match-end 3))))))) | |
2417 ;; Some ls's with the F switch mark symlinks with an @ (ULTRIX) | |
2418 ;; and others don't. (sigh...) Beware, that some Unix's don't | |
2419 ;; seem to believe in the F-switch | |
2420 (if (or (and symlink (string-match "@$" file)) | |
2421 (and directory (string-match "/$" file)) | |
2422 (and executable (string-match "*$" file)) | |
2423 (and socket (string-match "=$" file))) | |
2424 (setq file (substring file 0 -1))))) | |
2425 (ange-ftp-put-hash-entry file (or symlink directory) tbl) | |
2426 (forward-line 1)) | |
2427 (ange-ftp-put-hash-entry "." t tbl) | |
2428 (ange-ftp-put-hash-entry ".." t tbl) | |
2429 tbl))) | |
2430 | |
2431 ;;; The dl stuff for descriptive listings | |
2432 | |
2433 (defvar ange-ftp-dl-dir-regexp nil | |
7042 | 2434 "Regexp matching directories which are listed in dl format. |
2435 This regexp should not be anchored with a trailing `$', because it should | |
2436 match subdirectories as well.") | |
1106 | 2437 |
2438 (defun ange-ftp-add-dl-dir (dir) | |
1233 | 2439 "Interactively adds a DIR to ange-ftp-dl-dir-regexp." |
1106 | 2440 (interactive |
2441 (list (read-string "Directory: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2442 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2443 (and name (ange-ftp-ftp-name name) |
1106 | 2444 (file-name-directory name)))))) |
2445 (if (not (and ange-ftp-dl-dir-regexp | |
2446 (string-match ange-ftp-dl-dir-regexp dir))) | |
2447 (setq ange-ftp-dl-dir-regexp | |
2448 (concat "^" (regexp-quote dir) | |
2449 (and ange-ftp-dl-dir-regexp "\\|") | |
2450 ange-ftp-dl-dir-regexp)))) | |
2451 | |
2452 (defmacro ange-ftp-dl-parser () | |
2453 ;; Parse the current buffer, which is assumed to be a descriptive | |
2454 ;; listing, and return a hashtable. | |
2455 (` (let ((tbl (ange-ftp-make-hashtable))) | |
2456 (while (not (eobp)) | |
2457 (ange-ftp-put-hash-entry | |
2458 (buffer-substring (point) | |
2459 (progn | |
2460 (skip-chars-forward "^ /\n") | |
2461 (point))) | |
2462 (eq (following-char) ?/) | |
2463 tbl) | |
2464 (forward-line 1)) | |
2465 (ange-ftp-put-hash-entry "." t tbl) | |
2466 (ange-ftp-put-hash-entry ".." t tbl) | |
2467 tbl))) | |
2468 | |
7042 | 2469 ;; Parse the current buffer which is assumed to be in a dired-like listing |
2470 ;; format, and return a hashtable as the result. If the listing is not really | |
2471 ;; a listing, then return nil. | |
2472 | |
1106 | 2473 (defun ange-ftp-parse-dired-listing (&optional switches) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2474 (save-match-data |
1106 | 2475 (cond |
2476 ((looking-at "^total [0-9]+$") | |
2477 (forward-line 1) | |
5067
4854aff5c5b3
(ange-ftp-parse-dired-listing): Skip extra blank line
Richard M. Stallman <rms@gnu.org>
parents:
4912
diff
changeset
|
2478 ;; Some systems put in a blank line here. |
4854aff5c5b3
(ange-ftp-parse-dired-listing): Skip extra blank line
Richard M. Stallman <rms@gnu.org>
parents:
4912
diff
changeset
|
2479 (if (eolp) (forward-line 1)) |
1106 | 2480 (ange-ftp-ls-parser)) |
2481 ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'") | |
2482 ;; It's an ls error message. | |
2483 nil) | |
2484 ((eobp) ; i.e. (zerop (buffer-size)) | |
2485 ;; This could be one of: | |
2486 ;; (1) An Ultrix ls error message | |
2487 ;; (2) A listing with the A switch of an empty directory | |
2488 ;; on a machine which doesn't give a total line. | |
2489 ;; (3) The twilight zone. | |
2490 ;; We'll assume (1) for now. | |
2491 nil) | |
2492 ((re-search-forward ange-ftp-date-regexp nil t) | |
2493 (beginning-of-line) | |
2494 (ange-ftp-ls-parser)) | |
2495 ((re-search-forward "^[^ \n\t]+ +\\([0-9]+\\|-\\|=\\) " nil t) | |
2496 ;; It's a dl listing (I hope). | |
2497 ;; file is bound by the call to ange-ftp-ls | |
2498 (ange-ftp-add-dl-dir ange-ftp-this-file) | |
2499 (beginning-of-line) | |
2500 (ange-ftp-dl-parser)) | |
2501 (t nil)))) | |
2502 | |
2503 (defun ange-ftp-set-files (directory files) | |
2504 "For a given DIRECTORY, set or change the associated FILES hashtable." | |
2505 (and files (ange-ftp-put-hash-entry (file-name-as-directory directory) | |
2506 files ange-ftp-files-hashtable))) | |
2507 | |
2508 (defun ange-ftp-get-files (directory &optional no-error) | |
2509 "Given a given DIRECTORY, return a hashtable of file entries. | |
2510 This will give an error or return nil, depending on the value of | |
2511 NO-ERROR, if a listing for DIRECTORY cannot be obtained." | |
2512 (setq directory (file-name-as-directory directory)) ;normalize | |
2513 (or (ange-ftp-get-hash-entry directory ange-ftp-files-hashtable) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2514 (save-match-data |
1106 | 2515 (and (ange-ftp-ls directory |
2516 ;; This is an efficiency hack. We try to | |
2517 ;; anticipate what sort of listing dired | |
2518 ;; might want, and cache just such a listing. | |
2519 (if (and (boundp 'dired-actual-switches) | |
2520 (stringp dired-actual-switches) | |
2521 ;; We allow the A switch, which lists | |
2522 ;; all files except "." and "..". | |
2523 ;; This is OK because we manually | |
2524 ;; insert these entries | |
2525 ;; in the hash table. | |
2526 (string-match | |
2527 "[aA]" dired-actual-switches) | |
2528 (string-match | |
2529 "l" dired-actual-switches) | |
2530 (not (string-match | |
2531 "R" dired-actual-switches))) | |
2532 dired-actual-switches | |
2533 (if (and (boundp 'dired-listing-switches) | |
2534 (stringp dired-listing-switches) | |
2535 (string-match | |
2536 "[aA]" dired-listing-switches) | |
2537 (string-match | |
2538 "l" dired-listing-switches) | |
2539 (not (string-match | |
2540 "R" dired-listing-switches))) | |
2541 dired-listing-switches | |
2542 "-al")) | |
2543 t no-error) | |
2544 (ange-ftp-get-hash-entry | |
2545 directory ange-ftp-files-hashtable))))) | |
2546 | |
7042 | 2547 ;; Given NAME, return the file part that can be used for looking up the |
2548 ;; file's entry in a hashtable. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2549 (defmacro ange-ftp-get-file-part (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2550 (` (let ((file (file-name-nondirectory (, name)))) |
1106 | 2551 (if (string-equal file "") |
2552 "." | |
2553 file)))) | |
2554 | |
7042 | 2555 ;; Return whether ange-ftp-file-entry-p and ange-ftp-get-file-entry are |
2556 ;; allowed to determine if NAME is a sub-directory by listing it directly, | |
2557 ;; rather than listing its parent directory. This is used for efficiency so | |
2558 ;; that a wasted listing is not done: | |
2559 ;; 1. When looking for a .dired file in dired-x.el. | |
2560 ;; 2. The syntax of FILE and DIR make it impossible that FILE could be a valid | |
2561 ;; subdirectory. This is of course an OS dependent judgement. | |
2562 | |
1106 | 2563 (defmacro ange-ftp-allow-child-lookup (dir file) |
2564 (` (not | |
2565 (let* ((efile (, file)) ; expand once. | |
2566 (edir (, dir)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2567 (parsed (ange-ftp-ftp-name edir)) |
1106 | 2568 (host-type (ange-ftp-host-type |
2569 (car parsed)))) | |
2570 (or | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2571 ;;; This variable seems not to exist in Emacs 19 -- rms. |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2572 ;;; ;; Deal with dired |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2573 ;;; (and (boundp 'dired-local-variables-file) |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2574 ;;; (stringp dired-local-variables-file) |
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
2575 ;;; (string-equal dired-local-variables-file efile)) |
1106 | 2576 ;; No dots in dir names in vms. |
2577 (and (eq host-type 'vms) | |
2578 (string-match "\\." efile)) | |
2579 ;; No subdirs in mts of cms. | |
2580 (and (memq host-type '(mts cms)) | |
2581 (not (string-equal "/" (nth 2 parsed))))))))) | |
2582 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2583 (defun ange-ftp-file-entry-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2584 "Given NAME, return whether there is a file entry for it." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2585 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2586 (dir (file-name-directory name)) |
1106 | 2587 (ent (ange-ftp-get-hash-entry dir ange-ftp-files-hashtable)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2588 (file (ange-ftp-get-file-part name))) |
1106 | 2589 (if ent |
2590 (ange-ftp-hash-entry-exists-p file ent) | |
2591 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2592 (setq ent (ange-ftp-get-files name t)) |
1106 | 2593 ;; Try a child lookup. i.e. try to list file as a |
2594 ;; subdirectory of dir. This is a good idea because | |
2595 ;; we may not have read permission for file's parent. Also, | |
2596 ;; people tend to work down directory trees anyway. We use | |
2597 ;; no-error ;; because if file does not exist as a subdir., | |
2598 ;; then dumb hosts will give an ftp error. Smart unix hosts | |
2599 ;; will simply send back the ls | |
2600 ;; error message. | |
2601 (ange-ftp-get-hash-entry "." ent)) | |
2602 ;; Child lookup failed. Try the parent. If this bombs, | |
2603 ;; we are at wits end -- signal an error. | |
2604 ;; Problem: If this signals an error, the error message | |
2605 ;; may not have a lot to do with what went wrong. | |
2606 (ange-ftp-hash-entry-exists-p file | |
2607 (ange-ftp-get-files dir)))))) | |
2608 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2609 (defun ange-ftp-get-file-entry (name) |
1233 | 2610 "Given NAME, return the given file entry. |
2611 The entry will be either t for a directory, nil for a normal file, | |
2612 or a string for a symlink. If the file isn't in the hashtable, | |
2613 this also returns nil." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2614 (let* ((name (directory-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2615 (dir (file-name-directory name)) |
1106 | 2616 (ent (ange-ftp-get-hash-entry dir ange-ftp-files-hashtable)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2617 (file (ange-ftp-get-file-part name))) |
1106 | 2618 (if ent |
2619 (ange-ftp-get-hash-entry file ent) | |
2620 (or (and (ange-ftp-allow-child-lookup dir file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2621 (setq ent (ange-ftp-get-files name t)) |
1106 | 2622 (ange-ftp-get-hash-entry "." ent)) |
2623 ;; i.e. it's a directory by child lookup | |
2624 (ange-ftp-get-hash-entry file | |
2625 (ange-ftp-get-files dir)))))) | |
2626 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2627 (defun ange-ftp-internal-delete-file-entry (name &optional dir-p) |
1106 | 2628 (if dir-p |
2629 (progn | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2630 (setq name (file-name-as-directory name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2631 (ange-ftp-del-hash-entry name ange-ftp-files-hashtable) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2632 (setq name (directory-file-name name)))) |
1106 | 2633 ;; Note that file-name-as-directory followed by directory-file-name |
2634 ;; serves to canonicalize directory file names to their unix form. | |
2635 ;; i.e. in VMS, FOO.DIR -> FOO/ -> FOO | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2636 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2637 ange-ftp-files-hashtable))) |
2638 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2639 (ange-ftp-del-hash-entry (ange-ftp-get-file-part name) |
1106 | 2640 files)))) |
2641 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2642 (defun ange-ftp-internal-add-file-entry (name &optional dir-p) |
1106 | 2643 (and dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2644 (setq name (directory-file-name name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2645 (let ((files (ange-ftp-get-hash-entry (file-name-directory name) |
1106 | 2646 ange-ftp-files-hashtable))) |
2647 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2648 (ange-ftp-put-hash-entry (ange-ftp-get-file-part name) |
1106 | 2649 dir-p |
2650 files)))) | |
2651 | |
2652 (defun ange-ftp-wipe-file-entries (host user) | |
7042 | 2653 "Get rid of entry for HOST, USER pair from file entry information hashtable." |
1106 | 2654 (let ((new-tbl (ange-ftp-make-hashtable (length ange-ftp-files-hashtable)))) |
2655 (ange-ftp-map-hashtable | |
2656 (function | |
2657 (lambda (key val) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2658 (let ((parsed (ange-ftp-ftp-name key))) |
1106 | 2659 (if parsed |
2660 (let ((h (nth 0 parsed)) | |
2661 (u (nth 1 parsed))) | |
2662 (or (and (equal host h) (equal user u)) | |
2663 (ange-ftp-put-hash-entry key val new-tbl))))))) | |
2664 ange-ftp-files-hashtable) | |
2665 (setq ange-ftp-files-hashtable new-tbl))) | |
2666 | |
2667 ;;;; ------------------------------------------------------------ | |
2668 ;;;; File transfer mode support. | |
2669 ;;;; ------------------------------------------------------------ | |
2670 | |
2671 (defun ange-ftp-set-binary-mode (host user) | |
2672 "Tell the ftp process for the given HOST & USER to switch to binary mode." | |
2673 (let ((result (ange-ftp-send-cmd host user '(type "binary")))) | |
2674 (if (not (car result)) | |
2675 (ange-ftp-error host user (concat "BINARY failed: " (cdr result))) | |
2676 (save-excursion | |
2677 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
10118
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2678 (and ange-ftp-binary-hash-mark-size |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2679 (setq ange-ftp-hash-mark-unit |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2680 (ash ange-ftp-binary-hash-mark-size -4))))))) |
1106 | 2681 |
2682 (defun ange-ftp-set-ascii-mode (host user) | |
2683 "Tell the ftp process for the given HOST & USER to switch to ascii mode." | |
2684 (let ((result (ange-ftp-send-cmd host user '(type "ascii")))) | |
2685 (if (not (car result)) | |
2686 (ange-ftp-error host user (concat "ASCII failed: " (cdr result))) | |
2687 (save-excursion | |
2688 (set-buffer (process-buffer (ange-ftp-get-process host user))) | |
10118
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2689 (and ange-ftp-ascii-hash-mark-size |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2690 (setq ange-ftp-hash-mark-unit |
7e22057e9516
(ange-ftp-set-binary-mode): Ignore hash size if nil.
Karl Heuer <kwzh@gnu.org>
parents:
9879
diff
changeset
|
2691 (ash ange-ftp-ascii-hash-mark-size -4))))))) |
1106 | 2692 |
2693 (defun ange-ftp-cd (host user dir) | |
2694 (let ((result (ange-ftp-send-cmd host user (list 'cd dir) "Doing CD"))) | |
2695 (or (car result) | |
2696 (ange-ftp-error host user (concat "CD failed: " (cdr result)))))) | |
2697 | |
2698 (defun ange-ftp-get-pwd (host user) | |
2699 "Attempts to get the current working directory for the given HOST/USER pair. | |
2700 Returns \( DIR . LINE \) where DIR is either the directory or NIL if not found, | |
2701 and LINE is the relevant success or fail line from the FTP-client." | |
2702 (let* ((result (ange-ftp-send-cmd host user '(pwd) "Getting PWD")) | |
2703 (line (cdr result)) | |
2704 dir) | |
2705 (if (car result) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2706 (save-match-data |
1106 | 2707 (and (or (string-match "\"\\([^\"]*\\)\"" line) |
2708 (string-match " \\([^ ]+\\) " line)) ; stone-age VMS servers! | |
2709 (setq dir (substring line | |
2710 (match-beginning 1) | |
2711 (match-end 1)))))) | |
2712 (cons dir line))) | |
2713 | |
2714 ;;; ------------------------------------------------------------ | |
2715 ;;; expand-file-name and friends...which currently don't work | |
2716 ;;; ------------------------------------------------------------ | |
2717 | |
2718 (defun ange-ftp-expand-dir (host user dir) | |
7042 | 2719 "Return the result of doing a PWD in the current FTP session. |
2720 Use the connection to machine HOST | |
1106 | 2721 logged in as user USER and cd'd to directory DIR." |
2722 (let* ((host-type (ange-ftp-host-type host user)) | |
2723 ;; It is more efficient to call ange-ftp-host-type | |
2724 ;; before binding res, because ange-ftp-host-type sometimes | |
2725 ;; adds to the info in the expand-dir-hashtable. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2726 (fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2727 (cdr (assq host-type ange-ftp-fix-name-func-alist))) |
1106 | 2728 (key (concat host "/" user "/" dir)) |
2729 (res (ange-ftp-get-hash-entry key ange-ftp-expand-dir-hashtable))) | |
2730 (or res | |
2731 (progn | |
2732 (or | |
2733 (string-equal user "anonymous") | |
2734 (string-equal user "ftp") | |
2735 (not (eq host-type 'unix)) | |
2736 (let* ((ange-ftp-good-msgs (concat ange-ftp-expand-dir-regexp | |
2737 "\\|" | |
2738 ange-ftp-good-msgs)) | |
2739 (result (ange-ftp-send-cmd host user | |
2740 (list 'get dir "/dev/null") | |
2741 (format "expanding %s" dir))) | |
2742 (line (cdr result))) | |
2743 (setq res | |
2744 (if (string-match ange-ftp-expand-dir-regexp line) | |
2745 (substring line | |
2746 (match-beginning 1) | |
2747 (match-end 1)))))) | |
2748 (or res | |
2749 (if (string-equal dir "~") | |
2750 (setq res (car (ange-ftp-get-pwd host user))) | |
2751 (let ((home (ange-ftp-expand-dir host user "~"))) | |
2752 (unwind-protect | |
2753 (and (ange-ftp-cd host user dir) | |
2754 (setq res (car (ange-ftp-get-pwd host user)))) | |
2755 (ange-ftp-cd host user home))))) | |
2756 (if res | |
2757 (let ((ange-ftp-this-user user) | |
2758 (ange-ftp-this-host host)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2759 (if fix-name-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2760 (setq res (funcall fix-name-func res 'reverse))) |
1106 | 2761 (ange-ftp-put-hash-entry |
2762 key res ange-ftp-expand-dir-hashtable))) | |
2763 res)))) | |
2764 | |
2765 (defun ange-ftp-canonize-filename (n) | |
2766 "Take a string and short-circuit //, /. and /.." | |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2767 (if (string-match "[^:]+//" n) ;don't upset Apollo users |
1106 | 2768 (setq n (substring n (1- (match-end 0))))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2769 (let ((parsed (ange-ftp-ftp-name n))) |
1106 | 2770 (if parsed |
2771 (let ((host (car parsed)) | |
2772 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2773 (name (nth 2 parsed))) |
1106 | 2774 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2775 ;; See if remote name is absolute. If so then just expand it and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2776 ;; replace the name component of the overall name. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2777 (cond ((string-match "^/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2778 name) |
1106 | 2779 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2780 ;; Name starts with ~ or ~user. Resolve that part of the name |
1106 | 2781 ;; making it absolute then re-expand it. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2782 ((string-match "^~[^/]*" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2783 (let* ((tilda (substring name |
1106 | 2784 (match-beginning 0) |
2785 (match-end 0))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2786 (rest (substring name (match-end 0))) |
1106 | 2787 (dir (ange-ftp-expand-dir host user tilda))) |
2788 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2789 (setq name (concat dir rest)) |
1106 | 2790 (error "User \"%s\" is not known" |
2791 (substring tilda 1))))) | |
2792 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2793 ;; relative name. Tack on homedir and re-expand. |
1106 | 2794 (t |
2795 (let ((dir (ange-ftp-expand-dir host user "~"))) | |
2796 (if dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2797 (setq name (concat |
1106 | 2798 (ange-ftp-real-file-name-as-directory dir) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2799 name)) |
1106 | 2800 (error "Unable to obtain CWD"))))) |
2801 | |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2802 ;; If name starts with //, preserve that, for apollo system. |
7923
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2803 (if (not (string-match "^//" name)) |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2804 (progn |
7923
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2805 (setq name (ange-ftp-real-expand-file-name name)) |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2806 |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2807 (if (string-match "^//" name) |
457dc75d1d60
(ange-ftp-canonize-filename): Fix wrong var name.
Richard M. Stallman <rms@gnu.org>
parents:
7829
diff
changeset
|
2808 (setq name (substring name 1))))) |
1106 | 2809 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2810 ;; Now substitute the expanded name back into the overall filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2811 (ange-ftp-replace-name-component n name)) |
1106 | 2812 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2813 ;; non-ange-ftp name. Just expand normally. |
1106 | 2814 (if (eq (string-to-char n) ?/) |
2815 (ange-ftp-real-expand-file-name n) | |
2816 (ange-ftp-real-expand-file-name | |
2817 (ange-ftp-real-file-name-nondirectory n) | |
2818 (ange-ftp-real-file-name-directory n)))))) | |
2819 | |
2820 (defun ange-ftp-expand-file-name (name &optional default) | |
2821 "Documented as original." | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2822 (save-match-data |
1106 | 2823 (if (eq (string-to-char name) ?/) |
7829
5412b8112b6e
(ange-ftp-canonize-filename): Preserve // after colon.
Richard M. Stallman <rms@gnu.org>
parents:
7747
diff
changeset
|
2824 (while (cond ((string-match "[^:]+//" name) ;don't upset Apollo users |
1106 | 2825 (setq name (substring name (1- (match-end 0))))) |
2826 ((string-match "/~" name) | |
2827 (setq name (substring name (1- (match-end 0)))))))) | |
2828 (cond ((eq (string-to-char name) ?~) | |
2829 (ange-ftp-real-expand-file-name name)) | |
2830 ((eq (string-to-char name) ?/) | |
2831 (ange-ftp-canonize-filename name)) | |
2832 ((zerop (length name)) | |
2833 (ange-ftp-canonize-filename (or default default-directory))) | |
2834 ((ange-ftp-canonize-filename | |
2835 (concat (file-name-as-directory (or default default-directory)) | |
2836 name)))))) | |
2837 | |
2838 ;;; These are problems--they are currently not enabled. | |
2839 | |
2840 (defvar ange-ftp-file-name-as-directory-alist nil | |
7042 | 2841 "Association list of \( TYPE \. FUNC \) pairs. |
1106 | 2842 FUNC converts a filename to a directory name for the operating |
2843 system TYPE.") | |
2844 | |
2845 (defun ange-ftp-file-name-as-directory (name) | |
2846 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2847 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2848 (if parsed |
2849 (if (string-equal (nth 2 parsed) "") | |
2850 name | |
2851 (funcall (or (cdr (assq | |
2852 (ange-ftp-host-type (car parsed)) | |
2853 ange-ftp-file-name-as-directory-alist)) | |
2854 'ange-ftp-real-file-name-as-directory) | |
2855 name)) | |
2856 (ange-ftp-real-file-name-as-directory name)))) | |
2857 | |
2858 (defun ange-ftp-file-name-directory (name) | |
2859 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2860 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2861 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2862 (let ((filename (nth 2 parsed))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2863 (if (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2864 (string-match "^~[^/]*$" filename)) |
1106 | 2865 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2866 (ange-ftp-replace-name-component |
1106 | 2867 name |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2868 (ange-ftp-real-file-name-directory filename)))) |
1106 | 2869 (ange-ftp-real-file-name-directory name)))) |
2870 | |
2871 (defun ange-ftp-file-name-nondirectory (name) | |
2872 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2873 (let ((parsed (ange-ftp-ftp-name name))) |
1106 | 2874 (if parsed |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2875 (let ((filename (nth 2 parsed))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2876 (if (save-match-data |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
2877 (string-match "^~[^/]*$" filename)) |
1106 | 2878 "" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2879 (ange-ftp-real-file-name-nondirectory name))) |
1106 | 2880 (ange-ftp-real-file-name-nondirectory name)))) |
2881 | |
2882 (defun ange-ftp-directory-file-name (dir) | |
2883 "Documented as original." | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2884 (let ((parsed (ange-ftp-ftp-name dir))) |
1106 | 2885 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2886 (ange-ftp-replace-name-component |
1106 | 2887 dir |
2888 (ange-ftp-real-directory-file-name (nth 2 parsed))) | |
2889 (ange-ftp-real-directory-file-name dir)))) | |
2890 | |
2891 | |
2892 ;;; Hooks that handle Emacs primitives. | |
2893 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2894 ;; Returns non-nil if should transfer FILE in binary mode. |
1106 | 2895 (defun ange-ftp-binary-file (file) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
2896 (save-match-data |
1106 | 2897 (string-match ange-ftp-binary-file-name-regexp file))) |
2898 | |
2899 (defun ange-ftp-write-region (start end filename &optional append visit) | |
2900 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2901 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2902 (if parsed |
2903 (let* ((host (nth 0 parsed)) | |
2904 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2905 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2906 (temp (ange-ftp-make-tmp-name host)) |
2907 (binary (ange-ftp-binary-file filename)) | |
2908 (cmd (if append 'append 'put)) | |
2909 (abbr (ange-ftp-abbreviate-filename filename))) | |
2910 (unwind-protect | |
2911 (progn | |
2912 (let ((executing-macro t) | |
2913 (filename (buffer-file-name)) | |
2914 (mod-p (buffer-modified-p))) | |
2915 (unwind-protect | |
2916 (ange-ftp-real-write-region start end temp nil visit) | |
2917 ;; cleanup forms | |
2918 (setq buffer-file-name filename) | |
2919 (set-buffer-modified-p mod-p))) | |
2920 (if binary | |
2921 (ange-ftp-set-binary-mode host user)) | |
2922 | |
2923 ;; tell the process filter what size the transfer will be. | |
2924 (let ((attr (file-attributes temp))) | |
2925 (if attr | |
2926 (ange-ftp-set-xfer-size host user (nth 7 attr)))) | |
2927 | |
2928 ;; put or append the file. | |
2929 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2930 (list cmd temp name) |
1106 | 2931 (format "Writing %s" abbr)))) |
2932 (or (car result) | |
2933 (signal 'ftp-error | |
2934 (list | |
2935 "Opening output file" | |
2936 (format "FTP Error: \"%s\"" (cdr result)) | |
2937 filename))))) | |
2938 (ange-ftp-del-tmp-name temp) | |
2939 (if binary | |
2940 (ange-ftp-set-ascii-mode host user))) | |
2941 (if (eq visit t) | |
2942 (progn | |
5350
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
2943 (set-visited-file-modtime '(0 0)) |
1106 | 2944 (ange-ftp-set-buffer-mode) |
2945 (setq buffer-file-name filename) | |
2946 (set-buffer-modified-p nil))) | |
2947 (ange-ftp-message "Wrote %s" abbr) | |
2948 (ange-ftp-add-file-entry filename)) | |
2949 (ange-ftp-real-write-region start end filename append visit)))) | |
2950 | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
2951 (defun ange-ftp-insert-file-contents (filename &optional visit beg end replace) |
1106 | 2952 (barf-if-buffer-read-only) |
2953 (setq filename (expand-file-name filename)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2954 (let ((parsed (ange-ftp-ftp-name filename))) |
1106 | 2955 (if parsed |
2956 (progn | |
2957 (if visit | |
2958 (setq buffer-file-name filename)) | |
2959 (if (or (file-exists-p filename) | |
2960 (progn | |
2961 (setq ange-ftp-ls-cache-file nil) | |
2962 (ange-ftp-del-hash-entry (file-name-directory filename) | |
2963 ange-ftp-files-hashtable) | |
2964 (file-exists-p filename))) | |
2965 (let* ((host (nth 0 parsed)) | |
2966 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2967 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 2968 (temp (ange-ftp-make-tmp-name host)) |
2969 (binary (ange-ftp-binary-file filename)) | |
2970 (abbr (ange-ftp-abbreviate-filename filename)) | |
2971 size) | |
2972 (unwind-protect | |
2973 (progn | |
2974 (if binary | |
2975 (ange-ftp-set-binary-mode host user)) | |
2976 (let ((result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
2977 (list 'get name temp) |
1106 | 2978 (format "Retrieving %s" abbr)))) |
2979 (or (car result) | |
2980 (signal 'ftp-error | |
2981 (list | |
2982 "Opening input file" | |
2983 (format "FTP Error: \"%s\"" (cdr result)) | |
2984 filename)))) | |
2985 (if (or (ange-ftp-real-file-readable-p temp) | |
2986 (sleep-for ange-ftp-retry-time) | |
2987 ;; Wait for file to hopefully appear. | |
2988 (ange-ftp-real-file-readable-p temp)) | |
2989 (setq | |
2990 size | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
2991 (nth 1 (ange-ftp-real-insert-file-contents |
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
2992 temp visit beg end replace))) |
1106 | 2993 (signal 'ftp-error |
2994 (list | |
2995 "Opening input file:" | |
2996 (format | |
2997 "FTP Error: %s not arrived or readable" | |
2998 filename))))) | |
2999 (if binary | |
3000 (ange-ftp-set-ascii-mode host user)) | |
3001 (ange-ftp-del-tmp-name temp)) | |
3002 (if visit | |
5350
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3003 (progn |
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3004 (set-visited-file-modtime '(0 0)) |
722bd9d45ab2
(ange-ftp-write-region): Call set-visited-file-modtime.
Richard M. Stallman <rms@gnu.org>
parents:
5265
diff
changeset
|
3005 (setq buffer-file-name filename))) |
1106 | 3006 (list filename size)) |
3007 (signal 'file-error | |
3008 (list | |
3009 "Opening input file" | |
3010 filename)))) | |
5984
ec9477c8db1d
(ange-ftp-insert-file-contents): New arg REPLACE.
Richard M. Stallman <rms@gnu.org>
parents:
5840
diff
changeset
|
3011 (ange-ftp-real-insert-file-contents filename visit beg end replace)))) |
1106 | 3012 |
3013 (defun ange-ftp-expand-symlink (file dir) | |
3014 (if (file-name-absolute-p file) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3015 (ange-ftp-replace-name-component dir file) |
1106 | 3016 (expand-file-name file dir))) |
3017 | |
3018 (defun ange-ftp-file-symlink-p (file) | |
3019 ;; call ange-ftp-expand-file-name rather than the normal | |
3020 ;; expand-file-name to stop loops when using a package that | |
3021 ;; redefines both file-symlink-p and expand-file-name. | |
3022 (setq file (ange-ftp-expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3023 (if (ange-ftp-ftp-name file) |
1106 | 3024 (let ((file-ent |
3025 (ange-ftp-get-hash-entry | |
3026 (ange-ftp-get-file-part file) | |
3027 (ange-ftp-get-files (file-name-directory file))))) | |
3028 (if (stringp file-ent) | |
3029 (if (file-name-absolute-p file-ent) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3030 (ange-ftp-replace-name-component |
1106 | 3031 (file-name-directory file) file-ent) |
3032 file-ent))) | |
3033 (ange-ftp-real-file-symlink-p file))) | |
3034 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3035 (defun ange-ftp-file-exists-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3036 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3037 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3038 (if (ange-ftp-file-entry-p name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3039 (let ((file-ent (ange-ftp-get-file-entry name))) |
1106 | 3040 (if (stringp file-ent) |
3041 (file-exists-p | |
3042 (ange-ftp-expand-symlink file-ent | |
3043 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3044 (directory-file-name name)))) |
1106 | 3045 t))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3046 (ange-ftp-real-file-exists-p name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3047 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3048 (defun ange-ftp-file-directory-p (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3049 (setq name (expand-file-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3050 (if (ange-ftp-ftp-name name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3051 ;; We do a file-name-as-directory on name here because some |
1106 | 3052 ;; machines (VMS) use a .DIR to indicate the filename associated |
3053 ;; with a directory. This needs to be canonicalized. | |
3054 (let ((file-ent (ange-ftp-get-file-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3055 (ange-ftp-file-name-as-directory name)))) |
1106 | 3056 (if (stringp file-ent) |
3057 (file-directory-p | |
3058 (ange-ftp-expand-symlink file-ent | |
3059 (file-name-directory | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3060 (directory-file-name name)))) |
1106 | 3061 file-ent)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3062 (ange-ftp-real-file-directory-p name))) |
1106 | 3063 |
3064 (defun ange-ftp-directory-files (directory &optional full match | |
3065 &rest v19-args) | |
3066 (setq directory (expand-file-name directory)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3067 (if (ange-ftp-ftp-name directory) |
1106 | 3068 (progn |
3069 (ange-ftp-barf-if-not-directory directory) | |
3070 (let ((tail (ange-ftp-hash-table-keys | |
3071 (ange-ftp-get-files directory))) | |
3072 files f) | |
3073 (setq directory (file-name-as-directory directory)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3074 (save-match-data |
1106 | 3075 (while tail |
3076 (setq f (car tail) | |
3077 tail (cdr tail)) | |
3078 (if (or (not match) (string-match match f)) | |
3079 (setq files | |
3080 (cons (if full (concat directory f) f) files))))) | |
3081 (nreverse files))) | |
3082 (apply 'ange-ftp-real-directory-files directory full match v19-args))) | |
3083 | |
3084 (defun ange-ftp-file-attributes (file) | |
3085 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3086 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3087 (if parsed |
3088 (let ((part (ange-ftp-get-file-part file)) | |
3089 (files (ange-ftp-get-files (file-name-directory file)))) | |
3090 (if (ange-ftp-hash-entry-exists-p part files) | |
3091 (let ((host (nth 0 parsed)) | |
3092 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3093 (name (nth 2 parsed)) |
1106 | 3094 (dirp (ange-ftp-get-hash-entry part files))) |
3095 (list (if (and (stringp dirp) (file-name-absolute-p dirp)) | |
3096 (ange-ftp-expand-symlink dirp | |
3097 (file-name-directory file)) | |
3098 dirp) ;0 file type | |
3099 -1 ;1 link count | |
3100 -1 ;2 uid | |
3101 -1 ;3 gid | |
3102 '(0 0) ;4 atime | |
3103 '(0 0) ;5 mtime | |
3104 '(0 0) ;6 ctime | |
3105 -1 ;7 size | |
3106 (concat (if (stringp dirp) "l" (if dirp "d" "-")) | |
3107 "?????????") ;8 mode | |
3108 nil ;9 gid weird | |
3109 ;; Hack to give remote files a unique "inode number". | |
3110 ;; It's actually the sum of the characters in its name. | |
3111 (apply '+ (nconc (mapcar 'identity host) | |
3112 (mapcar 'identity user) | |
3113 (mapcar 'identity | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3114 (directory-file-name name)))) |
1106 | 3115 -1 ;11 device number [v19 only] |
3116 )))) | |
3117 (ange-ftp-real-file-attributes file)))) | |
3118 | |
3119 (defun ange-ftp-file-writable-p (file) | |
3120 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3121 (if (ange-ftp-ftp-name file) |
1106 | 3122 (or (file-exists-p file) ;guess here for speed |
3123 (file-directory-p (file-name-directory file))) | |
3124 (ange-ftp-real-file-writable-p file))) | |
3125 | |
3126 (defun ange-ftp-file-readable-p (file) | |
3127 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3128 (if (ange-ftp-ftp-name file) |
1106 | 3129 (file-exists-p file) |
3130 (ange-ftp-real-file-readable-p file))) | |
3131 | |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3132 (defun ange-ftp-file-executable-p (file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3133 (setq file (expand-file-name file)) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3134 (if (ange-ftp-ftp-name file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3135 (file-exists-p file) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3136 (ange-ftp-real-file-executable-p file))) |
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3137 |
1106 | 3138 (defun ange-ftp-delete-file (file) |
3139 (interactive "fDelete file: ") | |
3140 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3141 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 3142 (if parsed |
3143 (let* ((host (nth 0 parsed)) | |
3144 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3145 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 3146 (abbr (ange-ftp-abbreviate-filename file)) |
3147 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3148 (list 'delete name) |
1106 | 3149 (format "Deleting %s" abbr)))) |
3150 (or (car result) | |
3151 (signal 'ftp-error | |
3152 (list | |
3153 "Removing old name" | |
3154 (format "FTP Error: \"%s\"" (cdr result)) | |
3155 file))) | |
3156 (ange-ftp-delete-file-entry file)) | |
3157 (ange-ftp-real-delete-file file)))) | |
3158 | |
3159 (defun ange-ftp-verify-visited-file-modtime (buf) | |
3160 (let ((name (buffer-file-name buf))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3161 (if (and (stringp name) (ange-ftp-ftp-name name)) |
1106 | 3162 t |
3163 (ange-ftp-real-verify-visited-file-modtime buf)))) | |
3164 | |
3165 ;;;; ------------------------------------------------------------ | |
3166 ;;;; File copying support... totally re-written 6/24/92. | |
3167 ;;;; ------------------------------------------------------------ | |
3168 | |
3169 (defun ange-ftp-barf-or-query-if-file-exists (absname querystring interactive) | |
3170 (if (file-exists-p absname) | |
3171 (if (not interactive) | |
3172 (signal 'file-already-exists (list absname)) | |
3173 (if (not (yes-or-no-p (format "File %s already exists; %s anyway? " | |
3174 absname querystring))) | |
3175 (signal 'file-already-exists (list absname)))))) | |
3176 | |
3177 ;; async local copy commented out for now since I don't seem to get | |
3178 ;; the process sentinel called for some processes. | |
3179 ;; | |
3180 ;; (defun ange-ftp-copy-file-locally (filename newname ok-if-already-exists | |
3181 ;; keep-date cont) | |
3182 ;; "Kludge to copy a local file and call a continuation when the copy | |
3183 ;; finishes." | |
3184 ;; ;; check to see if we can overwrite | |
3185 ;; (if (or (not ok-if-already-exists) | |
3186 ;; (numberp ok-if-already-exists)) | |
3187 ;; (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3188 ;; (numberp ok-if-already-exists))) | |
3189 ;; (let ((proc (start-process " *copy*" | |
3190 ;; (generate-new-buffer "*copy*") | |
3191 ;; "cp" | |
3192 ;; filename | |
3193 ;; newname)) | |
3194 ;; res) | |
3195 ;; (set-process-sentinel proc (function ange-ftp-copy-file-locally-sentinel)) | |
3196 ;; (process-kill-without-query proc) | |
3197 ;; (save-excursion | |
3198 ;; (set-buffer (process-buffer proc)) | |
3199 ;; (make-variable-buffer-local 'copy-cont) | |
3200 ;; (setq copy-cont cont)))) | |
3201 ;; | |
3202 ;; (defun ange-ftp-copy-file-locally-sentinel (proc status) | |
3203 ;; (save-excursion | |
3204 ;; (set-buffer (process-buffer proc)) | |
3205 ;; (let ((cont copy-cont) | |
3206 ;; (result (buffer-string))) | |
3207 ;; (unwind-protect | |
3208 ;; (if (and (string-equal status "finished\n") | |
3209 ;; (zerop (length result))) | |
3210 ;; (ange-ftp-call-cont cont t nil) | |
3211 ;; (ange-ftp-call-cont cont | |
3212 ;; nil | |
3213 ;; (if (zerop (length result)) | |
3214 ;; (substring status 0 -1) | |
3215 ;; (substring result 0 -1)))) | |
3216 ;; (kill-buffer (current-buffer)))))) | |
3217 | |
3218 ;; this is the extended version of ange-ftp-copy-file-internal that works | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
3219 ;; asynchronously if asked nicely. |
1106 | 3220 (defun ange-ftp-copy-file-internal (filename newname ok-if-already-exists |
3221 keep-date &optional msg cont nowait) | |
3222 (setq filename (expand-file-name filename) | |
3223 newname (expand-file-name newname)) | |
3224 | |
3225 ;; canonicalize newname if a directory. | |
3226 (if (file-directory-p newname) | |
3227 (setq newname (expand-file-name (file-name-nondirectory filename) newname))) | |
3228 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3229 (let ((f-parsed (ange-ftp-ftp-name filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3230 (t-parsed (ange-ftp-ftp-name newname))) |
1106 | 3231 |
3232 ;; local file to local file copy? | |
3233 (if (and (not f-parsed) (not t-parsed)) | |
3234 (progn | |
3235 (ange-ftp-real-copy-file filename newname ok-if-already-exists | |
3236 keep-date) | |
3237 (if cont | |
3238 (ange-ftp-call-cont cont t "Copied locally"))) | |
3239 ;; one or both files are remote. | |
3240 (let* ((f-host (and f-parsed (nth 0 f-parsed))) | |
3241 (f-user (and f-parsed (nth 1 f-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3242 (f-name (and f-parsed (ange-ftp-quote-string (nth 2 f-parsed)))) |
1106 | 3243 (f-abbr (ange-ftp-abbreviate-filename filename)) |
3244 (t-host (and t-parsed (nth 0 t-parsed))) | |
3245 (t-user (and t-parsed (nth 1 t-parsed))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3246 (t-name (and t-parsed (ange-ftp-quote-string (nth 2 t-parsed)))) |
1106 | 3247 (t-abbr (ange-ftp-abbreviate-filename newname filename)) |
3248 (binary (or (ange-ftp-binary-file filename) | |
3249 (ange-ftp-binary-file newname))) | |
3250 temp1 | |
3251 temp2) | |
3252 | |
3253 ;; check to see if we can overwrite | |
3254 (if (or (not ok-if-already-exists) | |
3255 (numberp ok-if-already-exists)) | |
3256 (ange-ftp-barf-or-query-if-file-exists newname "copy to it" | |
3257 (numberp ok-if-already-exists))) | |
3258 | |
3259 ;; do the copying. | |
3260 (if f-parsed | |
3261 | |
3262 ;; filename was remote. | |
3263 (progn | |
3264 (if (or (ange-ftp-use-gateway-p f-host) | |
3265 t-parsed) | |
3266 ;; have to use intermediate file if we are getting via | |
3267 ;; gateway machine or we are doing a remote to remote copy. | |
3268 (setq temp1 (ange-ftp-make-tmp-name f-host))) | |
3269 | |
3270 (if binary | |
3271 (ange-ftp-set-binary-mode f-host f-user)) | |
3272 | |
3273 (ange-ftp-send-cmd | |
3274 f-host | |
3275 f-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3276 (list 'get f-name (or temp1 newname)) |
1106 | 3277 (or msg |
3278 (if (and temp1 t-parsed) | |
3279 (format "Getting %s" f-abbr) | |
3280 (format "Copying %s to %s" f-abbr t-abbr))) | |
3281 (list (function ange-ftp-cf1) | |
3282 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3283 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3284 t-parsed t-host t-user t-name t-abbr |
1106 | 3285 temp1 temp2 cont nowait) |
3286 nowait)) | |
3287 | |
3288 ;; filename wasn't remote. newname must be remote. call the | |
3289 ;; function which does the remainder of the copying work. | |
3290 (ange-ftp-cf1 t nil | |
3291 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3292 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3293 t-parsed t-host t-user t-name t-abbr |
1106 | 3294 nil nil cont nowait)))))) |
3295 | |
3296 ;; next part of copying routine. | |
3297 (defun ange-ftp-cf1 (result line | |
3298 filename newname binary msg | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3299 f-parsed f-host f-user f-name f-abbr |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3300 t-parsed t-host t-user t-name t-abbr |
1106 | 3301 temp1 temp2 cont nowait) |
3302 (if line | |
3303 ;; filename must have been remote, and we must have just done a GET. | |
3304 (unwind-protect | |
3305 (or result | |
3306 ;; GET failed for some reason. Clean up and get out. | |
3307 (progn | |
3308 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3309 (or cont | |
3310 (signal 'ftp-error (list "Opening input file" | |
3311 (format "FTP Error: \"%s\"" line) | |
3312 filename))))) | |
3313 ;; cleanup | |
3314 (if binary | |
3315 (ange-ftp-set-ascii-mode f-host f-user)))) | |
3316 | |
3317 (if result | |
3318 ;; We now have to copy either temp1 or filename to newname. | |
3319 (if t-parsed | |
3320 | |
3321 ;; newname was remote. | |
3322 (progn | |
3323 (if (ange-ftp-use-gateway-p t-host) | |
3324 (setq temp2 (ange-ftp-make-tmp-name t-host))) | |
3325 | |
3326 ;; make sure data is moved into the right place for the | |
3327 ;; outgoing transfer. gateway temporary files complicate | |
3328 ;; things nicely. | |
3329 (if temp1 | |
3330 (if temp2 | |
3331 (if (string-equal temp1 temp2) | |
3332 (setq temp1 nil) | |
3333 (ange-ftp-real-copy-file temp1 temp2 t)) | |
3334 (setq temp2 temp1 temp1 nil)) | |
3335 (if temp2 | |
3336 (ange-ftp-real-copy-file filename temp2 t))) | |
3337 | |
3338 (if binary | |
3339 (ange-ftp-set-binary-mode t-host t-user)) | |
3340 | |
3341 ;; tell the process filter what size the file is. | |
3342 (let ((attr (file-attributes (or temp2 filename)))) | |
3343 (if attr | |
3344 (ange-ftp-set-xfer-size t-host t-user (nth 7 attr)))) | |
3345 | |
3346 (ange-ftp-send-cmd | |
3347 t-host | |
3348 t-user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3349 (list 'put (or temp2 filename) t-name) |
1106 | 3350 (or msg |
3351 (if (and temp2 f-parsed) | |
3352 (format "Putting %s" newname) | |
3353 (format "Copying %s to %s" f-abbr t-abbr))) | |
3354 (list (function ange-ftp-cf2) | |
3355 newname t-host t-user binary temp1 temp2 cont) | |
3356 nowait)) | |
3357 | |
3358 ;; newname wasn't remote. | |
3359 (ange-ftp-cf2 t nil newname t-host t-user binary temp1 temp2 cont)) | |
3360 | |
3361 ;; first copy failed, tell caller | |
3362 (ange-ftp-call-cont cont result line))) | |
3363 | |
3364 ;; last part of copying routine. | |
3365 (defun ange-ftp-cf2 (result line newname t-host t-user binary temp1 temp2 cont) | |
3366 (unwind-protect | |
3367 (if line | |
3368 ;; result from doing a local to remote copy. | |
3369 (unwind-protect | |
3370 (progn | |
3371 (or result | |
3372 (or cont | |
3373 (signal 'ftp-error | |
3374 (list "Opening output file" | |
3375 (format "FTP Error: \"%s\"" line) | |
3376 newname)))) | |
3377 | |
3378 (ange-ftp-add-file-entry newname)) | |
3379 | |
3380 ;; cleanup. | |
3381 (if binary | |
3382 (ange-ftp-set-ascii-mode t-host t-user))) | |
3383 | |
3384 ;; newname was local. | |
3385 (if temp1 | |
3386 (ange-ftp-real-copy-file temp1 newname t))) | |
3387 | |
3388 ;; clean up | |
3389 (and temp1 (ange-ftp-del-tmp-name temp1)) | |
3390 (and temp2 (ange-ftp-del-tmp-name temp2)) | |
3391 (ange-ftp-call-cont cont result line))) | |
3392 | |
3393 (defun ange-ftp-copy-file (filename newname &optional ok-if-already-exists | |
3394 keep-date) | |
3395 (interactive "fCopy file: \nFCopy %s to file: \np") | |
3396 (ange-ftp-copy-file-internal filename | |
3397 newname | |
3398 ok-if-already-exists | |
3399 keep-date | |
3400 nil | |
3401 nil | |
3402 (interactive-p))) | |
3403 | |
3404 ;;;; ------------------------------------------------------------ | |
3405 ;;;; File renaming support. | |
3406 ;;;; ------------------------------------------------------------ | |
3407 | |
3408 (defun ange-ftp-rename-remote-to-remote (filename newname f-parsed t-parsed | |
3409 binary) | |
3410 "Rename remote file FILE to remote file NEWNAME." | |
3411 (let ((f-host (nth 0 f-parsed)) | |
3412 (f-user (nth 1 f-parsed)) | |
3413 (t-host (nth 0 t-parsed)) | |
3414 (t-user (nth 1 t-parsed))) | |
3415 (if (and (string-equal f-host t-host) | |
3416 (string-equal f-user t-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3417 (let* ((f-name (ange-ftp-quote-string (nth 2 f-parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3418 (t-name (ange-ftp-quote-string (nth 2 t-parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3419 (cmd (list 'rename f-name t-name)) |
1106 | 3420 (fabbr (ange-ftp-abbreviate-filename filename)) |
3421 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3422 (result (ange-ftp-send-cmd f-host f-user cmd | |
3423 (format "Renaming %s to %s" | |
3424 fabbr | |
3425 nabbr)))) | |
3426 (or (car result) | |
3427 (signal 'ftp-error | |
3428 (list | |
3429 "Renaming" | |
3430 (format "FTP Error: \"%s\"" (cdr result)) | |
3431 filename | |
3432 newname))) | |
3433 (ange-ftp-add-file-entry newname) | |
3434 (ange-ftp-delete-file-entry filename)) | |
3435 (ange-ftp-copy-file-internal filename newname t nil) | |
3436 (delete-file filename)))) | |
3437 | |
3438 (defun ange-ftp-rename-local-to-remote (filename newname) | |
1233 | 3439 "Rename local FILENAME to remote file NEWNAME." |
1106 | 3440 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3441 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3442 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3443 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3444 (let (ange-ftp-process-verbose) | |
3445 (delete-file filename)))) | |
3446 | |
3447 (defun ange-ftp-rename-remote-to-local (filename newname) | |
1233 | 3448 "Rename remote file FILENAME to local file NEWNAME." |
1106 | 3449 (let* ((fabbr (ange-ftp-abbreviate-filename filename)) |
3450 (nabbr (ange-ftp-abbreviate-filename newname filename)) | |
3451 (msg (format "Renaming %s to %s" fabbr nabbr))) | |
3452 (ange-ftp-copy-file-internal filename newname t nil msg) | |
3453 (let (ange-ftp-process-verbose) | |
3454 (delete-file filename)))) | |
3455 | |
3456 (defun ange-ftp-rename-file (filename newname &optional ok-if-already-exists) | |
3457 (interactive "fRename file: \nFRename %s to file: \np") | |
3458 (setq filename (expand-file-name filename)) | |
3459 (setq newname (expand-file-name newname)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3460 (let* ((f-parsed (ange-ftp-ftp-name filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3461 (t-parsed (ange-ftp-ftp-name newname)) |
1106 | 3462 (binary (if (or f-parsed t-parsed) (ange-ftp-binary-file filename)))) |
3463 (if (and (or f-parsed t-parsed) | |
3464 (or (not ok-if-already-exists) | |
3465 (numberp ok-if-already-exists))) | |
3466 (ange-ftp-barf-or-query-if-file-exists | |
3467 newname | |
3468 "rename to it" | |
3469 (numberp ok-if-already-exists))) | |
3470 (if f-parsed | |
3471 (if t-parsed | |
3472 (ange-ftp-rename-remote-to-remote filename newname f-parsed | |
3473 t-parsed binary) | |
3474 (ange-ftp-rename-remote-to-local filename newname)) | |
3475 (if t-parsed | |
3476 (ange-ftp-rename-local-to-remote filename newname) | |
3477 (ange-ftp-real-rename-file filename newname ok-if-already-exists))))) | |
3478 | |
3479 ;;;; ------------------------------------------------------------ | |
3480 ;;;; File name completion support. | |
3481 ;;;; ------------------------------------------------------------ | |
3482 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3483 ;; If the file entry SYM is a symlink, returns whether its file exists. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3484 ;; Note that `ange-ftp-this-dir' is used as a free variable. |
1106 | 3485 (defun ange-ftp-file-entry-active-p (sym) |
3486 (let ((val (get sym 'val))) | |
3487 (or (not (stringp val)) | |
3488 (file-exists-p (ange-ftp-expand-symlink val ange-ftp-this-dir))))) | |
3489 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3490 ;; If the file entry is not a directory (nor a symlink pointing to a directory) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3491 ;; returns whether the file (or file pointed to by the symlink) is ignored |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3492 ;; by completion-ignored-extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3493 ;; Note that `ange-ftp-this-dir' and `ange-ftp-completion-ignored-pattern' |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3494 ;; are used as free variables. |
1106 | 3495 (defun ange-ftp-file-entry-not-ignored-p (sym) |
3496 (let ((val (get sym 'val)) | |
3497 (symname (symbol-name sym))) | |
3498 (if (stringp val) | |
3499 (let ((file (ange-ftp-expand-symlink val ange-ftp-this-dir))) | |
3500 (or (file-directory-p file) | |
3501 (and (file-exists-p file) | |
3502 (not (string-match ange-ftp-completion-ignored-pattern | |
3503 symname))))) | |
3504 (or val ; is a directory name | |
3505 (not (string-match ange-ftp-completion-ignored-pattern symname)))))) | |
3506 | |
3507 (defun ange-ftp-file-name-all-completions (file dir) | |
3508 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3509 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3510 (progn |
3511 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3512 (setq ange-ftp-this-dir | |
3513 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) | |
3514 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3515 (completions | |
3516 (all-completions file tbl | |
3517 (function ange-ftp-file-entry-active-p)))) | |
3518 | |
3519 ;; see whether each matching file is a directory or not... | |
3520 (mapcar | |
3521 (function | |
3522 (lambda (file) | |
3523 (let ((ent (ange-ftp-get-hash-entry file tbl))) | |
3524 (if (and ent | |
3525 (or (not (stringp ent)) | |
3526 (file-directory-p | |
3527 (ange-ftp-expand-symlink ent | |
3528 ange-ftp-this-dir)))) | |
3529 (concat file "/") | |
3530 file)))) | |
3531 completions))) | |
3532 | |
3533 (if (string-equal "/" ange-ftp-this-dir) | |
3534 (nconc (all-completions file (ange-ftp-generate-root-prefixes)) | |
3535 (ange-ftp-real-file-name-all-completions file | |
3536 ange-ftp-this-dir)) | |
3537 (ange-ftp-real-file-name-all-completions file ange-ftp-this-dir))))) | |
3538 | |
3539 (defun ange-ftp-file-name-completion (file dir) | |
3540 (let ((ange-ftp-this-dir (expand-file-name dir))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3541 (if (ange-ftp-ftp-name ange-ftp-this-dir) |
1106 | 3542 (progn |
3543 (ange-ftp-barf-if-not-directory ange-ftp-this-dir) | |
3544 (if (equal file "") | |
3545 "" | |
3546 (setq ange-ftp-this-dir | |
3547 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) ;real? | |
3548 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) | |
3549 (ange-ftp-completion-ignored-pattern | |
3550 (mapconcat (function | |
3551 (lambda (s) (if (stringp s) | |
3552 (concat (regexp-quote s) "$") | |
3553 "/"))) ; / never in filename | |
3554 completion-ignored-extensions | |
3555 "\\|"))) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3556 (save-match-data |
1106 | 3557 (or (ange-ftp-file-name-completion-1 |
3558 file tbl ange-ftp-this-dir | |
3559 (function ange-ftp-file-entry-not-ignored-p)) | |
3560 (ange-ftp-file-name-completion-1 | |
3561 file tbl ange-ftp-this-dir | |
3562 (function ange-ftp-file-entry-active-p))))))) | |
3563 | |
3564 (if (string-equal "/" ange-ftp-this-dir) | |
3565 (try-completion | |
3566 file | |
3567 (nconc (ange-ftp-generate-root-prefixes) | |
3568 (mapcar 'list | |
3569 (ange-ftp-real-file-name-all-completions file "/")))) | |
3570 (ange-ftp-real-file-name-completion file ange-ftp-this-dir))))) | |
3571 | |
3572 | |
3573 (defun ange-ftp-file-name-completion-1 (file tbl dir predicate) | |
3574 (let ((bestmatch (try-completion file tbl predicate))) | |
3575 (if bestmatch | |
3576 (if (eq bestmatch t) | |
3577 (if (file-directory-p (expand-file-name file dir)) | |
3578 (concat file "/") | |
3579 t) | |
3580 (if (and (eq (try-completion bestmatch tbl predicate) t) | |
3581 (file-directory-p | |
3582 (expand-file-name bestmatch dir))) | |
3583 (concat bestmatch "/") | |
3584 bestmatch))))) | |
3585 | |
3586 ;; Put these lines uncommmented in your .emacs if you want C-r to refresh | |
3587 ;; ange-ftp's cache whilst doing filename completion. | |
3588 ;; | |
3589 ;;(define-key minibuffer-local-completion-map "\C-r" 'ange-ftp-re-read-dir) | |
3590 ;;(define-key minibuffer-local-must-match-map "\C-r" 'ange-ftp-re-read-dir) | |
3591 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3592 ;; Force a re-read of the directory DIR. If DIR is omitted then it defaults |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3593 ;; to the directory part of the contents of the current buffer. |
1106 | 3594 (defun ange-ftp-re-read-dir (&optional dir) |
3595 (interactive) | |
3596 (if dir | |
3597 (setq dir (expand-file-name dir)) | |
3598 (setq dir (file-name-directory (expand-file-name (buffer-string))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3599 (if (ange-ftp-ftp-name dir) |
1106 | 3600 (progn |
3601 (setq ange-ftp-ls-cache-file nil) | |
3602 (ange-ftp-del-hash-entry dir ange-ftp-files-hashtable) | |
3603 (ange-ftp-get-files dir t)))) | |
3604 | |
3611
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3605 (defun ange-ftp-make-directory (dir &optional parents) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3606 (interactive (list (expand-file-name (read-file-name "Make directory: ")))) |
3611
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3607 (if parents |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3608 (let ((parent (file-name-directory (directory-file-name dir)))) |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3609 (or (file-exists-p parent) |
2250b4880589
* ange-ftp.el (ange-ftp-make-directory): Take second optional
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
3610 (ange-ftp-make-directory parent parents)))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3611 (if (file-exists-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3612 (error "Cannot make directory %s: file already exists" dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3613 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3614 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3615 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3616 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3617 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3618 ;; insist that mkdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3619 ;; directory-name name as an arg. Argh!! This is a bug. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3620 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3621 ;; that mkdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3622 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3623 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3624 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3625 (ange-ftp-real-directory-file-name (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3626 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3627 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3628 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3629 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3630 (list 'mkdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3631 (format "Making directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3632 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3633 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3634 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3635 (format "Could not make directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3636 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3637 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3638 (ange-ftp-add-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3639 (ange-ftp-real-make-directory dir))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3640 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3641 (defun ange-ftp-delete-directory (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3642 (if (file-directory-p dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3643 (let ((parsed (ange-ftp-ftp-name dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3644 (if parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3645 (let* ((host (nth 0 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3646 (user (nth 1 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3647 ;; Some ftp's on unix machines (at least on Suns) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3648 ;; insist that rmdir take a filename, and not a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3649 ;; directory-name name as an arg. Argh!! This is a bug. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3650 ;; Non-unix machines will probably always insist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3651 ;; that rmdir takes a directory-name as an arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3652 ;; (as the ftp man page says it should). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3653 (name (ange-ftp-quote-string |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3654 (if (eq (ange-ftp-host-type host) 'unix) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3655 (ange-ftp-real-directory-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3656 (nth 2 parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3657 (ange-ftp-real-file-name-as-directory |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3658 (nth 2 parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3659 (abbr (ange-ftp-abbreviate-filename dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3660 (result (ange-ftp-send-cmd host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3661 (list 'rmdir name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3662 (format "Removing directory %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3663 abbr)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3664 (or (car result) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3665 (ange-ftp-error host user |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3666 (format "Could not remove directory %s: %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3667 dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3668 (cdr result)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3669 (ange-ftp-delete-file-entry dir t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3670 (ange-ftp-real-delete-directory dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3671 (error "Not a directory: %s" dir))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3672 |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3673 ;; Make a local copy of FILE and return its name. |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3674 |
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3675 (defun ange-ftp-file-local-copy (file) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3676 (let* ((fn1 (expand-file-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3677 (pa1 (ange-ftp-ftp-name fn1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3678 (if pa1 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3679 (let* ((tmp1 (ange-ftp-make-tmp-name (car pa1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3680 (bin1 (ange-ftp-binary-file fn1))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3681 (ange-ftp-copy-file-internal fn1 tmp1 t nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3682 (format "Getting %s" fn1)) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3683 tmp1)))) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3684 |
5840
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3685 (defun ange-ftp-load (file &optional noerror nomessage nosuffix) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3686 (if (ange-ftp-ftp-name file) |
5840
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3687 (let ((tryfiles (if nosuffix |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3688 (list file) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3689 (list (concat file ".elc") (concat file ".el") file))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3690 copy) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3691 (while (and tryfiles (not copy)) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3692 (condition-case error |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3693 (setq copy (ange-ftp-file-local-copy (car tryfiles))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3694 (ftp-error nil))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3695 (if copy |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3696 (unwind-protect |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3697 (funcall 'load copy noerror nomessage nosuffix) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3698 (delete-file copy)) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3699 (or noerror |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3700 (signal 'file-error (list "Cannot open load file" file))))) |
e173b4b346e5
(ange-ftp-load): Honor the NOERROR and NOSUFFIX flags.
Karl Heuer <kwzh@gnu.org>
parents:
5480
diff
changeset
|
3701 (ange-ftp-real-load file noerror nomessage nosuffix))) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3702 |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3703 ;; Calculate default-unhandled-directory for a given ange-ftp buffer. |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3704 (defun ange-ftp-unhandled-file-name-directory (filename) |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3705 (file-name-directory ange-ftp-tmp-name-template)) |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3706 |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3707 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3708 ;; Need the following functions for making filenames of compressed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3709 ;; files, because some OS's (unlike UNIX) do not allow a filename to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3710 ;; have two extensions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3711 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3712 (defvar ange-ftp-make-compressed-filename-alist nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3713 "Alist of host-type-specific functions to process file names for compression. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3714 Each element has the form (TYPE . FUNC). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3715 FUNC should take one argument, a file name, and return a list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3716 of the form (COMPRESSING NEWNAME). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3717 COMPRESSING should be t if the specified file should be compressed, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3718 and nil if it should be uncompressed (that is, if it is a compressed file). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3719 NEWNAME should be the name to give the new compressed or uncompressed file.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3720 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3721 (defun ange-ftp-dired-compress-file (name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3722 (let ((parsed (ange-ftp-ftp-name name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3723 conversion-func) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3724 (if (and parsed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3725 (setq conversion-func |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3726 (cdr (assq (ange-ftp-host-type (car parsed)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3727 ange-ftp-make-compressed-filename-alist)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3728 (let* ((decision |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
3729 (save-match-data (funcall conversion-func name))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3730 (compressing (car decision)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3731 (newfile (nth 1 decision))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3732 (if compressing |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3733 (ange-ftp-compress name newfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3734 (ange-ftp-uncompress name newfile))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3735 (let (file-name-handler-alist) |
3230
103f34320cb5
(ange-ftp-dired-compress-file):
Richard M. Stallman <rms@gnu.org>
parents:
3000
diff
changeset
|
3736 (dired-compress-file name))))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3737 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3738 ;; Copy FILE to this machine, compress it, and copy out to NFILE. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3739 (defun ange-ftp-compress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3740 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3741 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3742 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3743 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3744 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3745 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3746 (msg2 (format "Putting %s" nabbr))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3747 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3748 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3749 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3750 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3751 (ange-ftp-message "Compressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3752 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3753 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3754 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3755 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3756 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3757 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3758 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3759 (format "compress -f -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3760 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3761 (ange-ftp-message "Compressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3762 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3763 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3764 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3765 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3766 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3767 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3768 (ange-ftp-del-tmp-name tmp2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3769 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3770 ;; Copy FILE to this machine, uncompress it, and copy out to NFILE. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3771 (defun ange-ftp-uncompress (file nfile) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3772 (let* ((parsed (ange-ftp-ftp-name file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3773 (tmp1 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3774 (tmp2 (ange-ftp-make-tmp-name (car parsed))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3775 (abbr (ange-ftp-abbreviate-filename file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3776 (nabbr (ange-ftp-abbreviate-filename nfile)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3777 (msg1 (format "Getting %s" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3778 (msg2 (format "Putting %s" nabbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3779 ;; ;; Cheap hack because of problems with binary file transfers from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3780 ;; ;; VMS hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3781 ;; (gbinary (not (eq 'vms (ange-ftp-host-type (car parsed))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3782 ) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3783 (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3784 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3785 (ange-ftp-copy-file-internal file tmp1 t nil msg1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3786 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3787 (ange-ftp-message "Uncompressing %s..." abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3788 (call-process-region (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3789 (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3790 shell-file-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3791 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3792 t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3793 nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3794 "-c" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3795 (format "uncompress -c < %s > %s" tmp1 tmp2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3796 (and ange-ftp-process-verbose |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3797 (ange-ftp-message "Uncompressing %s...done" abbr)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3798 (if (zerop (buffer-size)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3799 (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3800 (let (ange-ftp-process-verbose) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3801 (delete-file file)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3802 (ange-ftp-copy-file-internal tmp2 nfile t nil msg2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3803 (ange-ftp-del-tmp-name tmp1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3804 (ange-ftp-del-tmp-name tmp2)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3805 |
1106 | 3806 ;;; Define the handler for special file names |
3807 ;;; that causes ange-ftp to be invoked. | |
3808 | |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3809 ;;;###autoload |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3810 (defun ange-ftp-hook-function (operation &rest args) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3811 (let ((fn (get operation 'ange-ftp))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3812 (if fn (apply fn args) |
7143
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3813 (ange-ftp-run-real-handler operation args)))) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3814 |
3893
d04e12f9153f
* ange-ftp.el: Loosen file-name-handler-alist regexp so we can do
Jim Blandy <jimb@redhat.com>
parents:
3831
diff
changeset
|
3815 |
d04e12f9153f
* ange-ftp.el: Loosen file-name-handler-alist regexp so we can do
Jim Blandy <jimb@redhat.com>
parents:
3831
diff
changeset
|
3816 ;;; This regexp takes care of real ange-ftp file names (with a slash |
4185
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3817 ;;; and colon). |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3818 ;;;###autoload |
4185
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3819 (or (assoc "^/[^/:]*[^/:]:" file-name-handler-alist) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3820 (setq file-name-handler-alist |
4185
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3821 (cons '("^/[^/:]*[^/:]:" . ange-ftp-hook-function) |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3822 file-name-handler-alist))) |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3823 |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3824 ;;; This regexp recognizes and absolute filenames with only one component, |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3825 ;;; for the sake of hostname completion. |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3826 ;;;###autoload |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3827 (or (assoc "^/[^/:]*\\'" file-name-handler-alist) |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3828 (setq file-name-handler-alist |
05a314aafd74
(file-name-handler-alist): Have two separate regexps with different hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4128
diff
changeset
|
3829 (cons '("^/[^/:]*\\'" . ange-ftp-completion-hook-function) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3830 file-name-handler-alist))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3831 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3832 ;;; The above two forms are sufficient to cause this file to be loaded |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3833 ;;; if the user ever uses a file name with a colon in it. |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3834 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3835 ;;; This sets the mode |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3836 (or (memq 'ange-ftp-set-buffer-mode find-file-hooks) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3837 (setq find-file-hooks |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3838 (cons 'ange-ftp-set-buffer-mode find-file-hooks))) |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3839 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3840 ;;; Now say where to find the handlers for particular operations. |
1106 | 3841 |
3842 (put 'file-name-directory 'ange-ftp 'ange-ftp-file-name-directory) | |
3843 (put 'file-name-nondirectory 'ange-ftp 'ange-ftp-file-name-nondirectory) | |
3844 (put 'file-name-as-directory 'ange-ftp 'ange-ftp-file-name-as-directory) | |
3845 (put 'directory-file-name 'ange-ftp 'ange-ftp-directory-file-name) | |
3846 (put 'expand-file-name 'ange-ftp 'ange-ftp-expand-file-name) | |
3847 (put 'make-directory 'ange-ftp 'ange-ftp-make-directory) | |
3848 (put 'delete-directory 'ange-ftp 'ange-ftp-delete-directory) | |
3849 (put 'insert-file-contents 'ange-ftp 'ange-ftp-insert-file-contents) | |
3850 (put 'directory-files 'ange-ftp 'ange-ftp-directory-files) | |
3851 (put 'file-directory-p 'ange-ftp 'ange-ftp-file-directory-p) | |
3852 (put 'file-writable-p 'ange-ftp 'ange-ftp-file-writable-p) | |
3853 (put 'file-readable-p 'ange-ftp 'ange-ftp-file-readable-p) | |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3854 (put 'file-executable-p 'ange-ftp 'ange-ftp-file-executable-p) |
1106 | 3855 (put 'file-symlink-p 'ange-ftp 'ange-ftp-file-symlink-p) |
3856 (put 'delete-file 'ange-ftp 'ange-ftp-delete-file) | |
3857 (put 'read-file-name-internal 'ange-ftp 'ange-ftp-read-file-name-internal) | |
3858 (put 'verify-visited-file-modtime 'ange-ftp | |
3859 'ange-ftp-verify-visited-file-modtime) | |
3860 (put 'file-exists-p 'ange-ftp 'ange-ftp-file-exists-p) | |
3861 (put 'write-region 'ange-ftp 'ange-ftp-write-region) | |
3862 (put 'backup-buffer 'ange-ftp 'ange-ftp-backup-buffer) | |
3863 (put 'copy-file 'ange-ftp 'ange-ftp-copy-file) | |
3864 (put 'rename-file 'ange-ftp 'ange-ftp-rename-file) | |
3865 (put 'file-attributes 'ange-ftp 'ange-ftp-file-attributes) | |
3866 (put 'file-name-all-completions 'ange-ftp 'ange-ftp-file-name-all-completions) | |
3867 (put 'file-name-completion 'ange-ftp 'ange-ftp-file-name-completion) | |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3868 (put 'insert-directory 'ange-ftp 'ange-ftp-insert-directory) |
1158
b48094d3cc42
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1132
diff
changeset
|
3869 (put 'file-local-copy 'ange-ftp 'ange-ftp-file-local-copy) |
1670
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3870 (put 'unhandled-file-name-directory 'ange-ftp |
174817d23858
* ange-ftp.el (ange-ftp-unhandled-file-name-directory): New
Jim Blandy <jimb@redhat.com>
parents:
1603
diff
changeset
|
3871 'ange-ftp-unhandled-file-name-directory) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3872 (put 'file-name-sans-versions 'ange-ftp 'ange-ftp-file-name-sans-versions) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3873 (put 'dired-uncache 'ange-ftp 'ange-ftp-dired-uncache) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3874 (put 'dired-compress-file 'ange-ftp 'ange-ftp-dired-compress-file) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3875 (put 'load 'ange-ftp 'ange-ftp-load) |
1454
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3876 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3877 ;; Turn off truename processing to save time. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3878 ;; Treat each name as its own truename. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3879 (put 'file-truename 'ange-ftp 'identity) |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3880 |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3881 ;; Turn off RCS/SCCS processing to save time. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3882 ;; This returns nil for any file name as argument. |
035c3f9fa12f
Add dummy handlers for file-truename and vc-registered.
Richard M. Stallman <rms@gnu.org>
parents:
1242
diff
changeset
|
3883 (put 'vc-registered 'ange-ftp 'null) |
1107
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3884 |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3885 ;;; Define ways of getting at unmodified Emacs primitives, |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3886 ;;; turning off our handler. |
e1519ff908b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1106
diff
changeset
|
3887 |
7042 | 3888 (defun ange-ftp-run-real-handler (operation args) |
3889 (let ((inhibit-file-name-handlers | |
3890 (cons 'ange-ftp-hook-function | |
7143
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3891 (cons 'ange-ftp-completion-hook-function |
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3892 (and (eq inhibit-file-name-operation operation) |
fa1ae50e55b3
(ange-ftp-hook-function): Use ange-ftp-run-real-handler.
Richard M. Stallman <rms@gnu.org>
parents:
7113
diff
changeset
|
3893 inhibit-file-name-handlers)))) |
7042 | 3894 (inhibit-file-name-operation operation)) |
3895 (apply operation args))) | |
3896 | |
1106 | 3897 (defun ange-ftp-real-file-name-directory (&rest args) |
7042 | 3898 (ange-ftp-run-real-handler 'file-name-directory args)) |
1106 | 3899 (defun ange-ftp-real-file-name-nondirectory (&rest args) |
7042 | 3900 (ange-ftp-run-real-handler 'file-name-nondirectory args)) |
1106 | 3901 (defun ange-ftp-real-file-name-as-directory (&rest args) |
7042 | 3902 (ange-ftp-run-real-handler 'file-name-as-directory args)) |
1106 | 3903 (defun ange-ftp-real-directory-file-name (&rest args) |
7042 | 3904 (ange-ftp-run-real-handler 'directory-file-name args)) |
1106 | 3905 (defun ange-ftp-real-expand-file-name (&rest args) |
7042 | 3906 (ange-ftp-run-real-handler 'expand-file-name args)) |
1106 | 3907 (defun ange-ftp-real-make-directory (&rest args) |
7042 | 3908 (ange-ftp-run-real-handler 'make-directory args)) |
1106 | 3909 (defun ange-ftp-real-delete-directory (&rest args) |
7042 | 3910 (ange-ftp-run-real-handler 'delete-directory args)) |
1106 | 3911 (defun ange-ftp-real-insert-file-contents (&rest args) |
7042 | 3912 (ange-ftp-run-real-handler 'insert-file-contents args)) |
1106 | 3913 (defun ange-ftp-real-directory-files (&rest args) |
7042 | 3914 (ange-ftp-run-real-handler 'directory-files args)) |
1106 | 3915 (defun ange-ftp-real-file-directory-p (&rest args) |
7042 | 3916 (ange-ftp-run-real-handler 'file-directory-p args)) |
1106 | 3917 (defun ange-ftp-real-file-writable-p (&rest args) |
7042 | 3918 (ange-ftp-run-real-handler 'file-writable-p args)) |
1106 | 3919 (defun ange-ftp-real-file-readable-p (&rest args) |
7042 | 3920 (ange-ftp-run-real-handler 'file-readable-p args)) |
4674
8db3c141cb62
(ange-ftp-file-executable-p): New function, handles file-executable-p.
Roland McGrath <roland@gnu.org>
parents:
4498
diff
changeset
|
3921 (defun ange-ftp-real-file-executable-p (&rest args) |
7042 | 3922 (ange-ftp-run-real-handler 'file-executable-p args)) |
1106 | 3923 (defun ange-ftp-real-file-symlink-p (&rest args) |
7042 | 3924 (ange-ftp-run-real-handler 'file-symlink-p args)) |
1106 | 3925 (defun ange-ftp-real-delete-file (&rest args) |
7042 | 3926 (ange-ftp-run-real-handler 'delete-file args)) |
1106 | 3927 (defun ange-ftp-real-read-file-name-internal (&rest args) |
7042 | 3928 (ange-ftp-run-real-handler 'read-file-name-internal args)) |
1106 | 3929 (defun ange-ftp-real-verify-visited-file-modtime (&rest args) |
7042 | 3930 (ange-ftp-run-real-handler 'verify-visited-file-modtime args)) |
1106 | 3931 (defun ange-ftp-real-file-exists-p (&rest args) |
7042 | 3932 (ange-ftp-run-real-handler 'file-exists-p args)) |
1106 | 3933 (defun ange-ftp-real-write-region (&rest args) |
7042 | 3934 (ange-ftp-run-real-handler 'write-region args)) |
1106 | 3935 (defun ange-ftp-real-backup-buffer (&rest args) |
7042 | 3936 (ange-ftp-run-real-handler 'backup-buffer args)) |
1106 | 3937 (defun ange-ftp-real-copy-file (&rest args) |
7042 | 3938 (ange-ftp-run-real-handler 'copy-file args)) |
1106 | 3939 (defun ange-ftp-real-rename-file (&rest args) |
7042 | 3940 (ange-ftp-run-real-handler 'rename-file args)) |
1106 | 3941 (defun ange-ftp-real-file-attributes (&rest args) |
7042 | 3942 (ange-ftp-run-real-handler 'file-attributes args)) |
1106 | 3943 (defun ange-ftp-real-file-name-all-completions (&rest args) |
7042 | 3944 (ange-ftp-run-real-handler 'file-name-all-completions args)) |
1106 | 3945 (defun ange-ftp-real-file-name-completion (&rest args) |
7042 | 3946 (ange-ftp-run-real-handler 'file-name-completion args)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3947 (defun ange-ftp-real-insert-directory (&rest args) |
7042 | 3948 (ange-ftp-run-real-handler 'insert-directory args)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3949 (defun ange-ftp-real-file-name-sans-versions (&rest args) |
7042 | 3950 (ange-ftp-run-real-handler 'file-name-sans-versions args)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3951 (defun ange-ftp-real-shell-command (&rest args) |
7042 | 3952 (ange-ftp-run-real-handler 'shell-command args)) |
3532
09bff9415131
(ange-ftp-real-load): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3502
diff
changeset
|
3953 (defun ange-ftp-real-load (&rest args) |
7042 | 3954 (ange-ftp-run-real-handler 'load args)) |
1106 | 3955 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3956 ;; Here we support using dired on remote hosts. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3957 ;; I have turned off the support for using dired on foreign directory formats. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3958 ;; That involves too many unclean hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3959 ;; It would be cleaner to support such operations by |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3960 ;; converting the foreign directory format to something dired can understand; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3961 ;; something close to ls -l output. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3962 ;; The logical place to do this is in the functions ange-ftp-parse-...-listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3963 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3964 ;; Some of the old dired hooks would still be needed even if this is done. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3965 ;; I have preserved (and modernized) those hooks. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3966 ;; So the format conversion should be all that is needed. |
1106 | 3967 |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3968 (defun ange-ftp-insert-directory (file switches &optional wildcard full) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3969 (let ((short (ange-ftp-abbreviate-filename file)) |
7747
40d992ff4662
(ange-ftp-insert-directory): Expand file name to
Richard M. Stallman <rms@gnu.org>
parents:
7664
diff
changeset
|
3970 (parsed (ange-ftp-ftp-name (expand-file-name file)))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3971 (if parsed |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3972 (insert |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3973 (if wildcard |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3974 (let ((default-directory (file-name-directory file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3975 (ange-ftp-ls (file-name-nondirectory file) switches nil nil t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3976 (ange-ftp-ls file switches full))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3977 (ange-ftp-real-insert-directory file switches wildcard full)))) |
1106 | 3978 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3979 (defun ange-ftp-dired-uncache (dir) |
4887
78c004148b7c
(ange-ftp-dired-uncache): Fix parens so that `(setq ...' is a result
Brian Fox <bfox@gnu.org>
parents:
4674
diff
changeset
|
3980 (if (ange-ftp-ftp-name (expand-file-name dir)) |
78c004148b7c
(ange-ftp-dired-uncache): Fix parens so that `(setq ...' is a result
Brian Fox <bfox@gnu.org>
parents:
4674
diff
changeset
|
3981 (setq ange-ftp-ls-cache-file nil))) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3982 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3983 (defvar ange-ftp-sans-version-alist nil |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3984 "Alist of mapping host type into function to remove file version numbers.") |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3985 |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3986 (defun ange-ftp-file-name-sans-versions (file keep-backup-version) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3987 (setq file (ange-ftp-abbreviate-filename file)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3988 (let ((parsed (ange-ftp-ftp-name file)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3989 host-type func) |
1106 | 3990 (if parsed |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3991 (setq host-type (ange-ftp-host-type (car parsed)) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
3992 func (cdr (assq (ange-ftp-host-type (car parsed)) |
1109
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3993 ange-ftp-sans-version-alist)))) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3994 (if func (funcall func file keep-backup-version) |
c9feb3e64805
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1107
diff
changeset
|
3995 (ange-ftp-real-file-name-sans-versions file keep-backup-version)))) |
1106 | 3996 |
3997 (defvar ange-ftp-remote-shell-file-name | |
3998 (if (memq system-type '(hpux usg-unix-v)) ; hope that's right | |
3999 "remsh" | |
4000 "rsh") | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4001 "Name of command to run a remote shell, for ange-ftp.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4002 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4003 ;;; This doesn't work yet; a new hook needs to be created. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4004 ;;; Maybe the new hook should be in call-process. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4005 (defun ange-ftp-shell-command (command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4006 (let* ((parsed (ange-ftp-ftp-name default-directory)) |
1106 | 4007 (host (nth 0 parsed)) |
4008 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4009 (name (nth 2 parsed))) |
1106 | 4010 (if (not parsed) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4011 (ange-ftp-real-shell-command command) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4012 (if (> (length name) 0) ; else it's $HOME |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4013 (setq command (concat "cd " name "; " command))) |
1106 | 4014 (setq command |
4015 (format "%s %s \"%s\"" ; remsh -l USER does not work well | |
4016 ; on a hp-ux machine I tried | |
4017 ange-ftp-remote-shell-file-name host command)) | |
4018 (ange-ftp-message "Remote command '%s' ..." command) | |
4019 ;; Cannot call ange-ftp-real-dired-run-shell-command here as it | |
4020 ;; would prepend "cd default-directory" --- which bombs because | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4021 ;; default-directory is in ange-ftp syntax for remote file names. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4022 (ange-ftp-real-shell-command command)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4023 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4024 ;;; Thisis not hooked up yet. |
1106 | 4025 (defun ange-ftp-dired-call-process (program discard &rest arguments) |
4026 ;; PROGRAM is always one of those below in the cond in dired.el. | |
4027 ;; The ARGUMENTS are (nearly) always files. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4028 (if (ange-ftp-ftp-name default-directory) |
1106 | 4029 ;; Can't use ange-ftp-dired-host-type here because the current |
4030 ;; buffer is *dired-check-process output* | |
4031 (condition-case oops | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4032 (cond ((equal "chmod" program) |
1106 | 4033 (ange-ftp-call-chmod arguments)) |
4034 ;; ((equal "chgrp" program)) | |
4035 ;; ((equal dired-chown-program program)) | |
4036 (t (error "Unknown remote command: %s" program))) | |
4037 (ftp-error (insert (format "%s: %s, %s\n" | |
4038 (nth 1 oops) | |
4039 (nth 2 oops) | |
4040 (nth 3 oops)))) | |
4041 (error (insert (format "%s\n" (nth 1 oops))))) | |
4042 (apply 'call-process program nil (not discard) nil arguments))) | |
4043 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4044 ;;; This currently does not work; it is never called. |
1106 | 4045 (defun ange-ftp-call-chmod (args) |
4046 (if (< (length args) 2) | |
4047 (error "ange-ftp-call-chmod: missing mode and/or filename: %s" args)) | |
4048 (let ((mode (car args))) | |
4049 (mapcar | |
4050 (function | |
4051 (lambda (file) | |
4052 (setq file (expand-file-name file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4053 (let ((parsed (ange-ftp-ftp-name file))) |
1106 | 4054 (if parsed |
4055 (let* ((host (nth 0 parsed)) | |
4056 (user (nth 1 parsed)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4057 (name (ange-ftp-quote-string (nth 2 parsed))) |
1106 | 4058 (abbr (ange-ftp-abbreviate-filename file)) |
4059 (result (ange-ftp-send-cmd host user | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4060 (list 'chmod mode name) |
1106 | 4061 (format "doing chmod %s" |
4062 abbr)))) | |
4063 (or (car result) | |
4064 (ange-ftp-error host user | |
4065 (format "chmod: %s: \"%s\"" | |
4066 file | |
4067 (cdr result))))))))) | |
4068 (cdr args))) | |
4069 (setq ange-ftp-ls-cache-file nil)) ;stop confusing dired | |
4070 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4071 ;;; This is turned off because it has nothing properly to do |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4072 ;;; with dired. It could be reasonable to adapt this to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4073 ;;; replace ange-ftp-copy-file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4074 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4075 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4076 ;;;;; Noddy support for async copy-file within dired. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4077 ;;;;; ------------------------------------------------------------ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4078 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4079 ;;(defun ange-ftp-dired-copy-file (from to ok-flag &optional cont nowait) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4080 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4081 ;; (dired-handle-overwrite to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4082 ;; (ange-ftp-copy-file-internal from to ok-flag dired-copy-preserve-time nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4083 ;; cont nowait)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4084 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4085 ;;(defun ange-ftp-dired-do-create-files (op-symbol file-creator operation arg |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4086 ;; &optional marker-char op1 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4087 ;; how-to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4088 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4089 ;; ;; we need to let ange-ftp-dired-create-files know that we indirectly |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4090 ;; ;; called it rather than somebody else. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4091 ;; (let ((ange-ftp-dired-do-create-files t)) ; tell who caller is |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4092 ;; (ange-ftp-real-dired-do-create-files op-symbol file-creator operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4093 ;; arg marker-char op1 how-to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4094 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4095 ;;(defun ange-ftp-dired-create-files (file-creator operation fn-list name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4096 ;; &optional marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4097 ;; "Documented as original." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4098 ;; (if (and (boundp 'ange-ftp-dired-do-create-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4099 ;; ;; called from ange-ftp-dired-do-create-files? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4100 ;; ange-ftp-dired-do-create-files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4101 ;; ;; any files worth copying? |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4102 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4103 ;; ;; we only support async copy-file at the mo. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4104 ;; (eq file-creator 'dired-copy-file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4105 ;; ;; it is only worth calling the alternative function for remote files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4106 ;; ;; as we tie ourself in recursive knots otherwise. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4107 ;; (or (ange-ftp-ftp-name (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4108 ;; ;; we can only call the name constructor for dired-do-create-files |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4109 ;; ;; since the one for regexps starts prompting here, there and |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4110 ;; ;; everywhere. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4111 ;; (ange-ftp-ftp-name (funcall name-constructor (car fn-list))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4112 ;; ;; use the process-filter driven routine rather than the iterative one. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4113 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4114 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4115 ;; fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4116 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4117 ;; (and (boundp 'target) target) ;dynamically bound |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4118 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4119 ;; (current-buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4120 ;; nil ;overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4121 ;; nil ;overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4122 ;; nil ;failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4123 ;; nil ;skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4124 ;; 0 ;success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4125 ;; (length fn-list) ;total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4126 ;; ) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3532
diff
changeset
|
4127 ;; ;; normal case... use the interactive routine... much cheaper. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4128 ;; (ange-ftp-real-dired-create-files file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4129 ;; name-constructor marker-char))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4130 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4131 ;;(defun ange-ftp-dcf-1 (file-creator operation fn-list name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4132 ;; target marker-char buffer overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4133 ;; overwrite-backup-query failures skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4134 ;; success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4135 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4136 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4137 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4138 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4139 ;; (if (null fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4140 ;; (ange-ftp-dcf-3 failures operation total skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4141 ;; success-count buffer) |
1106 | 4142 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4143 ;; (let* ((from (car fn-list)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4144 ;; (to (funcall name-constructor from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4145 ;; (if (equal to from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4146 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4147 ;; (setq to nil) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4148 ;; (dired-log "Cannot %s to same file: %s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4149 ;; (downcase operation) from))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4150 ;; (if (not to) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4151 ;; (ange-ftp-dcf-1 file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4152 ;; operation |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4153 ;; (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4154 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4155 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4156 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4157 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4158 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4159 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4160 ;; failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4161 ;; (cons (dired-make-relative from) skipped) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4162 ;; success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4163 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4164 ;; (let* ((overwrite (file-exists-p to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4165 ;; (overwrite-confirmed ; for dired-handle-overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4166 ;; (and overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4167 ;; (let ((help-form '(format "\ |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4168 ;;Type SPC or `y' to overwrite file `%s', |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4169 ;;DEL or `n' to skip to next, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4170 ;;ESC or `q' to not overwrite any of the remaining files, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4171 ;;`!' to overwrite all remaining files with no more questions." to))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4172 ;; (dired-query 'overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4173 ;; "Overwrite `%s'?" to)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4174 ;; ;; must determine if FROM is marked before file-creator |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4175 ;; ;; gets a chance to delete it (in case of a move). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4176 ;; (actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4177 ;; (cond ((integerp marker-char) marker-char) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4178 ;; (marker-char (dired-file-marker from)) ; slow |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4179 ;; (t nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4180 ;; (condition-case err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4181 ;; (funcall file-creator from to overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4182 ;; (list (function ange-ftp-dcf-2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4183 ;; nil ;err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4184 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4185 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4186 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4187 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4188 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4189 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4190 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4191 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4192 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4193 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4194 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4195 ;; t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4196 ;; (file-error ; FILE-CREATOR aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4197 ;; (ange-ftp-dcf-2 nil ;result |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4198 ;; nil ;line |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4199 ;; err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4200 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4201 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4202 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4203 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4204 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4205 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4206 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4207 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4208 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4209 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4210 ;; total)))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4211 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4212 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4213 ;;(defun ange-ftp-dcf-2 (result line err |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4214 ;; file-creator operation fn-list |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4215 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4216 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4217 ;; marker-char actual-marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4218 ;; buffer to from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4219 ;; overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4220 ;; overwrite-confirmed |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4221 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4222 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4223 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4224 ;; total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4225 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4226 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4227 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4228 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4229 ;; (if (or err (not result)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4230 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4231 ;; (setq failures (cons (dired-make-relative from) failures)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4232 ;; (dired-log "%s `%s' to `%s' failed:\n%s\n" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4233 ;; operation from to (or err line))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4234 ;; (if overwrite |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4235 ;; ;; If we get here, file-creator hasn't been aborted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4236 ;; ;; and the old entry (if any) has to be deleted |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4237 ;; ;; before adding the new entry. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4238 ;; (dired-remove-file to)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4239 ;; (setq success-count (1+ success-count)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4240 ;; (message "%s: %d of %d" operation success-count total) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4241 ;; (dired-add-file to actual-marker-char)) |
1106 | 4242 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4243 ;; (ange-ftp-dcf-1 file-creator operation (cdr fn-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4244 ;; name-constructor |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4245 ;; target |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4246 ;; marker-char |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4247 ;; buffer |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4248 ;; overwrite-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4249 ;; overwrite-backup-query |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4250 ;; failures skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4251 ;; total)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4252 ;; (set-buffer old-buf)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4253 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4254 ;;(defun ange-ftp-dcf-3 (failures operation total skipped success-count |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4255 ;; buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4256 ;; (let ((old-buf (current-buffer))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4257 ;; (unwind-protect |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4258 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4259 ;; (set-buffer buffer) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4260 ;; (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4261 ;; (failures |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4262 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4263 ;; (message "%s failed for %d of %d file%s %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4264 ;; operation (length failures) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4265 ;; (dired-plural-s total) failures))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4266 ;; (skipped |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4267 ;; (dired-log-summary |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4268 ;; (message "%s: %d of %d file%s skipped %s" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4269 ;; operation (length skipped) total |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4270 ;; (dired-plural-s total) skipped))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4271 ;; (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4272 ;; (message "%s: %s file%s." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4273 ;; operation success-count (dired-plural-s success-count)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4274 ;; (dired-move-to-filename)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4275 ;; (set-buffer old-buf)))) |
1106 | 4276 |
4277 ;;;; ----------------------------------------------- | |
4278 ;;;; Unix Descriptive Listing (dl) Support | |
4279 ;;;; ----------------------------------------------- | |
4280 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4281 ;; This is turned off because nothing uses it currently |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4282 ;; and because I don't understand what it's supposed to be for. --rms. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4283 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4284 ;;(defconst ange-ftp-dired-dl-re-dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4285 ;; "^. [^ /]+/[ \n]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4286 ;; "Regular expression to use to search for dl directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4287 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4288 ;;(or (assq 'unix:dl ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4289 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4290 ;; (cons (cons 'unix:dl ange-ftp-dired-dl-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4291 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4292 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4293 ;;(defun ange-ftp-dired-dl-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4294 ;; "In dired, move to the first character of the filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4295 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4296 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4297 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4298 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4299 ;; (if (looking-at ". [^ ]+ +\\([0-9]+\\|-\\|=\\) ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4300 ;; (goto-char (+ (point) 2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4301 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4302 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4303 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4304 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4305 ;;(or (assq 'unix:dl ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4306 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4307 ;; (cons '(unix:dl . ange-ftp-dired-dl-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4308 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4309 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4310 ;;(defun ange-ftp-dired-dl-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4311 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4312 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4313 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4314 ;; ;; This is the Unix dl version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4315 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4316 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4317 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4318 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4319 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4320 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4321 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4322 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4323 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4324 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4325 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4326 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4327 ;; (skip-chars-forward "^ /" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4328 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4329 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4330 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4331 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4332 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4333 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4334 ;;(or (assq 'unix:dl ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4335 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4336 ;; (cons '(unix:dl . ange-ftp-dired-dl-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4337 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 4338 |
4339 ;;;; ------------------------------------------------------------ | |
4340 ;;;; VOS support (VOS support is probably broken, | |
4341 ;;;; but I don't know anything about VOS.) | |
4342 ;;;; ------------------------------------------------------------ | |
4343 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4344 ;(defun ange-ftp-fix-name-for-vos (name &optional reverse) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4345 ; (setq name (copy-sequence name)) |
1106 | 4346 ; (let ((from (if reverse ?\> ?\/)) |
4347 ; (to (if reverse ?\/ ?\>)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4348 ; (i (1- (length name)))) |
1106 | 4349 ; (while (>= i 0) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4350 ; (if (= (aref name i) from) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4351 ; (aset name i to)) |
1106 | 4352 ; (setq i (1- i))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4353 ; name)) |
1106 | 4354 ; |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4355 ;(or (assq 'vos ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4356 ; (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4357 ; (cons '(vos . ange-ftp-fix-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4358 ; ange-ftp-fix-name-func-alist))) |
1106 | 4359 ; |
4360 ;(or (memq 'vos ange-ftp-dumb-host-types) | |
4361 ; (setq ange-ftp-dumb-host-types | |
4362 ; (cons 'vos ange-ftp-dumb-host-types))) | |
4363 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4364 ;(defun ange-ftp-fix-dir-name-for-vos (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4365 ; (ange-ftp-fix-name-for-vos |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4366 ; (concat dir-name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4367 ; (if (eq ?/ (aref dir-name (1- (length dir-name)))) |
1106 | 4368 ; "" "/") |
4369 ; "*"))) | |
4370 ; | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4371 ;(or (assq 'vos ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4372 ; (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4373 ; (cons '(vos . ange-ftp-fix-dir-name-for-vos) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4374 ; ange-ftp-fix-dir-name-func-alist))) |
1106 | 4375 ; |
4376 ;(defvar ange-ftp-vos-host-regexp nil | |
4377 ; "If a host matches this regexp then it is assumed to be running VOS.") | |
4378 ; | |
4379 ;(defun ange-ftp-vos-host (host) | |
4380 ; (and ange-ftp-vos-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4381 ; (save-match-data |
1106 | 4382 ; (string-match ange-ftp-vos-host-regexp host)))) |
4383 ; | |
4384 ;(defun ange-ftp-parse-vos-listing () | |
4385 ; "Parse the current buffer which is assumed to be in VOS list -all | |
4386 ;format, and return a hashtable as the result." | |
4387 ; (let ((tbl (ange-ftp-make-hashtable)) | |
4388 ; (type-list | |
4389 ; '(("^Files: [0-9]+ +Blocks: [0-9]+\n+" nil 40) | |
4390 ; ("^Dirs: [0-9]+\n+" t 30))) | |
4391 ; type-regexp type-is-dir type-col file) | |
4392 ; (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4393 ; (save-match-data |
1106 | 4394 ; (while type-list |
4395 ; (setq type-regexp (car (car type-list)) | |
4396 ; type-is-dir (nth 1 (car type-list)) | |
4397 ; type-col (nth 2 (car type-list)) | |
4398 ; type-list (cdr type-list)) | |
4399 ; (if (re-search-forward type-regexp nil t) | |
4400 ; (while (eq (char-after (point)) ? ) | |
4401 ; (move-to-column type-col) | |
4402 ; (setq file (buffer-substring (point) | |
4403 ; (progn | |
4404 ; (end-of-line 1) | |
4405 ; (point)))) | |
4406 ; (ange-ftp-put-hash-entry file type-is-dir tbl) | |
4407 ; (forward-line 1)))) | |
4408 ; (ange-ftp-put-hash-entry "." 'vosdir tbl) | |
4409 ; (ange-ftp-put-hash-entry ".." 'vosdir tbl)) | |
4410 ; tbl)) | |
4411 ; | |
4412 ;(or (assq 'vos ange-ftp-parse-list-func-alist) | |
4413 ; (setq ange-ftp-parse-list-func-alist | |
4414 ; (cons '(vos . ange-ftp-parse-vos-listing) | |
4415 ; ange-ftp-parse-list-func-alist))) | |
4416 | |
4417 ;;;; ------------------------------------------------------------ | |
4418 ;;;; VMS support. | |
4419 ;;;; ------------------------------------------------------------ | |
4420 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4421 ;; Convert NAME from UNIX-ish to VMS. If REVERSE given then convert from VMS |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4422 ;; to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4423 (defun ange-ftp-fix-name-for-vms (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4424 (save-match-data |
1106 | 4425 (if reverse |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4426 (if (string-match "^\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)$" name) |
1106 | 4427 (let (drive dir file) |
4428 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4429 (setq drive (substring name |
1106 | 4430 (match-beginning 1) |
4431 (match-end 1)))) | |
4432 (if (match-beginning 2) | |
4433 (setq dir | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4434 (substring name (match-beginning 2) (match-end 2)))) |
1106 | 4435 (if (match-beginning 3) |
4436 (setq file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4437 (substring name (match-beginning 3) (match-end 3)))) |
1106 | 4438 (and dir |
4439 (setq dir (apply (function concat) | |
4440 (mapcar (function | |
4441 (lambda (char) | |
4442 (if (= char ?.) | |
4443 (vector ?/) | |
4444 (vector char)))) | |
4445 (substring dir 1 -1))))) | |
4446 (concat (and drive | |
4447 (concat "/" drive "/")) | |
4448 dir (and dir "/") | |
4449 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4450 (error "name %s didn't match" name)) |
1106 | 4451 (let (drive dir file tmp) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4452 (if (string-match "^/[^:]+:/" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4453 (setq drive (substring name 1 |
1106 | 4454 (1- (match-end 0))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4455 name (substring name (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4456 (setq tmp (file-name-directory name)) |
1106 | 4457 (if tmp |
4458 (setq dir (apply (function concat) | |
4459 (mapcar (function | |
4460 (lambda (char) | |
4461 (if (= char ?/) | |
4462 (vector ?.) | |
4463 (vector char)))) | |
4464 (substring tmp 0 -1))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4465 (setq file (file-name-nondirectory name)) |
1106 | 4466 (concat drive |
4467 (and dir (concat "[" (if drive nil ".") dir "]")) | |
4468 file))))) | |
4469 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4470 ;; (ange-ftp-fix-name-for-vms "/PUB$:/ANONYMOUS/SDSCPUB/NEXT/Readme.txt;1") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4471 ;; (ange-ftp-fix-name-for-vms "/PUB$:[ANONYMOUS.SDSCPUB.NEXT]Readme.txt;1" t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4472 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4473 (or (assq 'vms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4474 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4475 (cons '(vms . ange-ftp-fix-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4476 ange-ftp-fix-name-func-alist))) |
1106 | 4477 |
4478 (or (memq 'vms ange-ftp-dumb-host-types) | |
4479 (setq ange-ftp-dumb-host-types | |
4480 (cons 'vms ange-ftp-dumb-host-types))) | |
4481 | |
4482 ;; It is important that this function barf for directories for which we know | |
4483 ;; that we cannot possibly get a directory listing, such as "/" and "/DEV:/". | |
4484 ;; This is because it saves an unnecessary FTP error, or possibly the listing | |
4485 ;; might succeed, but give erroneous info. This last case is particularly | |
4486 ;; likely for OS's (like MTS) for which we need to use a wildcard in order | |
4487 ;; to list a directory. | |
4488 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4489 ;; Convert name from UNIX-ish to VMS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4490 (defun ange-ftp-fix-dir-name-for-vms (dir-name) |
1106 | 4491 ;; Should there be entries for .. -> [-] and . -> [] below. Don't |
4492 ;; think so, because expand-filename should have already short-circuited | |
4493 ;; them. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4494 (cond ((string-equal dir-name "/") |
1106 | 4495 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4496 ((string-match "^/[-A-Z0-9_$]+:/$" dir-name) |
1106 | 4497 (error "Cannot get listing for device.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4498 ((ange-ftp-fix-name-for-vms dir-name)))) |
1106 | 4499 |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4500 (or (assq 'vms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4501 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4502 (cons '(vms . ange-ftp-fix-dir-name-for-vms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4503 ange-ftp-fix-dir-name-func-alist))) |
1106 | 4504 |
4505 (defvar ange-ftp-vms-host-regexp nil) | |
4506 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4507 ;; Return non-nil if HOST is running VMS. |
1106 | 4508 (defun ange-ftp-vms-host (host) |
4509 (and ange-ftp-vms-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4510 (save-match-data |
1106 | 4511 (string-match ange-ftp-vms-host-regexp host)))) |
4512 | |
4513 ;; Because some VMS ftp servers convert filenames to lower case | |
4514 ;; we allow a-z in the filename regexp. I'm not too happy about this. | |
4515 | |
4516 (defconst ange-ftp-vms-filename-regexp | |
4517 (concat | |
6309
9217f29851c2
Don't use triple-hyphen in a character class.
Karl Heuer <kwzh@gnu.org>
parents:
6192
diff
changeset
|
4518 "\\(\\([_A-Za-z0-9$]?\\|[_A-Za-z0-9$][-_A-Za-z0-9$]*\\)\\." |
9217f29851c2
Don't use triple-hyphen in a character class.
Karl Heuer <kwzh@gnu.org>
parents:
6192
diff
changeset
|
4519 "[-_A-Za-z0-9$]*;+[0-9]*\\)") |
1106 | 4520 "Regular expression to match for a valid VMS file name in Dired buffer. |
4521 Stupid freaking bug! Position of _ and $ shouldn't matter but they do. | |
4522 Having [A-Z0-9$_] bombs on filename _$$CHANGE_LOG$.TXT$ and $CHANGE_LOG$.TX | |
4523 Other orders of $ and _ seem to all work just fine.") | |
4524 | |
4525 ;; These parsing functions are as general as possible because the syntax | |
4526 ;; of ftp listings from VMS hosts is a bit erratic. What saves us is that | |
4527 ;; the VMS filename syntax is so rigid. If they bomb on a listing in the | |
4528 ;; standard VMS Multinet format, then this is a bug. If they bomb on a listing | |
4529 ;; from vms.weird.net, then too bad. | |
4530 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4531 ;; Extract the next filename from a VMS dired-like listing. |
1106 | 4532 (defun ange-ftp-parse-vms-filename () |
4533 (if (re-search-forward | |
4534 ange-ftp-vms-filename-regexp | |
4535 nil t) | |
4536 (buffer-substring (match-beginning 0) (match-end 0)))) | |
4537 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4538 ;; Parse the current buffer which is assumed to be in MultiNet FTP dir |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4539 ;; format, and return a hashtable as the result. |
1106 | 4540 (defun ange-ftp-parse-vms-listing () |
4541 (let ((tbl (ange-ftp-make-hashtable)) | |
4542 file) | |
4543 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4544 (save-match-data |
1106 | 4545 (while (setq file (ange-ftp-parse-vms-filename)) |
4546 (if (string-match "\\.\\(DIR\\|dir\\);[0-9]+" file) | |
4547 ;; deal with directories | |
4548 (ange-ftp-put-hash-entry | |
4549 (substring file 0 (match-beginning 0)) t tbl) | |
4550 (ange-ftp-put-hash-entry file nil tbl) | |
4551 (if (string-match ";[0-9]+$" file) ; deal with extension | |
4552 ;; sans extension | |
4553 (ange-ftp-put-hash-entry | |
4554 (substring file 0 (match-beginning 0)) nil tbl))) | |
4555 (forward-line 1)) | |
4556 ;; Would like to look for a "Total" line, or a "Directory" line to | |
4557 ;; make sure that the listing isn't complete garbage before putting | |
4558 ;; in "." and "..", but we can't even count on all VAX's giving us | |
4559 ;; either of these. | |
4560 (ange-ftp-put-hash-entry "." t tbl) | |
4561 (ange-ftp-put-hash-entry ".." t tbl)) | |
4562 tbl)) | |
4563 | |
4564 (or (assq 'vms ange-ftp-parse-list-func-alist) | |
4565 (setq ange-ftp-parse-list-func-alist | |
4566 (cons '(vms . ange-ftp-parse-vms-listing) | |
4567 ange-ftp-parse-list-func-alist))) | |
4568 | |
4569 ;; This version only deletes file entries which have | |
4570 ;; explicit version numbers, because that is all VMS allows. | |
4571 | |
4572 ;; Can the following two functions be speeded up using file | |
4573 ;; completion functions? | |
4574 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4575 (defun ange-ftp-vms-delete-file-entry (name &optional dir-p) |
1106 | 4576 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4577 (ange-ftp-internal-delete-file-entry name t) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4578 (save-match-data |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4579 (let ((file (ange-ftp-get-file-part name))) |
1106 | 4580 (if (string-match ";[0-9]+$" file) |
4581 ;; In VMS you can't delete a file without an explicit | |
4582 ;; version number, or wild-card (e.g. FOO;*) | |
4583 ;; For now, we give up on wildcards. | |
4584 (let ((files (ange-ftp-get-hash-entry | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4585 (file-name-directory name) |
1106 | 4586 ange-ftp-files-hashtable))) |
4587 (if files | |
4588 (let* ((root (substring file 0 | |
4589 (match-beginning 0))) | |
4590 (regexp (concat "^" | |
4591 (regexp-quote root) | |
4592 ";[0-9]+$")) | |
4593 versions) | |
4594 (ange-ftp-del-hash-entry file files) | |
4595 ;; Now we need to check if there are any | |
4596 ;; versions left. If not, then delete the | |
4597 ;; root entry. | |
4598 (mapatoms | |
4599 '(lambda (sym) | |
4600 (and (string-match regexp (get sym 'key)) | |
4601 (setq versions t))) | |
4602 files) | |
4603 (or versions | |
4604 (ange-ftp-del-hash-entry root files)))))))))) | |
4605 | |
4606 (or (assq 'vms ange-ftp-delete-file-entry-alist) | |
4607 (setq ange-ftp-delete-file-entry-alist | |
4608 (cons '(vms . ange-ftp-vms-delete-file-entry) | |
4609 ange-ftp-delete-file-entry-alist))) | |
4610 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4611 (defun ange-ftp-vms-add-file-entry (name &optional dir-p) |
1106 | 4612 (if dir-p |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4613 (ange-ftp-internal-add-file-entry name t) |
1106 | 4614 (let ((files (ange-ftp-get-hash-entry |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4615 (file-name-directory name) |
1106 | 4616 ange-ftp-files-hashtable))) |
4617 (if files | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4618 (let ((file (ange-ftp-get-file-part name))) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4619 (save-match-data |
1106 | 4620 (if (string-match ";[0-9]+$" file) |
4621 (ange-ftp-put-hash-entry | |
4622 (substring file 0 (match-beginning 0)) | |
4623 nil files) | |
4624 ;; Need to figure out what version of the file | |
4625 ;; is being added. | |
4626 (let ((regexp (concat "^" | |
4627 (regexp-quote file) | |
4628 ";\\([0-9]+\\)$")) | |
4629 (version 0)) | |
4630 (mapatoms | |
4631 '(lambda (sym) | |
4632 (let ((name (get sym 'key))) | |
4633 (and (string-match regexp name) | |
4634 (setq version | |
4635 (max version | |
4636 (string-to-int | |
4637 (substring name | |
4638 (match-beginning 1) | |
4639 (match-end 1)))))))) | |
4640 files) | |
4641 (setq version (1+ version)) | |
4642 (ange-ftp-put-hash-entry | |
4643 (concat file ";" (int-to-string version)) | |
4644 nil files)))) | |
4645 (ange-ftp-put-hash-entry file nil files)))))) | |
4646 | |
4647 (or (assq 'vms ange-ftp-add-file-entry-alist) | |
4648 (setq ange-ftp-add-file-entry-alist | |
4649 (cons '(vms . ange-ftp-vms-add-file-entry) | |
4650 ange-ftp-add-file-entry-alist))) | |
4651 | |
4652 | |
4653 (defun ange-ftp-add-vms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4654 "Mark HOST as the name of a machine running VMS." |
1106 | 4655 (interactive |
4656 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
4657 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4658 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 4659 (if (not (ange-ftp-vms-host host)) |
4660 (setq ange-ftp-vms-host-regexp | |
4661 (concat "^" (regexp-quote host) "$" | |
4662 (and ange-ftp-vms-host-regexp "\\|") | |
4663 ange-ftp-vms-host-regexp) | |
4664 ange-ftp-host-cache nil))) | |
4665 | |
4666 | |
4667 (defun ange-ftp-vms-file-name-as-directory (name) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4668 (save-match-data |
1106 | 4669 (if (string-match "\\.\\(DIR\\|dir\\)\\(;[0-9]+\\)?$" name) |
4670 (setq name (substring name 0 (match-beginning 0)))) | |
4671 (ange-ftp-real-file-name-as-directory name))) | |
4672 | |
4673 (or (assq 'vms ange-ftp-file-name-as-directory-alist) | |
4674 (setq ange-ftp-file-name-as-directory-alist | |
4675 (cons '(vms . ange-ftp-vms-file-name-as-directory) | |
4676 ange-ftp-file-name-as-directory-alist))) | |
4677 | |
4678 ;;; Tree dired support: | |
4679 | |
4680 ;; For this code I have borrowed liberally from Sebastian Kremer's | |
4681 ;; dired-vms.el | |
4682 | |
4683 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4684 ;;;; These regexps must be anchored to beginning of line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4685 ;;;; Beware that the ftpd may put the device in front of the filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4686 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4687 ;;(defconst ange-ftp-dired-vms-re-exe "^. [^ \t.]+\\.\\(EXE\\|exe\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4688 ;; "Regular expression to use to search for VMS executable files.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4689 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4690 ;;(defconst ange-ftp-dired-vms-re-dir "^. [^ \t.]+\\.\\(DIR\\|dir\\)[; ]" |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4691 ;; "Regular expression to use to search for VMS directories.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4692 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4693 ;;(or (assq 'vms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4694 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4695 ;; (cons (cons 'vms ange-ftp-dired-vms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4696 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4697 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4698 ;;(or (assq 'vms ange-ftp-dired-re-dir-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4699 ;; (setq ange-ftp-dired-re-dir-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4700 ;; (cons (cons 'vms ange-ftp-dired-vms-re-dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4701 ;; ange-ftp-dired-re-dir-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4702 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4703 ;;(defun ange-ftp-dired-vms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4704 ;; ;; VMS inserts a headerline. I would prefer the headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4705 ;; ;; to be in ange-ftp format. This version tries to |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4706 ;; ;; be careful, because we can't count on a headerline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4707 ;; ;; over ftp, and we wouldn't want to delete anything |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4708 ;; ;; important. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4709 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4710 ;; (if (looking-at "^ wildcard ") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4711 ;; (forward-line 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4712 ;; (if (looking-at "^[ \n\t]*[^\n]+\\][ \t]*\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4713 ;; (delete-region (point) (match-end 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4714 ;; (ange-ftp-real-dired-insert-headerline dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4715 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4716 ;;(or (assq 'vms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4717 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4718 ;; (cons '(vms . ange-ftp-dired-vms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4719 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4720 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4721 ;;(defun ange-ftp-dired-vms-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4722 ;; "In dired, move to first char of filename on this line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4723 ;;Returns position (point) or nil if no filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4724 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4725 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4726 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4727 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4728 ;; (if (re-search-forward ange-ftp-vms-filename-regexp eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4729 ;; (goto-char (match-beginning 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4730 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4731 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4732 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4733 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4734 ;;(or (assq 'vms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4735 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4736 ;; (cons '(vms . ange-ftp-dired-vms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4737 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4738 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4739 ;;(defun ange-ftp-dired-vms-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4740 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4741 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4742 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4743 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4744 ;; ;; This is the VMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4745 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4746 ;; (setq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4747 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4748 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4749 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4750 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4751 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4752 ;; (re-search-forward ange-ftp-vms-filename-regexp eol t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4753 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4754 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4755 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4756 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4757 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4758 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4759 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4760 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4761 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4762 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4763 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4764 ;;(or (assq 'vms ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4765 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4766 ;; (cons '(vms . ange-ftp-dired-vms-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4767 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4768 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4769 ;;(defun ange-ftp-dired-vms-between-files () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4770 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4771 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4772 ;; (or (equal (following-char) 10) ; newline |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4773 ;; (equal (following-char) 9) ; tab |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4774 ;; (progn (forward-char 2) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4775 ;; (or (looking-at "Total of") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4776 ;; (equal (following-char) 32)))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4777 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4778 ;;(or (assq 'vms ange-ftp-dired-between-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4779 ;; (setq ange-ftp-dired-between-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4780 ;; (cons '(vms . ange-ftp-dired-vms-between-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4781 ;; ange-ftp-dired-between-files-alist))) |
1106 | 4782 |
4783 ;; Beware! In VMS filenames must be of the form "FILE.TYPE". | |
4784 ;; Therefore, we cannot just append a ".Z" to filenames for | |
4785 ;; compressed files. Instead, we turn "FILE.TYPE" into | |
4786 ;; "FILE.TYPE-Z". Hope that this is a reasonable thing to do. | |
4787 | |
4788 (defun ange-ftp-vms-make-compressed-filename (name &optional reverse) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4789 (cond |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4790 ((string-match "-Z;[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4791 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4792 ((string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4793 (list nil (substring name 0 (match-beginning 0)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4794 ((string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4795 (list nil (substring name 0 -2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4796 (t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4797 (list t |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4798 (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4799 (concat (substring name 0 (match-beginning 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4800 "-Z") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4801 (concat name "-Z")))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4802 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4803 (or (assq 'vms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4804 (setq ange-ftp-make-compressed-filename-alist |
1106 | 4805 (cons '(vms . ange-ftp-vms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4806 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4807 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4808 ;;;; When the filename is too long, VMS will use two lines to list a file |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4809 ;;;; (damn them!) This will confuse dired. To solve this, need to convince |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4810 ;;;; Sebastian to use a function dired-go-to-end-of-file-line, instead of |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4811 ;;;; (forward-line 1). This would require a number of changes to dired.el. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4812 ;;;; If dired gets confused, revert-buffer will fix it. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4813 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4814 ;;(defun ange-ftp-dired-vms-ls-trim () |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4815 ;; (goto-char (point-min)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4816 ;; (let ((case-fold-search nil)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4817 ;; (re-search-forward ange-ftp-vms-filename-regexp)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4818 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4819 ;; (delete-region (point-min) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4820 ;; (forward-line 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4821 ;; (delete-region (point) (point-max))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4822 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4823 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4824 ;;(or (assq 'vms ange-ftp-dired-ls-trim-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4825 ;; (setq ange-ftp-dired-ls-trim-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4826 ;; (cons '(vms . ange-ftp-dired-vms-ls-trim) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4827 ;; ange-ftp-dired-ls-trim-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4828 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4829 (defun ange-ftp-vms-sans-version (name) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4830 (save-match-data |
1106 | 4831 (if (string-match ";[0-9]+$" name) |
4832 (substring name 0 (match-beginning 0)) | |
4833 name))) | |
4834 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4835 (or (assq 'vms ange-ftp-sans-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4836 (setq ange-ftp-sans-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4837 (cons '(vms . ange-ftp-vms-sans-version) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4838 ange-ftp-sans-version-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4839 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4840 ;;(defvar ange-ftp-file-version-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4841 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4842 ;;;;; The vms version of clean-directory has 2 more optional args |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4843 ;;;;; than the usual dired version. This is so that it can be used by |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4844 ;;;;; ange-ftp-dired-vms-flag-backup-files. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4845 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4846 ;;(defun ange-ftp-dired-vms-clean-directory (keep &optional marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4847 ;; "Flag numerical backups for deletion. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4848 ;;Spares `dired-kept-versions' latest versions, and `kept-old-versions' oldest. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4849 ;;Positive prefix arg KEEP overrides `dired-kept-versions'; |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4850 ;;Negative prefix arg KEEP overrides `kept-old-versions' with KEEP made positive. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4851 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4852 ;;To clear the flags on these files, you can use \\[dired-flag-backup-files] |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4853 ;;with a prefix argument." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4854 ;;; (interactive "P") ; Never actually called interactively. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4855 ;; (setq keep (max 1 (if keep (prefix-numeric-value keep) dired-kept-versions))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4856 ;; (let ((early-retention (if (< keep 0) (- keep) kept-old-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4857 ;; ;; late-retention must NEVER be allowed to be less than 1 in VMS! |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4858 ;; ;; This could wipe ALL copies of the file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4859 ;; (late-retention (max 1 (if (<= keep 0) dired-kept-versions keep))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4860 ;; (action (or msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4861 ;; (ange-ftp-trample-marker (or marker dired-del-marker)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4862 ;; (ange-ftp-file-version-alist ())) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4863 ;; (message (concat action |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4864 ;; " numerical backups (keeping %d late, %d old)...") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4865 ;; late-retention early-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4866 ;; ;; Look at each file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4867 ;; ;; If the file has numeric backup versions, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4868 ;; ;; put on ange-ftp-file-version-alist an element of the form |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4869 ;; ;; (FILENAME . VERSION-NUMBER-LIST) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4870 ;; (dired-map-dired-file-lines (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4871 ;; ange-ftp-dired-vms-collect-file-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4872 ;; ;; Sort each VERSION-NUMBER-LIST, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4873 ;; ;; and remove the versions not to be deleted. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4874 ;; (let ((fval ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4875 ;; (while fval |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4876 ;; (let* ((sorted-v-list (cons 'q (sort (cdr (car fval)) '<))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4877 ;; (v-count (length sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4878 ;; (if (> v-count (+ early-retention late-retention)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4879 ;; (rplacd (nthcdr early-retention sorted-v-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4880 ;; (nthcdr (- v-count late-retention) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4881 ;; sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4882 ;; (rplacd (car fval) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4883 ;; (cdr sorted-v-list))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4884 ;; (setq fval (cdr fval)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4885 ;; ;; Look at each file. If it is a numeric backup file, |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4886 ;; ;; find it in a VERSION-NUMBER-LIST and maybe flag it for deletion. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4887 ;; (dired-map-dired-file-lines |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4888 ;; (function |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4889 ;; ange-ftp-dired-vms-trample-file-versions mark)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4890 ;; (message (concat action " numerical backups...done")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4891 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4892 ;;(or (assq 'vms ange-ftp-dired-clean-directory-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4893 ;; (setq ange-ftp-dired-clean-directory-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4894 ;; (cons '(vms . ange-ftp-dired-vms-clean-directory) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4895 ;; ange-ftp-dired-clean-directory-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4896 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4897 ;;(defun ange-ftp-dired-vms-collect-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4898 ;; ;; "If it looks like file FN has versions, return a list of the versions. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4899 ;; ;;That is a list of strings which are file names. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4900 ;; ;;The caller may want to flag some of these files for deletion." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4901 ;;(let ((name (nth 2 (ange-ftp-ftp-name fn)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4902 ;; (if (string-match ";[0-9]+$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4903 ;; (let* ((name (substring name 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4904 ;; (fn (ange-ftp-replace-name-component fn name))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4905 ;; (if (not (assq fn ange-ftp-file-version-alist)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4906 ;; (let* ((base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4907 ;; (concat (file-name-nondirectory name) ";")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4908 ;; (bv-length (length base-versions)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4909 ;; (possibilities (file-name-all-completions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4910 ;; base-versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4911 ;; (file-name-directory fn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4912 ;; (versions (mapcar |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4913 ;; '(lambda (arg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4914 ;; (if (and (string-match |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4915 ;; "[0-9]+$" arg bv-length) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4916 ;; (= (match-beginning 0) bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4917 ;; (string-to-int (substring arg bv-length)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4918 ;; 0)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4919 ;; possibilities))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4920 ;; (if versions |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4921 ;; (setq |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4922 ;; ange-ftp-file-version-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4923 ;; (cons (cons fn versions) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4924 ;; ange-ftp-file-version-alist))))))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4925 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4926 ;;(defun ange-ftp-dired-vms-trample-file-versions (fn) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4927 ;; (let* ((start-vn (string-match ";[0-9]+$" fn)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4928 ;; base-version-list) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4929 ;; (and start-vn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4930 ;; (setq base-version-list ; there was a base version to which |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4931 ;; (assoc (substring fn 0 start-vn) ; this looks like a |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4932 ;; ange-ftp-file-version-alist)) ; subversion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4933 ;; (not (memq (string-to-int (substring fn (1+ start-vn))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4934 ;; base-version-list)) ; this one doesn't make the cut |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4935 ;; (progn (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4936 ;; (delete-char 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4937 ;; (insert ange-ftp-trample-marker))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4938 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4939 ;;(defun ange-ftp-dired-vms-flag-backup-files (&optional unflag-p) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4940 ;; (let ((dired-kept-versions 1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4941 ;; (kept-old-versions 0) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4942 ;; marker msg) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4943 ;; (if unflag-p |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4944 ;; (setq marker ?\040 msg "Unflagging") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4945 ;; (setq marker dired-del-marker msg "Cleaning")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4946 ;; (ange-ftp-dired-vms-clean-directory nil marker msg))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4947 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4948 ;;(or (assq 'vms ange-ftp-dired-flag-backup-files-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4949 ;; (setq ange-ftp-dired-flag-backup-files-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4950 ;; (cons '(vms . ange-ftp-dired-vms-flag-backup-files) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4951 ;; ange-ftp-dired-flag-backup-files-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4952 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4953 ;;(defun ange-ftp-dired-vms-backup-diff (&optional switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4954 ;; (let ((file (dired-get-filename 'no-dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4955 ;; bak) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4956 ;; (if (and (string-match ";[0-9]+$" file) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4957 ;; ;; Find most recent previous version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4958 ;; (let ((root (substring file 0 (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4959 ;; (ver |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4960 ;; (string-to-int (substring file (1+ (match-beginning 0))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4961 ;; found) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4962 ;; (setq ver (1- ver)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4963 ;; (while (and (> ver 0) (not found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4964 ;; (setq bak (concat root ";" (int-to-string ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4965 ;; (and (file-exists-p bak) (setq found t)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4966 ;; (setq ver (1- ver))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4967 ;; found)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4968 ;; (if switches |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4969 ;; (diff (expand-file-name bak) (expand-file-name file) switches) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4970 ;; (diff (expand-file-name bak) (expand-file-name file))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4971 ;; (error "No previous version found for %s" file)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4972 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4973 ;;(or (assq 'vms ange-ftp-dired-backup-diff-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4974 ;; (setq ange-ftp-dired-backup-diff-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4975 ;; (cons '(vms . ange-ftp-dired-vms-backup-diff) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4976 ;; ange-ftp-dired-backup-diff-alist))) |
1106 | 4977 |
4978 | |
4979 ;;;; ------------------------------------------------------------ | |
4980 ;;;; MTS support | |
4981 ;;;; ------------------------------------------------------------ | |
4982 | |
4983 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4984 ;; Convert NAME from UNIX-ish to MTS. If REVERSE given then convert from |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4985 ;; MTS to UNIX-ish. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4986 (defun ange-ftp-fix-name-for-mts (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
4987 (save-match-data |
1106 | 4988 (if reverse |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4989 (if (string-match "^\\([^:]+:\\)?\\(.*\\)$" name) |
1106 | 4990 (let (acct file) |
4991 (if (match-beginning 1) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4992 (setq acct (substring name 0 (match-end 1)))) |
1106 | 4993 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4994 (setq file (substring name |
1106 | 4995 (match-beginning 2) (match-end 2)))) |
4996 (concat (and acct (concat "/" acct "/")) | |
4997 file)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4998 (error "name %s didn't match" name)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
4999 (if (string-match "^/\\([^:]+:\\)/\\(.*\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5000 (concat (substring name 1 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5001 (substring name (match-beginning 2) (match-end 2))) |
1106 | 5002 ;; Let's hope that mts will recognize it anyway. |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5003 name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5004 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5005 (or (assq 'mts ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5006 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5007 (cons '(mts . ange-ftp-fix-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5008 ange-ftp-fix-name-func-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5009 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5010 ;; Convert name from UNIX-ish to MTS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5011 ;; Remember that there are no directories in MTS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5012 (defun ange-ftp-fix-dir-name-for-mts (dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5013 (if (string-equal dir-name "/") |
1106 | 5014 (error "Cannot get listing for fictitious \"/\" directory.") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5015 (let ((dir-name (ange-ftp-fix-name-for-mts dir-name))) |
1106 | 5016 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5017 ((string-equal dir-name "") |
1106 | 5018 "?") |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5019 ((string-match ":$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5020 (concat dir-name "?")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5021 (dir-name))))) ; It's just a single file. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5022 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5023 (or (assq 'mts ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5024 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5025 (cons '(mts . ange-ftp-fix-dir-name-for-mts) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5026 ange-ftp-fix-dir-name-func-alist))) |
1106 | 5027 |
5028 (or (memq 'mts ange-ftp-dumb-host-types) | |
5029 (setq ange-ftp-dumb-host-types | |
5030 (cons 'mts ange-ftp-dumb-host-types))) | |
5031 | |
5032 (defvar ange-ftp-mts-host-regexp nil) | |
5033 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5034 ;; Return non-nil if HOST is running MTS. |
1106 | 5035 (defun ange-ftp-mts-host (host) |
5036 (and ange-ftp-mts-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5037 (save-match-data |
1106 | 5038 (string-match ange-ftp-mts-host-regexp host)))) |
5039 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5040 ;; Parse the current buffer which is assumed to be in mts ftp dir format. |
1106 | 5041 (defun ange-ftp-parse-mts-listing () |
5042 (let ((tbl (ange-ftp-make-hashtable))) | |
5043 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5044 (save-match-data |
1106 | 5045 (while (re-search-forward ange-ftp-date-regexp nil t) |
5046 (end-of-line) | |
5047 (skip-chars-backward " ") | |
5048 (let ((end (point))) | |
5049 (skip-chars-backward "-A-Z0-9_.!") | |
5050 (ange-ftp-put-hash-entry (buffer-substring (point) end) nil tbl)) | |
5051 (forward-line 1))) | |
5052 ;; Don't need to bother with .. | |
5053 (ange-ftp-put-hash-entry "." t tbl) | |
5054 tbl)) | |
5055 | |
5056 (or (assq 'mts ange-ftp-parse-list-func-alist) | |
5057 (setq ange-ftp-parse-list-func-alist | |
5058 (cons '(mts . ange-ftp-parse-mts-listing) | |
5059 ange-ftp-parse-list-func-alist))) | |
5060 | |
5061 (defun ange-ftp-add-mts-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5062 "Mark HOST as the name of a machine running MTS." |
1106 | 5063 (interactive |
5064 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
5065 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5066 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 5067 (if (not (ange-ftp-mts-host host)) |
5068 (setq ange-ftp-mts-host-regexp | |
5069 (concat "^" (regexp-quote host) "$" | |
5070 (and ange-ftp-mts-host-regexp "\\|") | |
5071 ange-ftp-mts-host-regexp) | |
5072 ange-ftp-host-cache nil))) | |
5073 | |
5074 ;;; Tree dired support: | |
5075 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5076 ;;;; There aren't too many systems left that use MTS. This dired support will |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5077 ;;;; work for the implementation of ftp on mtsg.ubc.ca. I hope other mts systems |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5078 ;;;; implement ftp in the same way. If not, it might be necessary to make the |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5079 ;;;; following more flexible. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5080 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5081 ;;(defun ange-ftp-dired-mts-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5082 ;; "In dired, move to first char of filename on this line. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5083 ;;Returns position (point) or nil if no filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5084 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5085 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5086 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5087 ;; (if (re-search-forward |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5088 ;; ange-ftp-date-regexp eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5089 ;; (progn |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5090 ;; (skip-chars-forward " ") ; Eat blanks after date |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5091 ;; (skip-chars-forward "0-9:" eol) ; Eat time or year |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5092 ;; (skip-chars-forward " " eol) ; one space before filename |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5093 ;; ;; When listing an account other than the users own account it appends |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5094 ;; ;; ACCT: to the beginning of the filename. Skip over this. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5095 ;; (and (looking-at "[A-Z0-9_.]+:") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5096 ;; (goto-char (match-end 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5097 ;; (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5098 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5099 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5100 ;; nil))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5101 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5102 ;;(or (assq 'mts ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5103 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5104 ;; (cons '(mts . ange-ftp-dired-mts-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5105 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5106 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5107 ;;(defun ange-ftp-dired-mts-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5108 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5109 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5110 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5111 ;; ;; This is the MTS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5112 ;; (let (opoint hidden case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5113 ;; (setq opoint (point) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5114 ;; eol (save-excursion (end-of-line) (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5115 ;; hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5116 ;; (save-excursion (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5117 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5118 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5119 ;; (skip-chars-forward "-A-Z0-9._!" eol)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5120 ;; (or no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5121 ;; (not (eq opoint (point))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5122 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5123 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5124 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5125 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5126 ;; "No file on this line"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5127 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5128 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5129 ;; (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5130 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5131 ;;(or (assq 'mts ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5132 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5133 ;; (cons '(mts . ange-ftp-dired-mts-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5134 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5135 |
5136 ;;;; ------------------------------------------------------------ | |
5137 ;;;; CMS support | |
5138 ;;;; ------------------------------------------------------------ | |
5139 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5140 ;; Since CMS doesn't have any full file name syntax, we have to fudge |
4498
c050d8a0c3db
(ange-ftp-send-cmd): Bind ange-ftp-this-...
Richard M. Stallman <rms@gnu.org>
parents:
4185
diff
changeset
|
5141 ;; things with cd's. We actually send too many cd's, but it's dangerous |
1106 | 5142 ;; to try to remember the current minidisk, because if the connection |
5143 ;; is closed and needs to be reopened, we will find ourselves back in | |
5144 ;; the default minidisk. This is fairly likely since CMS ftp servers | |
5145 ;; usually close the connection after 5 minutes of inactivity. | |
5146 | |
5147 ;; Have I got the filename character set right? | |
5148 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5149 (defun ange-ftp-fix-name-for-cms (name &optional reverse) |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5150 (save-match-data |
1106 | 5151 (if reverse |
5152 ;; Since we only convert output from a pwd in this direction, | |
5153 ;; we'll assume that it's a minidisk, and make it into a | |
5154 ;; directory file name. Note that the expand-dir-hashtable | |
5155 ;; stores directories without the trailing /. Is this | |
5156 ;; consistent? | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5157 (concat "/" name) |
1106 | 5158 (if (string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5159 name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5160 (let ((minidisk (substring name 1 (match-end 1)))) |
1106 | 5161 (if (match-beginning 2) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5162 (let ((file (substring name (match-beginning 2) |
1106 | 5163 (match-end 2))) |
5164 (cmd (concat "cd " minidisk)) | |
5165 | |
5166 ;; Note that host and user are bound in the call | |
5167 ;; to ange-ftp-send-cmd | |
5168 (proc (ange-ftp-get-process ange-ftp-this-host | |
5169 ange-ftp-this-user))) | |
5170 | |
5171 ;; Must use ange-ftp-raw-send-cmd here to avoid | |
5172 ;; an infinite loop. | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5173 (if (car (ange-ftp-raw-send-cmd proc cmd ange-ftp-this-msg)) |
1106 | 5174 file |
5175 ;; failed... try ONCE more. | |
5176 (setq proc (ange-ftp-get-process ange-ftp-this-host | |
5177 ange-ftp-this-user)) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5178 (let ((result (ange-ftp-raw-send-cmd proc cmd |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5179 ange-ftp-this-msg))) |
1106 | 5180 (if (car result) |
5181 file | |
5182 ;; failed. give up. | |
5183 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user | |
5184 (format "cd to minidisk %s failed: %s" | |
5185 minidisk (cdr result))))))) | |
5186 ;; return the minidisk | |
5187 minidisk)) | |
5188 (error "Invalid CMS filename"))))) | |
5189 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5190 (or (assq 'cms ange-ftp-fix-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5191 (setq ange-ftp-fix-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5192 (cons '(cms . ange-ftp-fix-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5193 ange-ftp-fix-name-func-alist))) |
1106 | 5194 |
5195 (or (memq 'cms ange-ftp-dumb-host-types) | |
5196 (setq ange-ftp-dumb-host-types | |
5197 (cons 'cms ange-ftp-dumb-host-types))) | |
5198 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5199 ;; Convert name from UNIX-ish to CMS ready for a DIRectory listing. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5200 (defun ange-ftp-fix-dir-name-for-cms (dir-name) |
1106 | 5201 (cond |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5202 ((string-equal "/" dir-name) |
1106 | 5203 (error "Cannot get listing for fictitious \"/\" directory.")) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5204 ((string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" dir-name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5205 (let* ((minidisk (substring dir-name (match-beginning 1) (match-end 1))) |
1106 | 5206 ;; host and user are bound in the call to ange-ftp-send-cmd |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5207 (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user)) |
1106 | 5208 (cmd (concat "cd " minidisk)) |
5209 (file (if (match-beginning 2) | |
5210 ;; it's a single file | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5211 (substring dir-name (match-beginning 2) |
1106 | 5212 (match-end 2)) |
5213 ;; use the wild-card | |
5214 "*"))) | |
5215 (if (car (ange-ftp-raw-send-cmd proc cmd)) | |
5216 file | |
5217 ;; try again... | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5218 (setq proc (ange-ftp-get-process ange-ftp-this-host |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5219 ange-ftp-this-user)) |
1106 | 5220 (let ((result (ange-ftp-raw-send-cmd proc cmd))) |
5221 (if (car result) | |
5222 file | |
5223 ;; give up | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5224 (ange-ftp-error ange-ftp-this-host ange-ftp-this-user |
1106 | 5225 (format "cd to minidisk %s failed: " |
5226 minidisk (cdr result)))))))) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5227 (t (error "Invalid CMS file name")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5228 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5229 (or (assq 'cms ange-ftp-fix-dir-name-func-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5230 (setq ange-ftp-fix-dir-name-func-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5231 (cons '(cms . ange-ftp-fix-dir-name-for-cms) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5232 ange-ftp-fix-dir-name-func-alist))) |
1106 | 5233 |
5234 (defvar ange-ftp-cms-host-regexp nil | |
5235 "Regular expression to match hosts running the CMS operating system.") | |
5236 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5237 ;; Return non-nil if HOST is running CMS. |
1106 | 5238 (defun ange-ftp-cms-host (host) |
5239 (and ange-ftp-cms-host-regexp | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5240 (save-match-data |
1106 | 5241 (string-match ange-ftp-cms-host-regexp host)))) |
5242 | |
5243 (defun ange-ftp-add-cms-host (host) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5244 "Mark HOST as the name of a CMS host." |
1106 | 5245 (interactive |
5246 (list (read-string "Host: " | |
1456
5f42c7680da7
(ange-ftp-add-vms-host, ange-ftp-add-dl-dir, ange-ftp-add-mts-host):
Richard M. Stallman <rms@gnu.org>
parents:
1454
diff
changeset
|
5247 (let ((name (or (buffer-file-name) default-directory))) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5248 (and name (car (ange-ftp-ftp-name name))))))) |
1106 | 5249 (if (not (ange-ftp-cms-host host)) |
5250 (setq ange-ftp-cms-host-regexp | |
5251 (concat "^" (regexp-quote host) "$" | |
5252 (and ange-ftp-cms-host-regexp "\\|") | |
5253 ange-ftp-cms-host-regexp) | |
5254 ange-ftp-host-cache nil))) | |
5255 | |
5256 (defun ange-ftp-parse-cms-listing () | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5257 ;; Parse the current buffer which is assumed to be a CMS directory listing. |
1106 | 5258 ;; If we succeed in getting a listing, then we will assume that the minidisk |
5259 ;; exists. file is bound by the call to ange-ftp-ls. This doesn't work | |
5260 ;; because ange-ftp doesn't know that the root hashtable has only part of | |
5261 ;; the info. It will assume that if a minidisk isn't in it, then it doesn't | |
5262 ;; exist. It would be nice if completion worked for minidisks, as we | |
5263 ;; discover them. | |
5264 ; (let* ((dir-file (directory-file-name file)) | |
5265 ; (root (file-name-directory dir-file)) | |
5266 ; (minidisk (ange-ftp-get-file-part dir-file)) | |
5267 ; (root-tbl (ange-ftp-get-hash-entry root ange-ftp-files-hashtable))) | |
5268 ; (if root-tbl | |
5269 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5270 ; (setq root-tbl (ange-ftp-make-hashtable)) | |
5271 ; (ange-ftp-put-hash-entry minidisk t root-tbl) | |
5272 ; (ange-ftp-put-hash-entry "." t root-tbl) | |
5273 ; (ange-ftp-set-files root root-tbl))) | |
5274 ;; Now do the usual parsing | |
5275 (let ((tbl (ange-ftp-make-hashtable))) | |
5276 (goto-char (point-min)) | |
10244
3d95ea97eb9e
(ange-ftp-save-match-data): Macro deleted.
Richard M. Stallman <rms@gnu.org>
parents:
10118
diff
changeset
|
5277 (save-match-data |
1106 | 5278 (while |
5279 (re-search-forward | |
5280 "^\\([-A-Z0-9$_]+\\) +\\([-A-Z0-9$_]+\\) +[VF] +[0-9]+ " nil t) | |
5281 (ange-ftp-put-hash-entry | |
5282 (concat (buffer-substring (match-beginning 1) | |
5283 (match-end 1)) | |
5284 "." | |
5285 (buffer-substring (match-beginning 2) | |
5286 (match-end 2))) | |
5287 nil tbl) | |
5288 (forward-line 1)) | |
5289 (ange-ftp-put-hash-entry "." t tbl)) | |
5290 tbl)) | |
5291 | |
5292 (or (assq 'cms ange-ftp-parse-list-func-alist) | |
5293 (setq ange-ftp-parse-list-func-alist | |
5294 (cons '(cms . ange-ftp-parse-cms-listing) | |
5295 ange-ftp-parse-list-func-alist))) | |
5296 | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5297 ;;;;; Tree dired support: |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5298 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5299 ;;(defconst ange-ftp-dired-cms-re-exe |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5300 ;; "^. [-A-Z0-9$_]+ +EXEC " |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5301 ;; "Regular expression to use to search for CMS executables.") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5302 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5303 ;;(or (assq 'cms ange-ftp-dired-re-exe-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5304 ;; (setq ange-ftp-dired-re-exe-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5305 ;; (cons (cons 'cms ange-ftp-dired-cms-re-exe) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5306 ;; ange-ftp-dired-re-exe-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5307 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5308 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5309 ;;(defun ange-ftp-dired-cms-insert-headerline (dir) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5310 ;; ;; CMS has no total line, so we insert a blank line for |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5311 ;; ;; aesthetics. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5312 ;; (insert "\n") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5313 ;; (forward-char -1) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5314 ;; (ange-ftp-real-dired-insert-headerline dir)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5315 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5316 ;;(or (assq 'cms ange-ftp-dired-insert-headerline-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5317 ;; (setq ange-ftp-dired-insert-headerline-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5318 ;; (cons '(cms . ange-ftp-dired-cms-insert-headerline) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5319 ;; ange-ftp-dired-insert-headerline-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5320 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5321 ;;(defun ange-ftp-dired-cms-move-to-filename (&optional raise-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5322 ;; "In dired, move to the first char of filename on this line." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5323 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5324 ;; (or eol (setq eol (progn (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5325 ;; (let (case-fold-search) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5326 ;; (beginning-of-line) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5327 ;; (if (re-search-forward " [-A-Z0-9$_]+ +[-A-Z0-9$_]+ +[VF] +[0-9]+ " eol t) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5328 ;; (goto-char (1+ (match-beginning 0))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5329 ;; (if raise-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5330 ;; (error "No file on this line") |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5331 ;; nil)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5332 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5333 ;;(or (assq 'cms ange-ftp-dired-move-to-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5334 ;; (setq ange-ftp-dired-move-to-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5335 ;; (cons '(cms . ange-ftp-dired-cms-move-to-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5336 ;; ange-ftp-dired-move-to-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5337 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5338 ;;(defun ange-ftp-dired-cms-move-to-end-of-filename (&optional no-error eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5339 ;; ;; Assumes point is at beginning of filename. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5340 ;; ;; So, it should be called only after (dired-move-to-filename t). |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5341 ;; ;; case-fold-search must be nil, at least for VMS. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5342 ;; ;; On failure, signals an error or returns nil. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5343 ;; ;; This is the CMS version. |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5344 ;; (let ((opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5345 ;; case-fold-search hidden) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5346 ;; (or eol (setq eol (save-excursion (end-of-line) (point)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5347 ;; (setq hidden (and selective-display |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5348 ;; (save-excursion |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5349 ;; (search-forward "\r" eol t)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5350 ;; (if hidden |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5351 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5352 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5353 ;; (error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5354 ;; (substitute-command-keys |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5355 ;; "File line is hidden, type \\[dired-hide-subdir] to unhide"))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5356 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5357 ;; (skip-chars-forward " " eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5358 ;; (skip-chars-forward "-A-Z0-9$_" eol) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5359 ;; (if (eq opoint (point)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5360 ;; (if no-error |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5361 ;; nil |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5362 ;; (error "No file on this line")) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5363 ;; (point))))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5364 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5365 ;;(or (assq 'cms ange-ftp-dired-move-to-end-of-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5366 ;; (setq ange-ftp-dired-move-to-end-of-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5367 ;; (cons '(cms . ange-ftp-dired-cms-move-to-end-of-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5368 ;; ange-ftp-dired-move-to-end-of-filename-alist))) |
1106 | 5369 |
5370 (defun ange-ftp-cms-make-compressed-filename (name &optional reverse) | |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5371 (if (string-match "-Z$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5372 (list nil (substring name 0 -2)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5373 (list t (concat name "-Z")))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5374 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5375 (or (assq 'cms ange-ftp-make-compressed-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5376 (setq ange-ftp-make-compressed-filename-alist |
1106 | 5377 (cons '(cms . ange-ftp-cms-make-compressed-filename) |
1132
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5378 ange-ftp-make-compressed-filename-alist))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5379 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5380 ;;(defun ange-ftp-dired-cms-get-filename (&optional localp no-error-if-not-filep) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5381 ;; (let ((name (ange-ftp-real-dired-get-filename localp no-error-if-not-filep))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5382 ;; (and name |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5383 ;; (if (string-match "^\\([^ ]+\\) +\\([^ ]+\\)$" name) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5384 ;; (concat (substring name 0 (match-end 1)) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5385 ;; "." |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5386 ;; (substring name (match-beginning 2) (match-end 2))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5387 ;; name)))) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5388 |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5389 ;;(or (assq 'cms ange-ftp-dired-get-filename-alist) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5390 ;; (setq ange-ftp-dired-get-filename-alist |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5391 ;; (cons '(cms . ange-ftp-dired-cms-get-filename) |
4cfdd782a158
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1109
diff
changeset
|
5392 ;; ange-ftp-dired-get-filename-alist))) |
1106 | 5393 |
5394 ;;;; ------------------------------------------------------------ | |
5395 ;;;; Finally provide package. | |
5396 ;;;; ------------------------------------------------------------ | |
5397 | |
5398 (provide 'ange-ftp) | |
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
5399 |
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1670
diff
changeset
|
5400 ;;; ange-ftp.el ends here |