From b6a015a0a211208a20e4ec784165cecdd2ee0ed0 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 19 Jun 2022 15:48:15 +0530 Subject: Protect gemini protocol filter from interruption. * thogai.el (thogai-gemini-decode-stroke): Protect gemini protocol filter from interruption. --- thogai.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/thogai.el b/thogai.el index 2a4fa57..65d3407 100644 --- a/thogai.el +++ b/thogai.el @@ -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. -- cgit v1.2.3