diff options
| author | Geoff Voelker | 1998-04-17 05:22:37 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-04-17 05:22:37 +0000 |
| commit | c4185b2b8db3b3a33c65855df1c510aec7c6b247 (patch) | |
| tree | f1f1086b9addf7c7f141b54ac306eb1c87d936cf | |
| parent | 614c350caca77fbe3ff6f43a56492cd929d5927e (diff) | |
| download | emacs-c4185b2b8db3b3a33c65855df1c510aec7c6b247.tar.gz emacs-c4185b2b8db3b3a33c65855df1c510aec7c6b247.zip | |
(ange-ftp-tmp-name-template) [windows-nt]: Look for
common temp directories.
(ange-ftp-parse-netrc-group): Skip carriage returns.
(ange-ftp-expand-file-name): Handle files with drive letters.
(ange-ftp-write-region): Don't treat as unix.
(ange-ftp-insert-file-contents): Determine file type by transfer mode.
(ange-ftp-copy-file-internal): Don't treat as unix.
(ange-ftp-file-name-all-completions): Handle Windows filenames.
(file-name-handler-alist) [windows-nt]: Add patterns for name with
drive letters.
(ange-ftp-dired-call-process, ange-ftp-call-chmod): Use
dired-chmod-program.
(ange-ftp-disable-netrc-security-check) [windows-nt]: Disable by
default.
(ange-ftp-real-expand-file-name-actual): New function.
| -rw-r--r-- | lisp/ange-ftp.el | 90 |
1 files changed, 68 insertions, 22 deletions
diff --git a/lisp/ange-ftp.el b/lisp/ange-ftp.el index c7e980e6f2c..85e60e8a5a9 100644 --- a/lisp/ange-ftp.el +++ b/lisp/ange-ftp.el | |||
| @@ -700,7 +700,10 @@ These mean that the FTP process should (or already has) been killed." | |||
| 700 | :group 'ange-ftp | 700 | :group 'ange-ftp |
| 701 | :type 'regexp) | 701 | :type 'regexp) |
| 702 | 702 | ||
| 703 | (defcustom ange-ftp-tmp-name-template "/tmp/ange-ftp" | 703 | (defcustom ange-ftp-tmp-name-template |
| 704 | (if (memq system-type '(ms-dos windows-nt)) | ||
| 705 | (concat (or (getenv "TEMP") (getenv "TMP") "c:/temp") "/ange-ftp") | ||
| 706 | "/tmp/ange-ftp") | ||
| 704 | "*Template used to create temporary files." | 707 | "*Template used to create temporary files." |
| 705 | :group 'ange-ftp | 708 | :group 'ange-ftp |
| 706 | :type 'directory) | 709 | :type 'directory) |
| @@ -1307,11 +1310,11 @@ Optional DEFAULT is password to start with." | |||
| 1307 | (if (looking-at "machine\\>") | 1310 | (if (looking-at "machine\\>") |
| 1308 | ;; Skip `machine' and the machine name that follows. | 1311 | ;; Skip `machine' and the machine name that follows. |
| 1309 | (progn | 1312 | (progn |
| 1310 | (skip-chars-forward "^ \t\n") | 1313 | (skip-chars-forward "^ \t\r\n") |
| 1311 | (skip-chars-forward " \t\n") | 1314 | (skip-chars-forward " \t\r\n") |
| 1312 | (skip-chars-forward "^ \t\n")) | 1315 | (skip-chars-forward "^ \t\r\n")) |
| 1313 | ;; Skip `default'. | 1316 | ;; Skip `default'. |
| 1314 | (skip-chars-forward "^ \t\n")) | 1317 | (skip-chars-forward "^ \t\r\n")) |
| 1315 | ;; Find start of the next `machine' or `default' | 1318 | ;; Find start of the next `machine' or `default' |
| 1316 | ;; or the end of the buffer. | 1319 | ;; or the end of the buffer. |
| 1317 | (if (re-search-forward "machine\\>\\|default\\>" nil t) | 1320 | (if (re-search-forward "machine\\>\\|default\\>" nil t) |
| @@ -1376,7 +1379,7 @@ Optional DEFAULT is password to start with." | |||
| 1376 | (mapcar 'funcall find-file-hooks) | 1379 | (mapcar 'funcall find-file-hooks) |
| 1377 | (setq buffer-file-name nil) | 1380 | (setq buffer-file-name nil) |
| 1378 | (goto-char (point-min)) | 1381 | (goto-char (point-min)) |
| 1379 | (skip-chars-forward " \t\n") | 1382 | (skip-chars-forward " \t\r\n") |
| 1380 | (while (not (eobp)) | 1383 | (while (not (eobp)) |
| 1381 | (ange-ftp-parse-netrc-group)) | 1384 | (ange-ftp-parse-netrc-group)) |
| 1382 | (kill-buffer (current-buffer))) | 1385 | (kill-buffer (current-buffer))) |
| @@ -3041,6 +3044,8 @@ logged in as user USER and cd'd to directory DIR." | |||
| 3041 | (ange-ftp-real-expand-file-name name)) | 3044 | (ange-ftp-real-expand-file-name name)) |
| 3042 | ((eq (string-to-char name) ?/) | 3045 | ((eq (string-to-char name) ?/) |
| 3043 | (ange-ftp-canonize-filename name)) | 3046 | (ange-ftp-canonize-filename name)) |
| 3047 | ((and (eq system-type 'windows-nt) (string-match "^[a-zA-Z]:" name)) | ||
| 3048 | name) ; when on local drive, return it as-is | ||
| 3044 | ((zerop (length name)) | 3049 | ((zerop (length name)) |
| 3045 | (ange-ftp-canonize-filename (or default default-directory))) | 3050 | (ange-ftp-canonize-filename (or default default-directory))) |
| 3046 | ((ange-ftp-canonize-filename | 3051 | ((ange-ftp-canonize-filename |
| @@ -3116,8 +3121,12 @@ system TYPE.") | |||
| 3116 | (user (nth 1 parsed)) | 3121 | (user (nth 1 parsed)) |
| 3117 | (name (ange-ftp-quote-string (nth 2 parsed))) | 3122 | (name (ange-ftp-quote-string (nth 2 parsed))) |
| 3118 | (temp (ange-ftp-make-tmp-name host)) | 3123 | (temp (ange-ftp-make-tmp-name host)) |
| 3124 | ;; What we REALLY need here is a way to determine if the mode | ||
| 3125 | ;; of the transfer is irrelevant, i.e. we can use binary mode | ||
| 3126 | ;; regardless. Maybe a system-type to host-type lookup? | ||
| 3119 | (binary (or (ange-ftp-binary-file filename) | 3127 | (binary (or (ange-ftp-binary-file filename) |
| 3120 | (eq (ange-ftp-host-type host user) 'unix))) | 3128 | (and (not (eq system-type 'windows-nt)) |
| 3129 | (eq (ange-ftp-host-type host user) 'unix)))) | ||
| 3121 | (cmd (if append 'append 'put)) | 3130 | (cmd (if append 'append 'put)) |
| 3122 | (abbr (ange-ftp-abbreviate-filename filename))) | 3131 | (abbr (ange-ftp-abbreviate-filename filename))) |
| 3123 | (unwind-protect | 3132 | (unwind-protect |
| @@ -3180,7 +3189,8 @@ system TYPE.") | |||
| 3180 | (name (ange-ftp-quote-string (nth 2 parsed))) | 3189 | (name (ange-ftp-quote-string (nth 2 parsed))) |
| 3181 | (temp (ange-ftp-make-tmp-name host)) | 3190 | (temp (ange-ftp-make-tmp-name host)) |
| 3182 | (binary (or (ange-ftp-binary-file filename) | 3191 | (binary (or (ange-ftp-binary-file filename) |
| 3183 | (eq (ange-ftp-host-type host user) 'unix))) | 3192 | (and (not (eq system-type 'windows-nt)) |
| 3193 | (eq (ange-ftp-host-type host user) 'unix)))) | ||
| 3184 | (abbr (ange-ftp-abbreviate-filename filename)) | 3194 | (abbr (ange-ftp-abbreviate-filename filename)) |
| 3185 | size) | 3195 | size) |
| 3186 | (unwind-protect | 3196 | (unwind-protect |
| @@ -3203,7 +3213,10 @@ system TYPE.") | |||
| 3203 | (setq | 3213 | (setq |
| 3204 | size | 3214 | size |
| 3205 | (nth 1 (ange-ftp-real-insert-file-contents | 3215 | (nth 1 (ange-ftp-real-insert-file-contents |
| 3206 | temp visit beg end replace))) | 3216 | temp visit beg end replace)) |
| 3217 | ;; override autodetection of buffer file type | ||
| 3218 | ;; to ensure buffer is saved in DOS format | ||
| 3219 | buffer-file-type binary) | ||
| 3207 | (signal 'ftp-error | 3220 | (signal 'ftp-error |
| 3208 | (list | 3221 | (list |
| 3209 | "Opening input file:" | 3222 | "Opening input file:" |
| @@ -3462,7 +3475,8 @@ system TYPE.") | |||
| 3462 | (t-abbr (ange-ftp-abbreviate-filename newname filename)) | 3475 | (t-abbr (ange-ftp-abbreviate-filename newname filename)) |
| 3463 | (binary (or (ange-ftp-binary-file filename) | 3476 | (binary (or (ange-ftp-binary-file filename) |
| 3464 | (ange-ftp-binary-file newname) | 3477 | (ange-ftp-binary-file newname) |
| 3465 | (and (eq (ange-ftp-host-type f-host f-user) 'unix) | 3478 | (and (not (eq system-type 'windows-nt)) |
| 3479 | (eq (ange-ftp-host-type f-host f-user) 'unix) | ||
| 3466 | (eq (ange-ftp-host-type t-host t-user) 'unix)))) | 3480 | (eq (ange-ftp-host-type t-host t-user) 'unix)))) |
| 3467 | temp1 | 3481 | temp1 |
| 3468 | temp2) | 3482 | temp2) |
| @@ -3750,7 +3764,9 @@ system TYPE.") | |||
| 3750 | file)))) | 3764 | file)))) |
| 3751 | completions))) | 3765 | completions))) |
| 3752 | 3766 | ||
| 3753 | (if (string-equal "/" ange-ftp-this-dir) | 3767 | (if (or (and (eq system-type 'windows-nt) |
| 3768 | (string-match "[^a-zA-Z]?[a-zA-Z]:[/\]" ange-ftp-this-dir)) | ||
| 3769 | (string-equal "/" ange-ftp-this-dir)) | ||
| 3754 | (nconc (all-completions file (ange-ftp-generate-root-prefixes)) | 3770 | (nconc (all-completions file (ange-ftp-generate-root-prefixes)) |
| 3755 | (ange-ftp-real-file-name-all-completions file | 3771 | (ange-ftp-real-file-name-all-completions file |
| 3756 | ange-ftp-this-dir)) | 3772 | ange-ftp-this-dir)) |
| @@ -4048,18 +4064,24 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4048 | ;;; and colon). | 4064 | ;;; and colon). |
| 4049 | ;;; Don't allow the host name to end in a period--some systems use /.: | 4065 | ;;; Don't allow the host name to end in a period--some systems use /.: |
| 4050 | ;;;###autoload | 4066 | ;;;###autoload |
| 4051 | (or (assoc "^/[^/:]*[^/:.]:" file-name-handler-alist) | 4067 | (let ((pattern (if (memq system-type '(ms-dos windows-nt)) |
| 4052 | (setq file-name-handler-alist | 4068 | "^[a-zA-Z]:/[^/:]*[^/:.]:" |
| 4053 | (cons '("^/[^/:]*[^/:.]:" . ange-ftp-hook-function) | 4069 | "^/[^/:]*[^/:.]:"))) |
| 4054 | file-name-handler-alist))) | 4070 | (or (assoc pattern file-name-handler-alist) |
| 4071 | (setq file-name-handler-alist | ||
| 4072 | (cons (cons pattern ange-ftp-hook-function) | ||
| 4073 | file-name-handler-alist)))) | ||
| 4055 | 4074 | ||
| 4056 | ;;; This regexp recognizes and absolute filenames with only one component, | 4075 | ;;; This regexp recognizes and absolute filenames with only one component, |
| 4057 | ;;; for the sake of hostname completion. | 4076 | ;;; for the sake of hostname completion. |
| 4058 | ;;;###autoload | 4077 | ;;;###autoload |
| 4059 | (or (assoc "^/[^/:]*\\'" file-name-handler-alist) | 4078 | (let ((pattern (if (memq system-type '(ms-dos windows-nt)) |
| 4060 | (setq file-name-handler-alist | 4079 | "^[a-zA-Z]:/[^/:]*\\'" |
| 4061 | (cons '("^/[^/:]*\\'" . ange-ftp-completion-hook-function) | 4080 | "^/[^/:]*\\'"))) |
| 4062 | file-name-handler-alist))) | 4081 | (or (assoc pattern file-name-handler-alist) |
| 4082 | (setq file-name-handler-alist | ||
| 4083 | (cons (cons pattern ange-ftp-completion-hook-function) | ||
| 4084 | file-name-handler-alist)))) | ||
| 4063 | 4085 | ||
| 4064 | ;;; The above two forms are sufficient to cause this file to be loaded | 4086 | ;;; The above two forms are sufficient to cause this file to be loaded |
| 4065 | ;;; if the user ever uses a file name with a colon in it. | 4087 | ;;; if the user ever uses a file name with a colon in it. |
| @@ -4138,8 +4160,12 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4138 | (ange-ftp-run-real-handler 'file-name-as-directory args)) | 4160 | (ange-ftp-run-real-handler 'file-name-as-directory args)) |
| 4139 | (defun ange-ftp-real-directory-file-name (&rest args) | 4161 | (defun ange-ftp-real-directory-file-name (&rest args) |
| 4140 | (ange-ftp-run-real-handler 'directory-file-name args)) | 4162 | (ange-ftp-run-real-handler 'directory-file-name args)) |
| 4163 | (or (and (eq system-type 'windows-nt) | ||
| 4164 | ;; Windows handler for [A-Z]: drive name on local disks | ||
| 4165 | (defun ange-ftp-real-expand-file-name (&rest args) | ||
| 4166 | (ange-ftp-run-real-handler 'ange-ftp-real-expand-file-name-actual args))) | ||
| 4141 | (defun ange-ftp-real-expand-file-name (&rest args) | 4167 | (defun ange-ftp-real-expand-file-name (&rest args) |
| 4142 | (ange-ftp-run-real-handler 'expand-file-name args)) | 4168 | (ange-ftp-run-real-handler 'expand-file-name args))) |
| 4143 | (defun ange-ftp-real-make-directory (&rest args) | 4169 | (defun ange-ftp-real-make-directory (&rest args) |
| 4144 | (ange-ftp-run-real-handler 'make-directory args)) | 4170 | (ange-ftp-run-real-handler 'make-directory args)) |
| 4145 | (defun ange-ftp-real-delete-directory (&rest args) | 4171 | (defun ange-ftp-real-delete-directory (&rest args) |
| @@ -4260,7 +4286,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4260 | ;; Can't use ange-ftp-dired-host-type here because the current | 4286 | ;; Can't use ange-ftp-dired-host-type here because the current |
| 4261 | ;; buffer is *dired-check-process output* | 4287 | ;; buffer is *dired-check-process output* |
| 4262 | (condition-case oops | 4288 | (condition-case oops |
| 4263 | (cond ((equal "chmod" program) | 4289 | (cond ((equal dired-chmod-program program) |
| 4264 | (ange-ftp-call-chmod arguments)) | 4290 | (ange-ftp-call-chmod arguments)) |
| 4265 | ;; ((equal "chgrp" program)) | 4291 | ;; ((equal "chgrp" program)) |
| 4266 | ;; ((equal dired-chown-program program)) | 4292 | ;; ((equal dired-chown-program program)) |
| @@ -4304,7 +4330,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4304 | (or (car result) | 4330 | (or (car result) |
| 4305 | (call-process | 4331 | (call-process |
| 4306 | ange-ftp-remote-shell | 4332 | ange-ftp-remote-shell |
| 4307 | nil t nil host "chmod" mode name))))))) | 4333 | nil t nil host dired-chmod-program mode name))))))) |
| 4308 | rest)) | 4334 | rest)) |
| 4309 | (setq ange-ftp-ls-cache-file nil) ;Stop confusing Dired. | 4335 | (setq ange-ftp-ls-cache-file nil) ;Stop confusing Dired. |
| 4310 | 0) | 4336 | 0) |
| @@ -5632,6 +5658,26 @@ Other orders of $ and _ seem to all work just fine.") | |||
| 5632 | ;; (cons '(cms . ange-ftp-dired-cms-get-filename) | 5658 | ;; (cons '(cms . ange-ftp-dired-cms-get-filename) |
| 5633 | ;; ange-ftp-dired-get-filename-alist))) | 5659 | ;; ange-ftp-dired-get-filename-alist))) |
| 5634 | 5660 | ||
| 5661 | ;; | ||
| 5662 | (and (eq system-type 'windows-nt) | ||
| 5663 | (setq ange-ftp-disable-netrc-security-check t)) | ||
| 5664 | |||
| 5665 | ;; If a drive letter has been added, remote it. Otherwise, if the drive | ||
| 5666 | ;; letter existed before, leave it. | ||
| 5667 | (defun ange-ftp-real-expand-file-name-actual (&rest args) | ||
| 5668 | (setq old-name (car args)) | ||
| 5669 | (setq new-name (ange-ftp-run-real-handler 'expand-file-name args)) | ||
| 5670 | (setq drive-letter (substring new-name 0 2)) | ||
| 5671 | ;; I'd like to distill the following lines into one (if) statement | ||
| 5672 | ;; removing the need for the temp final variable | ||
| 5673 | (setq final new-name) | ||
| 5674 | (if (not (equal (substring old-name 0 1) "~")) | ||
| 5675 | (if (or (< (length old-name) 2) | ||
| 5676 | (not (string-match "/[a-zA-Z]:" old-name))) | ||
| 5677 | (setq final (substring new-name 2)))) | ||
| 5678 | final) | ||
| 5679 | |||
| 5680 | |||
| 5635 | ;;;; ------------------------------------------------------------ | 5681 | ;;;; ------------------------------------------------------------ |
| 5636 | ;;;; Finally provide package. | 5682 | ;;;; Finally provide package. |
| 5637 | ;;;; ------------------------------------------------------------ | 5683 | ;;;; ------------------------------------------------------------ |