]> code.delx.au - gnu-emacs/blobdiff - lisp/ange-ftp.el
(Finsert_file_contents): If undo_list was t, leave it t.
[gnu-emacs] / lisp / ange-ftp.el
index a1b9fc2645629e9f1cbb9cbb8d99d02f7930e5c5..54b30035d2329d52de943b8ce82dbe5d917ae215 100644 (file)
@@ -707,7 +707,8 @@ process uses the \'dir\' command to get directory information.")
 (defvar ange-ftp-binary-file-name-regexp
   (concat "\\.[zZ]$\\|\\.lzh$\\|\\.arc$\\|\\.zip$\\|\\.zoo$\\|\\.tar$\\|"
          "\\.dvi$\\|\\.ps$\\|\\.elc$\\|TAGS$\\|\\.gif$\\|"
-         "\\.EXE\\(;[0-9]+\\)?$\\|\\.[zZ]-part-..$\\|\\.gz$")
+         "\\.EXE\\(;[0-9]+\\)?$\\|\\.[zZ]-part-..$\\|\\.gz$\\|"
+         "\\.taz$\\|\\.tgz$")
   "*If a file matches this regexp then it is transferred in binary mode.")
 
 (defvar ange-ftp-gateway-host nil
@@ -728,7 +729,7 @@ like this.")
 are rsh (remsh on hp-ux), telnet and rlogin.  See also the gateway variable
 above.")
 
-(defvar ange-ftp-gateway-prompt-pattern "^[^#$%>;]*[#$%>;] *"
+(defvar ange-ftp-gateway-prompt-pattern "^[^#$%>;\n]*[#$%>;] *"
   "*Regexp used to detect that the logging-in sequence is completed on the
 gateway machine and that the shell is now awaiting input.  Make this regexp as
 strict as possible; it shouldn't match *anything* at all except the user's
@@ -856,7 +857,7 @@ SIZE, if supplied, should be a prime number."
 ;;;; Internal variables.
 ;;;; ------------------------------------------------------------
 
-(defconst ange-ftp-version "$Revision: 1.31 $")
+(defconst ange-ftp-version "$Revision: 1.41 $")
 
 (defvar ange-ftp-data-buffer-name " *ftp data*"
   "Buffer name to hold directory listing data received from ftp process.")
@@ -1849,6 +1850,7 @@ PROC is the process to the FTP-client."
                          (concat "USER request failed: "
                                  (cdr result)))))))
 
+;; ange@hplb.hpl.hp.com says this should not be changed.
 (defvar ange-ftp-hash-mark-msgs
   "[hH]ash mark [^0-9]*\\([0-9]+\\)"
   "*Regexp matching the FTP client's output upon doing a HASH command.")
@@ -2437,6 +2439,8 @@ a listing, then return nil."
     (cond
      ((looking-at "^total [0-9]+$")
       (forward-line 1)
+      ;; Some systems put in a blank line here.
+      (if (eolp) (forward-line 1))
       (ange-ftp-ls-parser))
      ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'")
       ;; It's an ls error message.
@@ -2894,6 +2898,7 @@ system TYPE.")
                (ange-ftp-set-ascii-mode host user)))
          (if (eq visit t)
              (progn
+               (set-visited-file-modtime '(0 0))
                (ange-ftp-set-buffer-mode)
                (setq buffer-file-name filename)
                (set-buffer-modified-p nil)))
@@ -2901,7 +2906,7 @@ system TYPE.")
          (ange-ftp-add-file-entry filename))
       (ange-ftp-real-write-region start end filename append visit))))
 
-(defun ange-ftp-insert-file-contents (filename &optional visit beg end)
+(defun ange-ftp-insert-file-contents (filename &optional visit beg end replace)
   (barf-if-buffer-read-only)
   (setq filename (expand-file-name filename))
   (let ((parsed (ange-ftp-ftp-name filename)))
@@ -2941,9 +2946,8 @@ system TYPE.")
                              (ange-ftp-real-file-readable-p temp))
                          (setq
                           size
-                          (nth 1 (ange-ftp-real-insert-file-contents temp
-                                                                     visit
-                                                                     beg end)))
+                          (nth 1 (ange-ftp-real-insert-file-contents
+                                  temp visit beg end replace)))
                        (signal 'ftp-error
                                (list
                                 "Opening input file:"
@@ -2954,13 +2958,15 @@ system TYPE.")
                      (ange-ftp-set-ascii-mode host user))
                  (ange-ftp-del-tmp-name temp))
                (if visit
-                   (setq buffer-file-name filename))
+                   (progn
+                     (set-visited-file-modtime '(0 0))
+                     (setq buffer-file-name filename)))
                (list filename size))
            (signal 'file-error
                    (list 
                     "Opening input file"
                     filename))))
