Skip to content

Commit d414c12

Browse files
committed
fix: Forward errors from READ of turtles-with-minibuffer in Emacs 30
This is a follow-up for bd55a59, which caught errors from BODY in Emacs 30. This change catches errors from READ in the same way and re-throws them once outside the timer.
1 parent de0ebce commit d414c12

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

test/turtles-test.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,11 @@
12241224
(read-from-minibuffer "Prompt: ")
12251225
:keys "ok")))
12261226

1227+
(turtles-ert-deftest turtles-with-minibuffer-fail-in-read ()
1228+
:expected-result :failed
1229+
(turtles-with-minibuffer
1230+
(should (equal "incorrect" (read-from-minibuffer "Prompt: ")))))
1231+
12271232
(turtles-ert-deftest turtles-term-truecolor ()
12281233
(skip-unless (>= emacs-major-version 29))
12291234
;; Truecolor in term.el became available in Emacs 29.1. Before that,

turtles.el

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,13 @@ to return."
987987
(run-with-timer
988988
0 nil
989989
(lambda ()
990-
(throw 'turtles-with-minibuffer-return
991-
(cons 'read (funcall readfunc))))))
990+
(let ((result (list 'read nil nil)))
991+
(if (>= emacs-major-version 30)
992+
(condition-case-unless-debug err
993+
(setf (nth 1 result) (funcall readfunc))
994+
(t (setf (nth 2 result) err)))
995+
(setf (nth 1 result) (funcall readfunc)))
996+
(throw 'turtles-with-minibuffer-return result)))))
992997
(setq body-timer
993998
(run-with-timer
994999
0 nil
@@ -1002,9 +1007,11 @@ to return."
10021007
bodyfunclist))))
10031008
(sleep-for timeout)
10041009
(error "Timed out"))
1005-
(`(read . ,result)
1010+
(`(read ,result ,err)
10061011
;; The read section has ended. The body might not have
10071012
;; run fully.
1013+
(when err
1014+
(signal (car err) (cdr err)))
10081015
(unless body-started
10091016
;; The body didn't have a chance to start. This is very
10101017
;; suspicious.

0 commit comments

Comments
 (0)