From 817a42b6b913b162adf5cc37a8ca720bc09d6a07 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 17 Jun 2022 23:28:21 +0530 Subject: Support mapping strokes to commands. * thogai.el (thogai-process-stroke): Support mapping strokes to commands. --- thogai.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/thogai.el b/thogai.el index 1803405..d9511ad 100644 --- a/thogai.el +++ b/thogai.el @@ -388,11 +388,16 @@ current state, and should typically be `thogai-stroke-ring'." ;; this translation. If no strokes were matched, skip this step. (unless (null matched-strokes) (thogai-reverse-strokes (butlast matched-strokes))) - ;; Insert literal stroke if it is not in the dictionary. Else, - ;; insert the actual translation. + ;; Insert literal stroke if it is not in the dictionary. (if (null matched-strokes) (thogai-insert-translation (ring-ref stroke-ring 0)) - (thogai-insert-translation (thogai-lookup (string-join matched-strokes "/"))))))) + ;; Else, insert or run the translation. + (let ((translation (thogai-lookup (string-join matched-strokes "/")))) + (cond + ((stringp translation) + (thogai-insert-translation translation)) + ((commandp translation) + (call-interactively translation)))))))) (defun thogai-byte-to-bits (byte) "Convert BYTE to a list of 8 bits. -- cgit v1.2.3