[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/handler-bind-2 5a3ed126ccc 14/16: tramp.el: Use `handler-bind` i
From: |
Stefan Monnier |
Subject: |
scratch/handler-bind-2 5a3ed126ccc 14/16: tramp.el: Use `handler-bind` instead of `signal-hook-function` |
Date: |
Wed, 27 Dec 2023 23:53:31 -0500 (EST) |
branch: scratch/handler-bind-2
commit 5a3ed126ccc6b8bdeb6ec9958509cfdbe93ef382
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
tramp.el: Use `handler-bind` instead of `signal-hook-function`
* lisp/net/tramp.el (tramp--trace-errors): Rename from
`tramp-signal-hook-function` and change calling convention for
`handler-bind`.
(tramp-unknown-id-string, tramp-unknown-id-integer):
Don't use `defconst` for vars which we let-bind (in tramp-tests.el).
(tramp-file-name-handler): Use `handler-bind` instead of let-binding
`signal-hook-function`.
(tramp-handle-lock-file, tramp-handle-load, tramp-add-hops)
(tramp-run-real-handler):
* lisp/net/tramp-sshfs.el (tramp-sshfs-handle-insert-file-contents):
* lisp/net/tramp-sh.el (tramp-sh-get-signal-strings):
(tramp-send-command-and-read):
* lisp/net/tramp-message.el (tramp-debug-message, tramp-error):
* lisp/net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls): Don't
let-bind `signal-hook-function`.
---
lisp/net/tramp-adb.el | 4 +---
lisp/net/tramp-message.el | 5 ++---
lisp/net/tramp-sh.el | 15 ++++++---------
lisp/net/tramp-sshfs.el | 2 +-
lisp/net/tramp.el | 30 ++++++++++++++----------------
5 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index e4d3ba8c74b..0b68e7384b2 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -297,9 +297,7 @@ arguments to pass to the OPERATION."
(cons uid tramp-unknown-id-integer)
(cons gid tramp-unknown-id-integer)
tramp-time-dont-know ; atime
- ;; `date-to-time' checks `iso8601-parse', which might fail.
- (let (signal-hook-function)
- (date-to-time date)) ; mtime
+ (date-to-time date) ; mtime
tramp-time-dont-know ; ctime
size
mod-string
diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el
index e05357f1f4f..924f4d15ad2 100644
--- a/lisp/net/tramp-message.el
+++ b/lisp/net/tramp-message.el
@@ -207,8 +207,7 @@ Message is formatted with FMT-STRING as control string and
the remaining
ARGUMENTS to actually emit the message (if applicable)."
(declare (tramp-suppress-trace t))
(let ((inhibit-message t)
- create-lockfiles file-name-handler-alist message-log-max
- signal-hook-function)
+ create-lockfiles file-name-handler-alist message-log-max)
(with-current-buffer (tramp-get-debug-buffer vec)
(goto-char (point-max))
(let ((point (point)))
@@ -364,7 +363,7 @@ VEC-OR-PROC identifies the connection to use, SIGNAL is the
signal identifier to be raised, remaining arguments passed to
`tramp-message'. Finally, signal SIGNAL is raised with
FMT-STRING and ARGUMENTS."
- (let (signal-hook-function)
+ (let ()
(tramp-backtrace vec-or-proc)
(unless arguments
;; FMT-STRING could be just a file name, as in
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 1777e2f1ed8..94408db771f 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3186,12 +3186,11 @@ implementation will be used."
(setcdr signals (cddr signals)))
;; Sanity check. "kill -l" shall have returned just the signal
;; names. Some shells don't, like the one in "docker alpine".
- (let (signal-hook-function)
- (condition-case nil
- (dolist (sig (cdr signals))
- (unless (string-match-p (rx bol (+ (any "+-" alnum)) eol) sig)
- (error nil)))
- (error (setq signals '(0)))))
+ (condition-case nil
+ (dolist (sig (cdr signals))
+ (unless (string-match-p (rx bol (+ (any "+-" alnum)) eol) sig)
+ (error nil)))
+ (error (setq signals '(0))))
(dotimes (i 128)
(push
(cond
@@ -5536,9 +5535,7 @@ raises an error."
;; Read the expression.
(condition-case nil
(prog1
- (let ((signal-hook-function
- (unless noerror signal-hook-function)))
- (read (current-buffer)))
+ (read (current-buffer))
;; Error handling.
(when (search-forward-regexp (rx (not space)) (line-end-position) t)
(error nil)))
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 102ba637f55..afc2033ee6e 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -242,7 +242,7 @@ arguments to pass to the OPERATION."
(filename &optional visit beg end replace)
"Like `insert-file-contents' for Tramp files."
(setq filename (expand-file-name filename))
- (let (signal-hook-function result)
+ (let (result)
(unwind-protect
(setq result
(insert-file-contents
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 0207805c720..a8d4ea51fbe 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1085,10 +1085,10 @@ Derived from `tramp-postfix-host-format'.")
(defconst tramp-localname-regexp (rx (* (not (any "\r\n"))) eos)
"Regexp matching localnames.")
-(defconst tramp-unknown-id-string "UNKNOWN"
+(defvar tramp-unknown-id-string "UNKNOWN"
"String used to denote an unknown user or group.")
-(defconst tramp-unknown-id-integer -1
+(defvar tramp-unknown-id-integer -1
"Integer used to denote an unknown user or group.")
;;;###tramp-autoload
@@ -1994,16 +1994,16 @@ does not exist, otherwise propagate the error."
;; This function provides traces in case of errors not triggered by
;; Tramp functions.
-(defun tramp-signal-hook-function (error-symbol data)
- "Function to be called via `signal-hook-function'."
+(defun tramp--trace-errors (err)
+ "Function to be called via `handler-bind'."
;; `custom-initialize-*' functions provoke `void-variable' errors.
;; We don't want to see them in the backtrace.
(declare (tramp-suppress-trace t))
- (unless (eq error-symbol 'void-variable)
+ (unless (eq (car err) 'void-variable)
(let ((inhibit-message t))
(tramp-error
- (car tramp-current-connection) error-symbol
- (mapconcat (lambda (x) (format "%s" x)) data " ")))))
+ (car tramp-current-connection) (car err)
+ (mapconcat (lambda (x) (format "%s" x)) (cdr err) " ")))))
(defmacro with-parsed-tramp-file-name (filename var &rest body)
"Parse a Tramp filename and make components available in the body.
@@ -2081,7 +2081,7 @@ without a visible progress reporter."
(defmacro with-tramp-timeout (list &rest body)
"Like `with-timeout', but allow SECONDS to be nil.
-(fn (SECONDS TIMEOUT-FORMS...) BODY)"
+\(fn (SECONDS TIMEOUT-FORMS...) BODY)"
(declare (indent 1) (debug ((form body) body)))
(let ((seconds (car list))
(timeout-forms (cdr list)))
@@ -2248,8 +2248,7 @@ arguments to pass to the OPERATION."
,(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers)))
(inhibit-file-name-operation operation)
- (args (if (tramp-file-name-p (car args)) (cons nil (cdr args)) args))
- signal-hook-function)
+ (args (if (tramp-file-name-p (car args)) (cons nil (cdr args)) args)))
(apply operation args)))
;; We handle here all file primitives. Most of them have the file
@@ -2386,8 +2385,8 @@ Fall back to normal file name handler if no Tramp file
name handler exists."
(let ((current-connection tramp-current-connection)
(foreign
(tramp-find-foreign-file-name-handler v operation))
- (signal-hook-function #'tramp-signal-hook-function)
result)
+ (handler-bind ((error #'tramp--trace-errors))
;; Set `tramp-current-connection'.
(unless
(tramp-file-name-equal-p v (car tramp-current-connection))
@@ -2453,7 +2452,7 @@ Fall back to normal file name handler if no Tramp file
name handler exists."
(unless
(tramp-file-name-equal-p
(car current-connection) (car tramp-current-connection))
- (setq tramp-current-connection current-connection))))))
+ (setq tramp-current-connection current-connection)))))))
;; When `tramp-mode' is not enabled, or the file name is quoted,
;; we don't do anything.
@@ -4584,7 +4583,7 @@ Do not set it manually, it is used buffer-local in
`tramp-get-lock-pid'.")
;; Do the lock.
(let ((tramp-verbose 0)
- create-lockfiles signal-hook-function)
+ create-lockfiles)
(condition-case nil
(make-symbolic-link info lockname 'ok-if-already-exists)
(error
@@ -4632,8 +4631,7 @@ Do not set it manually, it is used buffer-local in
`tramp-get-lock-pid'.")
(tramp-error v 'file-missing file))
(if (not (file-exists-p file))
nil
- (let ((signal-hook-function (unless noerror signal-hook-function))
- (inhibit-message (or inhibit-message nomessage)))
+ (let ((inhibit-message (or inhibit-message nomessage)))
(with-tramp-progress-reporter v 0 (format "Loading %s" file)
(let ((local-copy (file-local-copy file)))
(unwind-protect
@@ -4651,7 +4649,7 @@ Do not set it manually, it is used buffer-local in
`tramp-get-lock-pid'.")
"Add ad-hoc proxy definitions to `tramp-default-proxies-alist'."
(when-let ((hops (tramp-file-name-hop vec))
(item vec))
- (let (signal-hook-function changed)
+ (let (changed)
(dolist
(proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit)))
(let* ((host-port (tramp-file-name-host-port item))
- branch scratch/handler-bind-2 created (now 94b11fc0c9b), Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 a4efbe4c499 01/16: New special form `handler-bind`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 9f8ea786918 07/16: eval.c: Add new var `lisp-eval-depth-reserve`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 40437afc8ee 09/16: (signal_or_quit): Preserve error object identity, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 19f1d2a9f51 02/16: (eval-expression): Fix bug#67196, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 10e04044c7b 06/16: (macroexp--with-extended-form-stack): Use plain `let`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 617d568f4b6 03/16: ert.el: Use `handler-bind` to record backtraces, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 b21a22c86cc 13/16: Allow the `error-message` property to be a function, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 5a3ed126ccc 14/16: tramp.el: Use `handler-bind` instead of `signal-hook-function`,
Stefan Monnier <=
- scratch/handler-bind-2 c03598f1323 11/16: src/eval.c (call_debugger): Don't bind `Qinhibit_changing_match_data`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 bb9e093a106 08/16: Use handler-bind to repair bytecomp-tests, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 bc5500be3b0 15/16: (edebug-format): Make it obsolete, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 d9f047e2da5 05/16: Move batch backtrace code to `top_level_2`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 235907e1764 12/16: Add `redisplay-counter` to catched nested redisplays and abort outer one, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 857f1d37037 04/16: startup.el: Use `handler-bind` to implement `--debug-init`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 94b11fc0c9b 16/16: edebug.el: Use `handler-bind` instead of `signal-hook-function`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 1c5f2f854d9 10/16: (backtrace-on-redisplay-error): Use `handler-bind`, Stefan Monnier, 2023/12/27