* net/tramp.el (tramp-handle-insert-file-contents): Use "dd"
[bpt/emacs.git] / lisp / net / tramp.el
index 5d0f393..bc831c3 100644 (file)
@@ -1574,8 +1574,12 @@ special handling of `substitute-in-file-name'."
     (let ((props (tramp-compat-funcall
                  'overlay-properties (symbol-value 'rfn-eshadow-overlay))))
       (while props
-       (tramp-compat-funcall
-        'overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props))))))
+       ;; The `field' property prevents correct minibuffer
+       ;; completion; we exclude it.
+       (if (not (eq (car props) 'field))
+           (tramp-compat-funcall
+            'overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props))
+         (pop props) (pop props))))))
 
 (when (boundp 'rfn-eshadow-setup-minibuffer-hook)
   (add-hook 'rfn-eshadow-setup-minibuffer-hook
@@ -2834,16 +2838,16 @@ User is always nil."
                 v
                 (cond
                  ((and beg end)
-                  (format "tail -c +%d %s | head -c +%d >%s"
-                          (1+ beg) (tramp-shell-quote-argument localname)
+                  (format "dd bs=1 skip=%d if=%s count=%d of=%s"
+                          beg (tramp-shell-quote-argument localname)
                           (- end beg) remote-copy))
                  (beg
-                  (format "tail -c +%d %s >%s"
-                          (1+ beg) (tramp-shell-quote-argument localname)
+                  (format "dd bs=1 skip=%d if=%s of=%s"
+                          beg (tramp-shell-quote-argument localname)
                           remote-copy))
                  (end
-                  (format "head -c +%d %s >%s"
-                          (1+ end) (tramp-shell-quote-argument localname)
+                  (format "dd bs=1 count=%d if=%s of=%s"
+                          end (tramp-shell-quote-argument localname)
                           remote-copy)))))
 
              ;; `insert-file-contents-literally' takes care to avoid
@@ -3094,8 +3098,11 @@ The terminal type can be configured with `tramp-terminal-type'."
          (setq found (funcall action proc vec)))))
     found))
 
-(defun tramp-process-actions (proc vec actions &optional timeout)
-  "Perform actions until success or TIMEOUT."
+(defun tramp-process-actions (proc vec pos actions &optional timeout)
+  "Perform ACTIONS until success or TIMEOUT.
+PROC and VEC indicate the remote connection to be used.  POS, if
+set, is the starting point of the region to be deleted in the
+connection buffer."
   ;; Preserve message for `progress-reporter'.
   (tramp-compat-with-temp-message ""
     ;; Enable auth-source and password-cache.
@@ -3120,7 +3127,10 @@ The terminal type can be configured with `tramp-terminal-type'."
           (cond
            ((eq exit 'permission-denied) "Permission denied")
            ((eq exit 'process-died) "Process died")
-           (t "Login failed"))))))))
+           (t "Login failed"))))
+       (when (numberp pos)
+         (with-current-buffer (tramp-get-connection-buffer vec)
+           (let (buffer-read-only) (delete-region pos (point)))))))))
 
 :;; Utility functions:
 
@@ -3526,23 +3536,24 @@ Invokes `password-read' if available, `read-passwd' else."
     (with-parsed-tramp-file-name key nil
       (prog1
          (or
-          ;; See if auth-sources contains something useful, if it's bound.
+          ;; See if auth-sources contains something useful, if it's
+          ;; bound.  `auth-source-user-or-password' is an obsoleted
+          ;; function, it has been replaced by `auth-source-search'.
           (and (boundp 'auth-sources)
                (tramp-get-connection-property v "first-password-request" nil)
                ;; Try with Tramp's current method.
                 (if (fboundp 'auth-source-search)
-                    (progn
-                      (setq auth-info
+                   (setq auth-info
                             (tramp-compat-funcall
                              'auth-source-search
                              :max 1
                              :user (or tramp-current-user t)
                              :host tramp-current-host
-                             :port tramp-current-method))
-                      (setq auth-passwd (plist-get (nth 0 auth-info) :secret))
-                      (setq auth-passwd (if (functionp auth-passwd)
+                             :port tramp-current-method)
+                           auth-passwd (plist-get (nth 0 auth-info) :secret)
+                           auth-passwd (if (functionp auth-passwd)
                                             (funcall auth-passwd)
-                                          auth-passwd)))
+                                          auth-passwd))
                   (tramp-compat-funcall
                    'auth-source-user-or-password
                    "password" tramp-current-host tramp-current-method)))