-      (ange-ftp-real-insert-file-contents filename visit beg end))))
+      (ange-ftp-real-insert-file-contents filename visit beg end replace))))
  
 (defun ange-ftp-expand-symlink (file dir)
   (if (file-name-absolute-p file)
@@ -3081,6 +3087,12 @@ system TYPE.")
       (file-exists-p file)
     (ange-ftp-real-file-readable-p file)))
 
+(defun ange-ftp-file-executable-p (file)
+  (setq file (expand-file-name file))
+  (if (ange-ftp-ftp-name file)
+      (file-exists-p file)
+    (ange-ftp-real-file-executable-p file)))
+
 (defun ange-ftp-delete-file (file)
   (interactive "fDelete file: ")
   (setq file (expand-file-name file))
@@ -3628,13 +3640,23 @@ system TYPE.")
                                       (format "Getting %s" fn1))
          tmp1))))
 
-(defun ange-ftp-load (file)
+(defun ange-ftp-load (file &optional noerror nomessage nosuffix)
   (if (ange-ftp-ftp-name file)
-      (let ((copy (ange-ftp-file-local-copy file)))
-       (unwind-protect
-           (load copy)
-         (delete-file copy)))
-    (ange-ftp-real-load file)))
+      (let ((tryfiles (if nosuffix
+                         (list file)
+                       (list (concat file ".elc") (concat file ".el") file)))
+           copy)
+       (while (and tryfiles (not copy))
+         (condition-case error
+             (setq copy (ange-ftp-file-local-copy (car tryfiles)))
+           (ftp-error nil)))
+       (if copy
+           (unwind-protect
+               (funcall 'load copy noerror nomessage nosuffix)
+             (delete-file copy))
+         (or noerror
+             (signal 'file-error (list "Cannot open load file" file)))))
+    (ange-ftp-real-load file noerror nomessage nosuffix)))
 
 ;; Calculate default-unhandled-directory for a given ange-ftp buffer.
 (defun ange-ftp-unhandled-file-name-directory (filename)
@@ -3788,6 +3810,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
 (put 'file-directory-p 'ange-ftp 'ange-ftp-file-directory-p)
 (put 'file-writable-p 'ange-ftp 'ange-ftp-file-writable-p)
 (put 'file-readable-p 'ange-ftp 'ange-ftp-file-readable-p)
+(put 'file-executable-p 'ange-ftp 'ange-ftp-file-executable-p)
 (put 'file-symlink-p 'ange-ftp 'ange-ftp-file-symlink-p)
 (put 'delete-file 'ange-ftp 'ange-ftp-delete-file)
 (put 'read-file-name-internal 'ange-ftp 'ange-ftp-read-file-name-internal)
@@ -3857,6 +3880,9 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
 (defun ange-ftp-real-file-readable-p (&rest args)
   (let (file-name-handler-alist)
     (apply 'file-readable-p args)))
+(defun ange-ftp-real-file-executable-p (&rest args)
+  (let (file-name-handler-alist)
+    (apply 'file-executable-p args)))
 (defun ange-ftp-real-file-symlink-p (&rest args)
   (let (file-name-handler-alist)
     (apply 'file-symlink-p args)))
@@ -3930,8 +3956,8 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
       (ange-ftp-real-insert-directory file switches wildcard full))))
 
 (defun ange-ftp-dired-uncache (dir)
-  (if (ange-ftp-ftp-name (expand-file-name dir)))
-      (setq ange-ftp-ls-cache-file nil))
+  (if (ange-ftp-ftp-name (expand-file-name dir))
+      (setq ange-ftp-ls-cache-file nil)))
 
 (defvar ange-ftp-sans-version-alist nil
   "Alist of mapping host type into function to remove file version numbers.")