Spelling fixes.
[bpt/emacs.git] / lisp / net / ange-ftp.el
index 53d58a7..458d419 100644 (file)
@@ -721,7 +721,7 @@ parenthesized expressions in REGEXP for the components (in that order)."
          "^local:\\|^Trying\\|^125 \\|^550-\\|^221 .*oodbye\\|"
           "^500 .*AUTH\\|^KERBEROS\\|"
           "^504 Unknown security mechanism\\|"
-         "^530 Please login with USER and PASS\\|" ; non kerberised vsFTPd
+         "^530 Please login with USER and PASS\\|" ; non kerberized vsFTPd
          "^534 Kerberos Authentication not enabled\\|"
          "^22[789] .*[Pp]assive\\|^200 EPRT\\|^500 .*EPRT")
   "Regular expression matching FTP messages that can be ignored."
@@ -1723,11 +1723,12 @@ good, skip, fatal, or unknown."
 ;;; Temporary file location and deletion...
 ;;; ------------------------------------------------------------
 
-(defun ange-ftp-make-tmp-name (host)
+(defun ange-ftp-make-tmp-name (host &optional suffix)
   "This routine will return the name of a new file."
   (make-temp-file (if (ange-ftp-use-gateway-p host)
                      ange-ftp-gateway-tmp-name-template
-                   ange-ftp-tmp-name-template)))
+                   ange-ftp-tmp-name-template)
+                 nil suffix))
 
 (defun ange-ftp-del-tmp-name (filename)
   "Force to delete temporary file."
@@ -2806,6 +2807,19 @@ match subdirectories as well.")
   (and files (puthash (file-name-as-directory directory)
                      files ange-ftp-files-hashtable)))
 
+(defun ange-ftp-switches-ok (switches)
+  "Return SWITCHES (a string) if suitable for our use."
+  (and (stringp switches)
+       ;; We allow the A switch, which lists all files except "." and
+       ;; "..".  This is OK because we manually insert these entries
+       ;; in the hash table.
+       (string-match
+       "--\\(almost-\\)?all\\>\\|\\(\\`\\| \\)-[[:alpha:]]*[aA]" switches)
+       (string-match "\\(\\`\\| \\)-[[:alpha:]]*l" switches)
+       (not (string-match
+            "--recursive\\>\\|\\(\\`\\| \\)-[[:alpha:]]*R" switches))
+       switches))
+
 (defun ange-ftp-get-files (directory &optional no-error)
   "Given a DIRECTORY, return a hashtable of file entries.
 This will give an error or return nil, depending on the value of
@@ -2817,30 +2831,12 @@ NO-ERROR, if a listing for DIRECTORY cannot be obtained."
                          ;; This is an efficiency hack. We try to
                          ;; anticipate what sort of listing dired
                          ;; might want, and cache just such a listing.
-                         (if (and (boundp 'dired-actual-switches)
-                                  (stringp dired-actual-switches)
-                                  ;; We allow the A switch, which lists
-                                  ;; all files except "." and "..".
-                                  ;; This is OK because we manually
-                                  ;; insert these entries
-                                  ;; in the hash table.
-                                  (string-match
-                                   "[aA]" dired-actual-switches)
-                                  (string-match
-                                   "l" dired-actual-switches)
-                                  (not (string-match
-                                        "R" dired-actual-switches)))
-                             dired-actual-switches
-                           (if (and (boundp 'dired-listing-switches)
-                                    (stringp dired-listing-switches)
-                                    (string-match
-                                     "[aA]" dired-listing-switches)
-                                    (string-match
-                                     "l" dired-listing-switches)
-                                    (not (string-match
-                                          "R" dired-listing-switches)))
-                               dired-listing-switches
-                             "-al"))
+                         (or (and (boundp 'dired-actual-switches)
+                                  (ange-ftp-switches-ok dired-actual-switches))
+                             (and (boundp 'dired-listing-switches)
+                                  (ange-ftp-switches-ok
+                                   dired-listing-switches))
+                             "-al")
                          t no-error)
             (gethash directory ange-ftp-files-hashtable)))))
 
@@ -3283,6 +3279,7 @@ system TYPE.")
                     (name (ange-ftp-quote-string (nth 2 parsed)))
                     (temp (ange-ftp-make-tmp-name host))
                     (binary (ange-ftp-binary-file filename))
