]> code.delx.au - gnu-emacs/commitdiff
* net/tramp.el (tramp-handle-insert-file-contents): Improve handling
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 7 Oct 2013 12:45:20 +0000 (14:45 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 7 Oct 2013 12:45:20 +0000 (14:45 +0200)
of BEG and END.

* net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Use
`tramp-handle-insert-file-contents'.
(tramp-gvfs-handle-insert-file-contents): Remove function.

* net/tramp-sh.el (tramp-sh-handle-insert-directory): Use
`save-restriction' in order to keep markers.

* net/trampver.el: Update release number.

lisp/ChangeLog
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp.el
lisp/net/trampver.el

index 0d9b4b10d6cbc13cf2bb0039ffc0cc941068e521..1cad30c0214aaa912a59982d0457c88fb0ce20d1 100644 (file)
@@ -1,3 +1,17 @@
+2013-10-07  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-handle-insert-file-contents): Improve handling
+       of BEG and END.
+
+       * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Use
+       `tramp-handle-insert-file-contents'.
+       (tramp-gvfs-handle-insert-file-contents): Remove function.
+
+       * net/tramp-sh.el (tramp-sh-handle-insert-directory): Use
+       `save-restriction' in order to keep markers.
+
+       * net/trampver.el: Update release number.
+
 2013-10-07  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * progmodes/compile.el (compilation-parse-errors):
index 8f79e495420a95a21c140f89348665f8d67fdf64..d4b7a89ce35715d7e42d7b11dbd3be58febccf55 100644 (file)
@@ -451,7 +451,7 @@ Every entry is a list (NAME ADDRESS).")
     ;; `find-file-noselect' performed by default handler.
     ;; `get-file-buffer' performed by default handler.
     (insert-directory . tramp-gvfs-handle-insert-directory)
-    (insert-file-contents . tramp-gvfs-handle-insert-file-contents)
+    (insert-file-contents . tramp-handle-insert-file-contents)
     (load . tramp-handle-load)
     (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
     (make-directory . tramp-gvfs-handle-make-directory)
@@ -1014,32 +1014,6 @@ is no information where to trace the message.")
         'insert-directory
         (list filename switches wildcard full-directory-p))))))
 
