Commit f8f91d5d authored by Michael Albinus's avatar Michael Albinus
Browse files

* 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.
parent cc593f54
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> 2013-10-07 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/compile.el (compilation-parse-errors): * progmodes/compile.el (compilation-parse-errors):
......
...@@ -451,7 +451,7 @@ Every entry is a list (NAME ADDRESS).") ...@@ -451,7 +451,7 @@ Every entry is a list (NAME ADDRESS).")
;; `find-file-noselect' performed by default handler. ;; `find-file-noselect' performed by default handler.
;; `get-file-buffer' performed by default handler. ;; `get-file-buffer' performed by default handler.
(insert-directory . tramp-gvfs-handle-insert-directory) (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) (load . tramp-handle-load)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name) (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-gvfs-handle-make-directory) (make-directory . tramp-gvfs-handle-make-directory)
...@@ -1014,32 +1014,6 @@ is no information where to trace the message.") ...@@ -1014,32 +1014,6 @@ is no information where to trace the message.")
'insert-directory 'insert-directory
(list filename switches wildcard full-directory-p)))))) (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) (defun tramp-gvfs-handle-make-directory (dir &optional parents)
"Like `make-directory' for Tramp files." "Like `make-directory' for Tramp files."
(with-parsed-tramp-file-name dir nil (with-parsed-tramp-file-name dir nil
......
...@@ -2544,61 +2544,64 @@ This is like `dired-recursive-delete-directory' for Tramp files." ...@@ -2544,61 +2544,64 @@ This is like `dired-recursive-delete-directory' for Tramp files."
(tramp-shell-quote-argument (tramp-shell-quote-argument
(tramp-run-real-handler (tramp-run-real-handler
'file-name-nondirectory (list localname))))))) 'file-name-nondirectory (list localname)))))))
(let ((beg (point)))
;; We cannot use `insert-buffer-substring' because the Tramp (save-restriction
;; buffer changes its contents before insertion due to calling (let ((beg (point)))
;; `expand-file' and alike. (narrow-to-region (point) (point))
(insert ;; We cannot use `insert-buffer-substring' because the Tramp
(with-current-buffer (tramp-get-buffer v) ;; buffer changes its contents before insertion due to calling
(buffer-string))) ;; `expand-file' and alike.
(insert
;; Check for "--dired" output. (with-current-buffer (tramp-get-buffer v)
(forward-line -2) (buffer-string)))
(when (looking-at "//SUBDIRED//")
(forward-line -1)) ;; Check for "--dired" output.
(when (looking-at "//DIRED//\\s-+") (forward-line -2)
(let ((databeg (match-end 0)) (when (looking-at "//SUBDIRED//")
(end (point-at-eol))) (forward-line -1))
;; Now read the numeric positions of file names. (when (looking-at "//DIRED//\\s-+")
(goto-char databeg) (let ((databeg (match-end 0))
(while (< (point) end) (end (point-at-eol)))
(let ((start (+ beg (read (current-buffer)))) ;; Now read the numeric positions of file names.
(end (+ beg (read (current-buffer))))) (goto-char databeg)
(if (memq (char-after end) '(?\n ?\ )) (while (< (point) end)
;; End is followed by \n or by " -> ". (let ((start (+ beg (read (current-buffer))))
(put-text-property start end 'dired-filename t)))))) (end (+ beg (read (current-buffer)))))
;; Remove trailing lines. (if (memq (char-after end) '(?\n ?\ ))
(goto-char (point-at-bol)) ;; End is followed by \n or by " -> ".
(while (looking-at "//") (put-text-property start end 'dired-filename t))))))
(forward-line 1) ;; Remove trailing lines.
(delete-region (match-beginning 0) (point))) (goto-char (point-at-bol))
(while (looking-at "//")
;; Some busyboxes are reluctant to discard colors. (forward-line 1)
(unless (string-match "color" (tramp-get-connection-property v "ls" "")) (delete-region (match-beginning 0) (point)))
(goto-char beg)
(while (re-search-forward tramp-color-escape-sequence-regexp nil t) ;; Some busyboxes are reluctant to discard colors.
(replace-match ""))) (unless (string-match "color" (tramp-get-connection-property v "ls" ""))
(goto-char beg)
;; Decode the output, it could be multibyte. (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
(decode-coding-region (replace-match "")))
beg (point-max)
(or file-name-coding-system ;; Decode the output, it could be multibyte.
(and (boundp 'default-file-name-coding-system) (decode-coding-region
(symbol-value 'default-file-name-coding-system)))) beg (point-max)
(or file-name-coding-system
;; The inserted file could be from somewhere else. (and (boundp 'default-file-name-coding-system)
(when (and (not wildcard) (not full-directory-p)) (symbol-value 'default-file-name-coding-system))))
(goto-char (point-max))
(when (file-symlink-p filename) ;; The inserted file could be from somewhere else.
(goto-char (search-backward "->" beg 'noerror))) (when (and (not wildcard) (not full-directory-p))
(search-backward (goto-char (point-max))
(if (zerop (length (file-name-nondirectory filename))) (when (file-symlink-p filename)
"." (goto-char (search-backward "->" beg 'noerror)))
(file-name-nondirectory filename)) (search-backward
beg 'noerror) (if (zerop (length (file-name-nondirectory filename)))
(replace-match (file-relative-name filename) t)) "."
(file-name-nondirectory filename))
(goto-char (point-max)))))) beg 'noerror)
(replace-match (file-relative-name filename) t))
(goto-char (point-max)))))))
;; Canonicalization of file names. ;; Canonicalization of file names.
......
...@@ -3030,8 +3030,11 @@ User is always nil." ...@@ -3030,8 +3030,11 @@ User is always nil."
(list localname visit beg end replace))) (list localname visit beg end replace)))
;; When we shall insert only a part of the file, we ;; When we shall insert only a part of the file, we
;; copy this part. ;; copy this part. This works only for the shell file
(when (or beg end) ;; 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)) (setq remote-copy (tramp-make-tramp-temp-file v))
;; This is defined in tramp-sh.el. Let's assume ;; This is defined in tramp-sh.el. Let's assume
;; this is loaded already. ;; this is loaded already.
...@@ -3050,7 +3053,8 @@ User is always nil." ...@@ -3050,7 +3053,8 @@ User is always nil."
(end (end
(format "dd bs=1 count=%d if=%s of=%s" (format "dd bs=1 count=%d if=%s of=%s"
end (tramp-shell-quote-argument localname) 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 ;; `insert-file-contents-literally' takes care to
;; avoid calling jka-compr. By let-binding ;; avoid calling jka-compr. By let-binding
...@@ -3093,7 +3097,7 @@ User is always nil." ...@@ -3093,7 +3097,7 @@ User is always nil."
filename local-copy))) filename local-copy)))
(setq result (setq result
(insert-file-contents (insert-file-contents
local-copy visit nil nil replace))))) local-copy visit beg end replace)))))
;; Save exit. ;; Save exit.
(progn (progn
...@@ -3846,7 +3850,7 @@ be granted." ...@@ -3846,7 +3850,7 @@ be granted."
(stringp host) (stringp host)
(string-match tramp-local-host-regexp host) (string-match tramp-local-host-regexp host)
;; The method shall be applied to one of the shell file name ;; 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. ;; alike, where it must fail.
(tramp-get-method-parameter (tramp-get-method-parameter
(tramp-file-name-method vec) 'tramp-login-program) (tramp-file-name-method vec) 'tramp-login-program)
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
;; should be changed only there. ;; should be changed only there.
;;;###tramp-autoload ;;;###tramp-autoload
(defconst tramp-version "2.2.8" (defconst tramp-version "2.2.9-pre"
"This version of Tramp.") "This version of Tramp.")
;;;###tramp-autoload ;;;###tramp-autoload
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
(= emacs-major-version 21) (= emacs-major-version 21)
(>= emacs-minor-version 4))) (>= emacs-minor-version 4)))
"ok" "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)) (when (string-match "^.*$" (emacs-version))
(match-string 0 (emacs-version))))))) (match-string 0 (emacs-version)))))))
(unless (string-match "\\`ok\\'" x) (error "%s" x))) (unless (string-match "\\`ok\\'" x) (error "%s" x)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment