mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
* 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.
This commit is contained in:
parent
cc593f54d9
commit
f8f91d5d56
5 changed files with 79 additions and 84 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
(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)))
|
||||
|
||||
;; 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 "")))
|
||||
;; 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)))
|
||||
|
||||
;; 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))))
|
||||
;; 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 "")))
|
||||
|
||||
;; 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))
|
||||
;; 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))))
|
||||
|
||||
(goto-char (point-max))))))
|
||||
;; 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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue