From 3bc19776322eade3f9938851190243fef0a5afb2 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Fri, 15 May 2026 16:12:43 -0400 Subject: [PATCH] fix: Reader error loop from (= nil 27), Swank *standard-output* redirect - Remove 'code' variable binding (redundant with b). esc-seq now starts with (and b (= b 27) ...) so when b is nil (timeout), the and short-circuits before (= b 27) can error with 'NIL is not of the type NUMBER'. - Swank prints to *standard-output*, not *error-output*. Bind both to string output streams to prevent ';; Swank started' leak. --- org/channel-tui-main.org | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index 71ded14..fcabba0 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -968,8 +968,7 @@ Returns T on success, nil on failure. Does NOT wait or retry." ;; Keyboard reader via read-raw-byte (proven CSI detection) (handler-case (let* ((b (cl-tty.input::read-raw-byte :timeout 0.1)) - (code b) - (esc-seq (and (= code 27) + (esc-seq (and b (= b 27) (let ((b2 (cl-tty.input::read-raw-byte :timeout 0.15))) (when (and b2 (= b2 91)) (let ((t2 (cl-tty.input::read-raw-byte :timeout 0.15))) @@ -981,21 +980,21 @@ Returns T on success, nil on failure. Does NOT wait or retry." (when b (queue-event (list :type :key - :payload (list :code (or code 0) + :payload (list :code b :ch (or esc-seq (cond - ((= code 13) :enter) - ((= code 10) :enter) - ((= code 27) :escape) - ((= code 9) :tab) - ((or (= code 127) (= code 8)) :backspace) - ((and (>= code 1) (<= code 26)) + ((= b 13) :enter) + ((= b 10) :enter) + ((= b 27) :escape) + ((= b 9) :tab) + ((or (= b 127) (= b 8)) :backspace) + ((and (>= b 1) (<= b 26)) (intern (string-upcase (format nil "CTRL-~a" - (code-char (+ #x60 code)))) + (code-char (+ #x60 b)))) :keyword)) - (t code)))))))) + (t b)))))))) (error (c) (add-msg :system (format nil "* Reader error: ~a *" c)))) ;; Check for terminal resize (SIGWINCH sets this flag)