emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114554: * net/tramp.el (tramp-handle-insert-file-co


From: Michael Albinus
Subject: [Emacs-diffs] trunk r114554: * net/tramp.el (tramp-handle-insert-file-contents): Improve handling
Date: Mon, 07 Oct 2013 12:45:28 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114554
revision-id: address@hidden
parent: address@hidden
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Mon 2013-10-07 14:45:20 +0200
message:
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/tramp-gvfs.el         
trampgvfs.el-20091113204419-o5vbwnq5f7feedwu-10898
  lisp/net/tramp-sh.el           trampsh.el-20100913133439-a1faifh29eqoi4nh-1
  lisp/net/tramp.el              tramp.el-20091113204419-o5vbwnq5f7feedwu-2427
  lisp/net/trampver.el           
trampver.el-20091113204419-o5vbwnq5f7feedwu-2564
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-10-07 05:15:48 +0000
+++ b/lisp/ChangeLog    2013-10-07 12:45:20 +0000
@@ -1,3 +1,17 @@
+2013-10-07  Michael Albinus  <address@hidden>
+
+       * 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  <address@hidden>
 
        * progmodes/compile.el (compilation-parse-errors):

=== modified file 'lisp/net/tramp-gvfs.el'
--- a/lisp/net/tramp-gvfs.el    2013-09-13 06:03:06 +0000
+++ b/lisp/net/tramp-gvfs.el    2013-10-07 12:45:20 +0000
@@ -451,7 +451,7 @@
     ;; `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 @@
         '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

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2013-09-19 19:14:26 +0000
+++ b/lisp/net/tramp-sh.el      2013-10-07 12:45:20 +0000
@@ -2544,61 +2544,64 @@
                   (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.
 

=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2013-09-13 06:03:06 +0000
+++ b/lisp/net/tramp.el 2013-10-07 12:45:20 +0000
@@ -3030,8 +3030,11 @@
                         (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 @@
                    (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 @@
                        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 @@
      (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)

=== modified file 'lisp/net/trampver.el'
--- a/lisp/net/trampver.el      2013-10-02 13:48:20 +0000
+++ b/lisp/net/trampver.el      2013-10-07 12:45:20 +0000
@@ -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)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]