aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-19 15:48:15 +0530
committerArun Isaac2022-06-19 15:50:55 +0530
commitb6a015a0a211208a20e4ec784165cecdd2ee0ed0 (patch)
treeb10186bc627bc975392215fb549c22fe4df69216
parent1d3800a7cd2be55d5bf2ac0ba6ef8502161da97b (diff)
downloadthogai-b6a015a0a211208a20e4ec784165cecdd2ee0ed0.tar.gz
thogai-b6a015a0a211208a20e4ec784165cecdd2ee0ed0.tar.lz
thogai-b6a015a0a211208a20e4ec784165cecdd2ee0ed0.zip
Protect gemini protocol filter from interruption.
* thogai.el (thogai-gemini-decode-stroke): Protect gemini protocol filter from interruption.
-rw-r--r--thogai.el21
1 files 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.