+                    (buffer-file-type buffer-file-type)
                     (abbr (ange-ftp-abbreviate-filename filename))
                     (coding-system-used last-coding-system-used)
                     size)
@@ -4030,7 +4027,7 @@ E.g.,
              (concat bestmatch "/")
            bestmatch)))))
 
-;; Put these lines uncommmented in your .emacs if you want C-r to refresh
+;; Put these lines uncommented in your .emacs if you want C-r to refresh
 ;; ange-ftp's cache whilst doing filename completion.
 ;;
 ;;(define-key minibuffer-local-completion-map "\C-r" 'ange-ftp-re-read-dir)
@@ -4143,7 +4140,8 @@ directory, so that Emacs will know its current contents."
   (let* ((fn1 (expand-file-name file))
         (pa1 (ange-ftp-ftp-name fn1)))
     (if pa1
-       (let ((tmp1 (ange-ftp-make-tmp-name (car pa1))))
+       (let ((tmp1 (ange-ftp-make-tmp-name (car pa1)
+                                           (file-name-extension file t))))
          (ange-ftp-copy-file-internal fn1 tmp1 t nil
                                       (format "Getting %s" fn1))
          tmp1))))
@@ -4414,14 +4412,16 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
 ;;; Define ways of getting at unmodified Emacs primitives,
 ;;; turning off our handler.
 
-(defun ange-ftp-run-real-handler (operation args)
-  (let ((inhibit-file-name-handlers
-        (cons 'ange-ftp-hook-function
-              (cons 'ange-ftp-completion-hook-function
-                    (and (eq inhibit-file-name-operation operation)
-                         inhibit-file-name-handlers))))
-       (inhibit-file-name-operation operation))
-    (apply operation args)))
+;(defun ange-ftp-run-real-handler (operation args)
+;  (let ((inhibit-file-name-handlers
+;       (cons 'ange-ftp-hook-function
+;             (cons 'ange-ftp-completion-hook-function
+;                   (and (eq inhibit-file-name-operation operation)
+;                        inhibit-file-name-handlers))))
+;      (inhibit-file-name-operation operation))
+;    (apply operation args)))
+
+(defalias 'ange-ftp-run-real-handler 'tramp-run-real-handler)
 
 (defun ange-ftp-real-file-name-directory (&rest args)
   (ange-ftp-run-real-handler 'file-name-directory args))
@@ -4507,7 +4507,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
     ;; We used to follow symlinks on `file' here.  Apparently it was done
     ;; because some FTP servers react to "ls foo" by listing the symlink foo
     ;; rather than the directory it points to.  Now that ange-ftp-ls uses
-    ;; "cd foo; ls" instead, this is not necesssary any more.
+    ;; "cd foo; ls" instead, this is not necessary any more.
     (let ((beg (point))
          (end (point-marker)))
       (set-marker-insertion-type end t)
@@ -5007,7 +5007,11 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
                      dir (and dir "/")
                      file))
          (error "name %s didn't match" name))
-      (let (drive dir file tmp)
+      (let (drive dir file tmp quote)
+       (if (string-match "\\`\".+\"\\'" name)
+           (setq name (substring name 1 -1)
+                 quote "\"")
+         (setq quote ""))
        (if (string-match "\\`/[^:]+:/" name)
            (setq drive (substring name 1
                                   (1- (match-end 0)))
@@ -5016,9 +5020,9 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
        (if tmp
            (setq dir (subst-char-in-string ?/ ?. (substring tmp 0 -1) t)))
        (setq file (file-name-nondirectory name))
-       (concat drive
+       (concat quote drive
                (and dir (concat "[" (if drive nil ".") dir "]"))
-               file)))))
+               file quote)))))
 
 ;; (ange-ftp-fix-name-for-vms "/PUB$:/ANONYMOUS/SDSCPUB/NEXT/Readme.txt;1")
 ;; (ange-ftp-fix-name-for-vms "/PUB$:[ANONYMOUS.SDSCPUB.NEXT]Readme.txt;1" t)
@@ -5448,7 +5452,7 @@ Other orders of $ and _ seem to all work just fine.")
 ;;                                base-versions
 ;;                                (file-name-directory fn)))
 ;;                (versions (mapcar
-;;                           '(lambda (arg)
+;;                           (lambda (arg)
 ;;                              (if (and (string-match
 ;;                                        "[0-9]+$" arg bv-length)
 ;;                                       (= (match-beginning 0) bv-length))