Use `with-demoted-errors' in Tramp

* lisp/net/tramp.el (tramp-with-demoted-errors): New defmacro.

* lisp/net/tramp-sh.el (tramp-sh-handle-vc-registered): Use it.
This commit is contained in:
Michael Albinus 2017-07-10 17:49:01 +02:00
parent 0440c748aa
commit 689c5c20d1
2 changed files with 17 additions and 2 deletions

View file

@ -3432,7 +3432,9 @@ the result will be a local, non-Tramp, file name."
`((,(tramp-file-name-regexp) . tramp-vc-file-name-handler))))
;; Here we collect only file names, which need an operation.
(ignore-errors (tramp-run-real-handler 'vc-registered (list file)))
(tramp-with-demoted-errors
v "Error in 1st pass of `vc-registered': %s"
(tramp-run-real-handler 'vc-registered (list file)))
(tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
;; Send just one command, in order to fill the cache.
@ -3493,7 +3495,8 @@ the result will be a local, non-Tramp, file name."
v vc-hg-program (tramp-get-remote-path v)))))
(setq vc-handled-backends (remq 'Hg vc-handled-backends)))
;; Run.
(ignore-errors
(tramp-with-demoted-errors
v "Error in 2nd pass of `vc-registered': %s"
(tramp-run-real-handler 'vc-registered (list file))))))))
;;;###tramp-autoload

View file

@ -1641,6 +1641,18 @@ an input event arrives. The other arguments are passed to `tramp-error'."
(when (tramp-file-name-equal-p vec (car tramp-current-connection))
(setcdr tramp-current-connection (current-time)))))))
(defmacro tramp-with-demoted-errors (vec-or-proc format &rest body)
"Execute BODY while redirecting the error message to `tramp-message'.
BODY is executed like wrapped by `with-demoted-errors'. FORMAT
is a format-string containing a %-sequence meaning to substitute
the resulting error message."
(declare (debug (symbolp body))
(indent 2))
(let ((err (make-symbol "err")))
`(condition-case-unless-debug ,err
(progn ,@body)
(error (tramp-message ,vec-or-proc 3 ,format ,err) nil))))
(defmacro with-parsed-tramp-file-name (filename var &rest body)
"Parse a Tramp filename and make components available in the body.