diff options
-rw-r--r-- | thogai.el | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -566,15 +566,18 @@ BYTES is a list of 6 bytes in the Gemini protocol." ;; The Gemini protocol represents each stroke by 6 ;; bytes. Decode stroke once 6 bytes are received. (when (= (length bytes) bytes-per-stroke) - (let ((stroke (thogai-gemini-decode-stroke (reverse bytes)))) - ;; Log to paper tape. - (with-current-buffer (process-buffer process) - (insert stroke) - (insert "\n")) - ;; Insert into stroke ring, and process translation. - (ring-insert thogai-stroke-ring stroke) - (thogai-process-stroke thogai-stroke-ring)) - (setq bytes nil)))))) + ;; Stroke processing could result in errors, typically from + ;; user commands bound to strokes. Hence, unwind-protect. + (unwind-protect + (let ((stroke (thogai-gemini-decode-stroke (reverse bytes)))) + ;; Log to paper tape. + (with-current-buffer (process-buffer process) + (insert stroke) + (insert "\n")) + ;; Insert into stroke ring, and process translation. + (ring-insert thogai-stroke-ring stroke) + (thogai-process-stroke thogai-stroke-ring)) + (setq bytes nil))))))) (defun thogai-gemini-connect (port speed) "Connect to steno machine via the Gemini protocol. |