diff options
| author | Michael Albinus | 2013-10-07 14:45:20 +0200 |
|---|---|---|
| committer | Michael Albinus | 2013-10-07 14:45:20 +0200 |
| commit | f8f91d5d560aa64b7a4e5086eea4903a462afa68 (patch) | |
| tree | c877d6aba237a079a5abd6148390fc5fbeecbc02 | |
| parent | cc593f54d9db1ca94dcafba5aaa18784123a666b (diff) | |
| download | emacs-f8f91d5d560aa64b7a4e5086eea4903a462afa68.tar.gz emacs-f8f91d5d560aa64b7a4e5086eea4903a462afa68.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 28 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 113 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 14 | ||||
| -rw-r--r-- | lisp/net/trampver.el | 4 |
5 files changed, 84 insertions, 89 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0d9b4b10d6c..1cad30c0214 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2013-10-07 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (tramp-handle-insert-file-contents): Improve handling | ||
| 4 | of BEG and END. | ||
| 5 | |||
| 6 | * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Use | ||
| 7 | `tramp-handle-insert-file-contents'. | ||
| 8 | (tramp-gvfs-handle-insert-file-contents): Remove function. | ||
| 9 | |||
| 10 | * net/tramp-sh.el (tramp-sh-handle-insert-directory): Use | ||
| 11 | `save-restriction' in order to keep markers. | ||
| 12 | |||
| 13 | * net/trampver.el: Update release number. | ||
| 14 | |||
| 1 | 2013-10-07 Stefan Monnier <monnier@iro.umontreal.ca> | 15 | 2013-10-07 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 16 | ||
| 3 | * progmodes/compile.el (compilation-parse-errors): | 17 | * progmodes/compile.el (compilation-parse-errors): |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 8f79e495420..d4b7a89ce35 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -451,7 +451,7 @@ Every entry is a list (NAME ADDRESS).") | |||
| 451 | ;; `find-file-noselect' performed by default handler. | 451 | ;; `find-file-noselect' performed by default handler. |
| 452 | ;; `get-file-buffer' performed by default handler. | 452 | ;; `get-file-buffer' performed by default handler. |
| 453 | (insert-directory . tramp-gvfs-handle-insert-directory) | 453 | (insert-directory . tramp-gvfs-handle-insert-directory) |
| 454 | (insert-file-contents . tramp-gvfs-handle-insert-file-contents) | 454 | (insert-file-contents . tramp-handle-insert-file-contents) |
| 455 | (load . tramp-handle-load) | 455 | (load . tramp-handle-load) |
| 456 | (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) | 456 | (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) |
| 457 | (make-directory . tramp-gvfs-handle-make-directory) | 457 | (make-directory . tramp-gvfs-handle-make-directory) |
| @@ -1014,32 +1014,6 @@ is no information where to trace the message.") | |||
| 1014 | 'insert-directory | 1014 | 'insert-directory |
| 1015 | (list filename switches wildcard full-directory-p)))))) | 1015 | (list filename switches wildcard full-directory-p)))))) |
| 1016 | 1016 | ||
| 1017 | (defun tramp-gvfs-handle-insert-file-contents | ||
| 1018 | (filename &optional visit beg end replace) | ||
| 1019 | "Like `insert-file-contents' for Tramp files." | ||
| 1020 | (barf-if-buffer-read-only) | ||
| 1021 | (setq filename (expand-file-name filename)) | ||
| 1022 | (let (tmpfile result) | ||
| 1023 | (unwind-protect | ||
| 1024 | (if (not (file-exists-p filename)) | ||
| 1025 | ;; We don't raise a Tramp error, because it might be | ||
| 1026 | ;; suppressed, like in `find-file-noselect-1'. | ||
| 1027 | (signal 'file-error (list "File not found on remote host" filename)) | ||
| 1028 | |||
| 1029 | (setq tmpfile (file-local-copy filename) | ||
| 1030 | result (insert-file-contents tmpfile visit beg end replace))) | ||
| 1031 | ;; Save exit. | ||
| 1032 | (when visit | ||
| 1033 | (setq buffer-file-name filename) | ||
| 1034 | (setq buffer-read-only (not (file-writable-p filename))) | ||
| 1035 | (set-visited-file-modtime) | ||
| 1036 | (set-buffer-modified-p nil)) | ||
| 1037 | (when (stringp tmpfile) | ||
| 1038 | (delete-file tmpfile))) | ||
| 1039 | |||
| 1040 | ;; Result. | ||
| 1041 | (list filename (cadr result)))) | ||
| 1042 | |||
| 1043 | (defun tramp-gvfs-handle-make-directory (dir &optional parents) | 1017 | (defun tramp-gvfs-handle-make-directory (dir &optional parents) |
| 1044 | "Like `make-directory' for Tramp files." | 1018 | "Like `make-directory' for Tramp files." |
| 1045 | (with-parsed-tramp-file-name dir nil | 1019 | (with-parsed-tramp-file-name dir nil |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4bc836b88d5..8ed1c592617 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2544,61 +2544,64 @@ This is like `dired-recursive-delete-directory' for Tramp files." | |||
| 2544 | (tramp-shell-quote-argument | 2544 | (tramp-shell-quote-argument |
| 2545 | (tramp-run-real-handler | 2545 | (tramp-run-real-handler |
| 2546 | 'file-name-nondirectory (list localname))))))) | 2546 | 'file-name-nondirectory (list localname))))))) |
| 2547 | (let ((beg (point))) | 2547 | |
| 2548 | ;; We cannot use `insert-buffer-substring' because the Tramp | 2548 | (save-restriction |
| 2549 | ;; buffer changes its contents before insertion due to calling | 2549 | (let ((beg (point))) |
| 2550 | ;; `expand-file' and alike. | 2550 | (narrow-to-region (point) (point)) |
| 2551 | (insert | 2551 | ;; We cannot use `insert-buffer-substring' because the Tramp |
| 2552 | (with-current-buffer (tramp-get-buffer v) | 2552 | ;; buffer changes its contents before insertion due to calling |
| 2553 | (buffer-string))) | 2553 | ;; `expand-file' and alike. |
| 2554 | 2554 | (insert | |
| 2555 | ;; Check for "--dired" output. | 2555 | (with-current-buffer (tramp-get-buffer v) |
| 2556 | (forward-line -2) | 2556 | (buffer-string))) |
| 2557 | (when (looking-at "//SUBDIRED//") | 2557 | |
| 2558 | (forward-line -1)) | 2558 | ;; Check for "--dired" output. |
| 2559 | (when (looking-at "//DIRED//\\s-+") | 2559 | (forward-line -2) |
| 2560 | (let ((databeg (match-end 0)) | 2560 | (when (looking-at "//SUBDIRED//") |
| 2561 | (end (point-at-eol))) | 2561 | (forward-line -1)) |
| 2562 | ;; Now read the numeric positions of file names. | 2562 | (when (looking-at "//DIRED//\\s-+") |
| 2563 | (goto-char databeg) | 2563 | (let ((databeg (match-end 0)) |
| 2564 | (while (< (point) end) | 2564 | (end (point-at-eol))) |
| 2565 | (let ((start (+ beg (read (current-buffer)))) | 2565 | ;; Now read the numeric positions of file names. |
| 2566 | (end (+ beg (read (current-buffer))))) | 2566 | (goto-char databeg) |
| 2567 | (if (memq (char-after end) '(?\n ?\ )) | 2567 | (while (< (point) end) |
| 2568 | ;; End is followed by \n or by " -> ". | 2568 | (let ((start (+ beg (read (current-buffer)))) |
| 2569 | (put-text-property start end 'dired-filename t)))))) | 2569 | (end (+ beg (read (current-buffer))))) |
| 2570 | ;; Remove trailing lines. | 2570 | (if (memq (char-after end) '(?\n ?\ )) |
| 2571 | (goto-char (point-at-bol)) | 2571 | ;; End is followed by \n or by " -> ". |
| 2572 | (while (looking-at "//") | 2572 | (put-text-property start end 'dired-filename t)))))) |
| 2573 | (forward-line 1) | 2573 | ;; Remove trailing lines. |
| 2574 | (delete-region (match-beginning 0) (point))) | 2574 | (goto-char (point-at-bol)) |
| 2575 | 2575 | (while (looking-at "//") | |
| 2576 | ;; Some busyboxes are reluctant to discard colors. | 2576 | (forward-line 1) |
| 2577 | (unless (string-match "color" (tramp-get-connection-property v "ls" "")) | 2577 | (delete-region (match-beginning 0) (point))) |
| 2578 | (goto-char beg) | 2578 | |
| 2579 | (while (re-search-forward tramp-color-escape-sequence-regexp nil t) | 2579 | ;; Some busyboxes are reluctant to discard colors. |
| 2580 | (replace-match ""))) | 2580 | (unless (string-match "color" (tramp-get-connection-property v "ls" "")) |
| 2581 | 2581 | (goto-char beg) | |
| 2582 | ;; Decode the output, it could be multibyte. | 2582 | (while (re-search-forward tramp-color-escape-sequence-regexp nil t) |
| 2583 | (decode-coding-region | 2583 | (replace-match ""))) |
| 2584 | beg (point-max) | 2584 | |
| 2585 | (or file-name-coding-system | 2585 | ;; Decode the output, it could be multibyte. |
| 2586 | (and (boundp 'default-file-name-coding-system) | 2586 | (decode-coding-region |
| 2587 | (symbol-value 'default-file-name-coding-system)))) | 2587 | beg (point-max) |
| 2588 | 2588 | (or file-name-coding-system | |
| 2589 | ;; The inserted file could be from somewhere else. | 2589 | (and (boundp 'default-file-name-coding-system) |
| 2590 | (when (and (not wildcard) (not full-directory-p)) | 2590 | (symbol-value 'default-file-name-coding-system)))) |
| 2591 | (goto-char (point-max)) | 2591 | |
| 2592 | (when (file-symlink-p filename) | 2592 | ;; The inserted file could be from somewhere else. |
| 2593 | (goto-char (search-backward "->" beg 'noerror))) | 2593 | (when (and (not wildcard) (not full-directory-p)) |
| 2594 | (search-backward | 2594 | (goto-char (point-max)) |
| 2595 | (if (zerop (length (file-name-nondirectory filename))) | 2595 | (when (file-symlink-p filename) |
| 2596 | "." | 2596 | (goto-char (search-backward "->" beg 'noerror))) |
| 2597 | (file-name-nondirectory filename)) | 2597 | (search-backward |
| 2598 | beg 'noerror) | 2598 | (if (zerop (length (file-name-nondirectory filename))) |
| 2599 | (replace-match (file-relative-name filename) t)) | 2599 | "." |
| 2600 | 2600 | (file-name-nondirectory filename)) | |
| 2601 | (goto-char (point-max)))))) | 2601 | beg 'noerror) |
| 2602 | (replace-match (file-relative-name filename) t)) | ||
| 2603 | |||
| 2604 | (goto-char (point-max))))))) | ||
| 2602 | 2605 | ||
| 2603 | ;; Canonicalization of file names. | 2606 | ;; Canonicalization of file names. |
| 2604 | 2607 | ||
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 48420aad5a3..c5d728ba5c7 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3030,8 +3030,11 @@ User is always nil." | |||
| 3030 | (list localname visit beg end replace))) | 3030 | (list localname visit beg end replace))) |
| 3031 | 3031 | ||
| 3032 | ;; When we shall insert only a part of the file, we | 3032 | ;; When we shall insert only a part of the file, we |
| 3033 | ;; copy this part. | 3033 | ;; copy this part. This works only for the shell file |
| 3034 | (when (or beg end) | 3034 | ;; name handlers. |
| 3035 | (when (and (or beg end) | ||
| 3036 | (tramp-get-method-parameter | ||
| 3037 | (tramp-file-name-method v) 'tramp-login-program)) | ||
| 3035 | (setq remote-copy (tramp-make-tramp-temp-file v)) | 3038 | (setq remote-copy (tramp-make-tramp-temp-file v)) |
| 3036 | ;; This is defined in tramp-sh.el. Let's assume | 3039 | ;; This is defined in tramp-sh.el. Let's assume |
| 3037 | ;; this is loaded already. | 3040 | ;; this is loaded already. |
| @@ -3050,7 +3053,8 @@ User is always nil." | |||
| 3050 | (end | 3053 | (end |
| 3051 | (format "dd bs=1 count=%d if=%s of=%s" | 3054 | (format "dd bs=1 count=%d if=%s of=%s" |
| 3052 | end (tramp-shell-quote-argument localname) | 3055 | end (tramp-shell-quote-argument localname) |
| 3053 | remote-copy))))) | 3056 | remote-copy)))) |
| 3057 | (setq tramp-temp-buffer-file-name nil beg nil end nil)) | ||
| 3054 | 3058 | ||
| 3055 | ;; `insert-file-contents-literally' takes care to | 3059 | ;; `insert-file-contents-literally' takes care to |
| 3056 | ;; avoid calling jka-compr. By let-binding | 3060 | ;; avoid calling jka-compr. By let-binding |
| @@ -3093,7 +3097,7 @@ User is always nil." | |||
| 3093 | filename local-copy))) | 3097 | filename local-copy))) |
| 3094 | (setq result | 3098 | (setq result |
| 3095 | (insert-file-contents | 3099 | (insert-file-contents |
| 3096 | local-copy visit nil nil replace))))) | 3100 | local-copy visit beg end replace))))) |
| 3097 | 3101 | ||
| 3098 | ;; Save exit. | 3102 | ;; Save exit. |
| 3099 | (progn | 3103 | (progn |
| @@ -3846,7 +3850,7 @@ be granted." | |||
| 3846 | (stringp host) | 3850 | (stringp host) |
| 3847 | (string-match tramp-local-host-regexp host) | 3851 | (string-match tramp-local-host-regexp host) |
| 3848 | ;; The method shall be applied to one of the shell file name | 3852 | ;; The method shall be applied to one of the shell file name |
| 3849 | ;; handler. `tramp-local-host-p' is also called for "smb" and | 3853 | ;; handlers. `tramp-local-host-p' is also called for "smb" and |
| 3850 | ;; alike, where it must fail. | 3854 | ;; alike, where it must fail. |
| 3851 | (tramp-get-method-parameter | 3855 | (tramp-get-method-parameter |
| 3852 | (tramp-file-name-method vec) 'tramp-login-program) | 3856 | (tramp-file-name-method vec) 'tramp-login-program) |
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index 8fc05872ca1..1986da8a94b 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | ;; should be changed only there. | 31 | ;; should be changed only there. |
| 32 | 32 | ||
| 33 | ;;;###tramp-autoload | 33 | ;;;###tramp-autoload |
| 34 | (defconst tramp-version "2.2.8" | 34 | (defconst tramp-version "2.2.9-pre" |
| 35 | "This version of Tramp.") | 35 | "This version of Tramp.") |
| 36 | 36 | ||
| 37 | ;;;###tramp-autoload | 37 | ;;;###tramp-autoload |
| @@ -44,7 +44,7 @@ | |||
| 44 | (= emacs-major-version 21) | 44 | (= emacs-major-version 21) |
| 45 | (>= emacs-minor-version 4))) | 45 | (>= emacs-minor-version 4))) |
| 46 | "ok" | 46 | "ok" |
| 47 | (format "Tramp 2.2.8 is not fit for %s" | 47 | (format "Tramp 2.2.9-pre is not fit for %s" |
| 48 | (when (string-match "^.*$" (emacs-version)) | 48 | (when (string-match "^.*$" (emacs-version)) |
| 49 | (match-string 0 (emacs-version))))))) | 49 | (match-string 0 (emacs-version))))))) |
| 50 | (unless (string-match "\\`ok\\'" x) (error "%s" x))) | 50 | (unless (string-match "\\`ok\\'" x) (error "%s" x))) |