-(defun tramp-gvfs-handle-insert-file-contents
-  (filename &optional visit beg end replace)
-  "Like `insert-file-contents' for Tramp files."
-  (barf-if-buffer-read-only)
-  (setq filename (expand-file-name filename))
-  (let (tmpfile result)
-    (unwind-protect
-       (if (not (file-exists-p filename))
-           ;; We don't raise a Tramp error, because it might be
-           ;; suppressed, like in `find-file-noselect-1'.
-           (signal 'file-error (list "File not found on remote host" filename))
-
-         (setq tmpfile (file-local-copy filename)
-               result (insert-file-contents tmpfile visit beg end replace)))
-      ;; Save exit.
-      (when visit
-       (setq buffer-file-name filename)
-       (setq buffer-read-only (not (file-writable-p filename)))
-       (set-visited-file-modtime)
-       (set-buffer-modified-p nil))
-      (when (stringp tmpfile)
-       (delete-file tmpfile)))
-
-    ;; Result.
-    (list filename (cadr result))))
-
 (defun tramp-gvfs-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
   (with-parsed-tramp-file-name dir nil
index 4bc836b88d52ca11938cf542084eec022076c358..8ed1c592617ce2b214dedc7aeeb8ee42a09f363b 100644 (file)
@@ -2544,61 +2544,64 @@ This is like `dired-recursive-delete-directory' for Tramp files."
                   (tramp-shell-quote-argument
                    (tramp-run-real-handler
                     'file-name-nondirectory (list localname)))))))
-      (let ((beg (point)))
-       ;; We cannot use `insert-buffer-substring' because the Tramp
-       ;; buffer changes its contents before insertion due to calling
-       ;; `expand-file' and alike.
-       (insert
-        (with-current-buffer (tramp-get-buffer v)
-          (buffer-string)))
-
-       ;; Check for "--dired" output.
-       (forward-line -2)
-       (when (looking-at "//SUBDIRED//")
-         (forward-line -1))
-       (when (looking-at "//DIRED//\\s-+")
-         (let ((databeg (match-end 0))
-               (end (point-at-eol)))
-           ;; Now read the numeric positions of file names.
-           (goto-char databeg)
-           (while (< (point) end)
-             (let ((start (+ beg (read (current-buffer))))
-                   (end (+ beg (read (current-buffer)))))
-               (if (memq (char-after end) '(?\n ?\ ))
-                   ;; End is followed by \n or by " -> ".
-                   (put-text-property start end 'dired-filename t))))))
-       ;; Remove trailing lines.
-       (goto-char (point-at-bol))
-       (while (looking-at "//")
-         (forward-line 1)
-         (delete-region (match-beginning 0) (point)))
-
-       ;; Some busyboxes are reluctant to discard colors.
-       (unless (string-match "color" (tramp-get-connection-property v "ls" ""))
-         (goto-char beg)
-         (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
-           (replace-match "")))
-
-       ;; Decode the output, it could be multibyte.
-       (decode-coding-region
-        beg (point-max)
-        (or file-name-coding-system
-            (and (boundp 'default-file-name-coding-system)
-                 (symbol-value 'default-file-name-coding-system))))
-
-       ;; The inserted file could be from somewhere else.
-       (when (and (not wildcard) (not full-directory-p))
-         (goto-char (point-max))
-         (when (file-symlink-p filename)
-           (goto-char (search-backward "->" beg 'noerror)))
-         (search-backward
-          (if (zerop (length (file-name-nondirectory filename)))
-              "."
-            (file-name-nondirectory filename))
-          beg 'noerror)
-         (replace-match (file-relative-name filename) t))
-
-       (goto-char (point-max))))))
+
+      (save-restriction
+       (let ((beg (point)))
+         (narrow-to-region (point) (point))
+         ;; We cannot use `insert-buffer-substring' because the Tramp
+         ;; buffer changes its contents before insertion due to calling
+         ;; `expand-file' and alike.
+         (insert
+          (with-current-buffer (tramp-get-buffer v)
+            (buffer-string)))
+
+         ;; Check for "--dired" output.
+         (forward-line -2)
+         (when (looking-at "//SUBDIRED//")
+           (forward-line -1))
+         (when (looking-at "//DIRED//\\s-+")
+           (let ((databeg (match-end 0))
+                 (end (point-at-eol)))
+             ;; Now read the numeric positions of file names.
+             (goto-char databeg)
+             (while (< (point) end)
+               (let ((start (+ beg (read (current-buffer))))
+                     (end (+ beg (read (current-buffer)))))
+                 (if (memq (char-after end) '(?\n ?\ ))
+                     ;; End is followed by \n or by " -> ".
+                     (put-text-property start end 'dired-filename t))))))
+         ;; Remove trailing lines.
+         (goto-char (point-at-bol))
+         (while (looking-at "//")
+           (forward-line 1)
+           (delete-region (match-beginning 0) (point)))
+
+         ;; Some busyboxes are reluctant to discard colors.
+         (unless (string-match "color" (tramp-get-connection-property v "ls" ""))
+           (goto-char beg)
+           (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
+             (replace-match "")))
+
+         ;; Decode the output, it could be multibyte.
+         (decode-coding-region
+          beg (point-max)
+          (or file-name-coding-system
+              (and (boundp 'default-file-name-coding-system)
+                   (symbol-value 'default-file-name-coding-system))))
+
+         ;; The inserted file could be from somewhere else.
+         (when (and (not wildcard) (not full-directory-p))
+           (goto-char (point-max))
+           (when (file-symlink-p filename)
+             (goto-char (search-backward "->" beg 'noerror)))
+           (search-backward
+            (if (zerop (length (file-name-nondirectory filename)))
+                "."
+              (file-name-nondirectory filename))
+            beg 'noerror)
+           (replace-match (file-relative-name filename) t))
+
+         (goto-char (point-max)))))))
 
 ;; Canonicalization of file names.
 
index 48420aad5a3289791e46023f555f2d449330f9d1..c5d728ba5c71b8e5d8443d50db3a4ae3ea68d4f1 100644 (file)
@@ -3030,8 +3030,11 @@ User is always nil."
                         (list localname visit beg end replace)))
 
                ;; When we shall insert only a part of the file, we
-               ;; copy this part.
-               (when (or beg end)
+               ;; copy this part.  This works only for the shell file
+               ;; name handlers.
+               (when (and (or beg end)
+                          (tramp-get-method-parameter
+                           (tramp-file-name-method v) 'tramp-login-program))
                  (setq remote-copy (tramp-make-tramp-temp-file v))
                  ;; This is defined in tramp-sh.el.  Let's assume
                  ;; this is loaded already.
@@ -3050,7 +3053,8 @@ User is always nil."
                    (end
                     (format "dd bs=1 count=%d if=%s of=%s"
                             end (tramp-shell-quote-argument localname)
-                            remote-copy)))))
+                            remote-copy))))
+                 (setq tramp-temp-buffer-file-name nil beg nil end nil))
 
                ;; `insert-file-contents-literally' takes care to
                ;; avoid calling jka-compr.  By let-binding
@@ -3093,7 +3097,7 @@ User is always nil."
                        filename local-copy)))
                  (setq result
                        (insert-file-contents
-                        local-copy visit nil nil replace)))))
+                        local-copy visit beg end replace)))))
 
          ;; Save exit.
          (progn
@@ -3846,7 +3850,7 @@ be granted."
      (stringp host)
      (string-match tramp-local-host-regexp host)
      ;; The method shall be applied to one of the shell file name
-     ;; handler.  `tramp-local-host-p' is also called for "smb" and
+     ;; handlers.  `tramp-local-host-p' is also called for "smb" and
      ;; alike, where it must fail.
      (tramp-get-method-parameter
       (tramp-file-name-method vec) 'tramp-login-program)
index 8fc05872ca15706d6ecb6d7947c409361161c832..1986da8a94b59797b7e517b5812094a032c06bc3 100644 (file)
@@ -31,7 +31,7 @@
 ;; should be changed only there.
 
 ;;;###tramp-autoload
-(defconst tramp-version "2.2.8"
+(defconst tramp-version "2.2.9-pre"
   "This version of Tramp.")
 
 ;;;###tramp-autoload
@@ -44,7 +44,7 @@
                      (= emacs-major-version 21)
                      (>= emacs-minor-version 4)))
             "ok"
-          (format "Tramp 2.2.8 is not fit for %s"
+          (format "Tramp 2.2.9-pre is not fit for %s"
                   (when (string-match "^.*$" (emacs-version))
                     (match-string 0 (emacs-version)))))))
   (unless (string-match "\\`ok\\'" x) (error "%s" x)))