Fixes: debbugs:18623

* net/tramp.el (tramp-handle-insert-file-contents):
Set `find-file-not-found-functions' in case of errors.
This commit is contained in:
Michael Albinus 2014-12-21 12:10:31 +01:00
parent 48a9d9fdbb
commit 74d3b20cf5
2 changed files with 108 additions and 101 deletions

View file

@ -1,3 +1,8 @@
2014-12-21 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-handle-insert-file-contents):
Set `find-file-not-found-functions' in case of errors. (Bug#18623)
2014-12-19 Michael Albinus <michael.albinus@gmx.de>
* net/tramp-sh.el (tramp-send-command-and-read): New optional

View file

@ -3086,18 +3086,13 @@ User is always nil."
(setq filename (expand-file-name filename))
(let (result local-copy remote-copy)
(with-parsed-tramp-file-name filename nil
(with-tramp-progress-reporter
v 3 (format "Inserting `%s'" filename)
(unwind-protect
(if (not (file-exists-p filename))
(progn
;; We don't raise a Tramp error, because it might be
;; suppressed, like in `find-file-noselect-1'.
(tramp-message
v 1 "File not `%s' found on remote host" filename)
(signal 'file-error
(list "File not found on remote host" filename)))
(tramp-message v 0 "(New file)")
(with-tramp-progress-reporter
v 3 (format "Inserting `%s'" filename)
(condition-case err
(if (and (tramp-local-host-p v)
(let (file-name-handler-alist)
(file-readable-p localname)))
@ -3113,7 +3108,8 @@ User is always nil."
;; name handlers.
(when (and (or beg end)
(tramp-get-method-parameter
(tramp-file-name-method v) 'tramp-login-program))
(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.
@ -3150,7 +3146,8 @@ User is always nil."
(tramp-make-tramp-file-name
method user host remote-copy)))
((stringp tramp-temp-buffer-file-name)
(copy-file filename tramp-temp-buffer-file-name 'ok)
(copy-file
filename tramp-temp-buffer-file-name 'ok)
tramp-temp-buffer-file-name)
(t (file-local-copy filename)))))
@ -3176,7 +3173,12 @@ User is always nil."
filename local-copy)))
(setq result
(insert-file-contents
local-copy visit beg end replace)))))
local-copy visit beg end replace))))
(error
(add-hook 'find-file-not-found-functions
`(lambda () (signal ',(car err) ',(cdr err)))
nil t)
(signal (car err) (cdr err))))))
;; Save exit.
(progn
@ -3190,11 +3192,11 @@ User is always nil."
(delete-file local-copy))
(when (stringp remote-copy)
(delete-file
(tramp-make-tramp-file-name method user host remote-copy)))))))
(tramp-make-tramp-file-name method user host remote-copy)))))
;; Result.
(list (expand-file-name filename)
(cadr result))))
(cadr result)))))
(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
"Like `load' for Tramp files."