From 689c5c20d1174e95be50e674d05632545eb4b9c5 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 10 Jul 2017 17:49:01 +0200 Subject: [PATCH] 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. --- lisp/net/tramp-sh.el | 7 +++++-- lisp/net/tramp.el | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 94518d0d359..4beb6fe5216 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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 diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 945f81188c8..8d7fbc068b8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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. -- 2.39.2