aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-17 23:28:21 +0530
committerArun Isaac2022-06-17 23:28:21 +0530
commit817a42b6b913b162adf5cc37a8ca720bc09d6a07 (patch)
tree243383db8cd76de406e64f964546a6e400aae075
parent4f456c36a4b56dec2e7053ba1d3d0475b70ed3ac (diff)
downloadthogai-817a42b6b913b162adf5cc37a8ca720bc09d6a07.tar.gz
thogai-817a42b6b913b162adf5cc37a8ca720bc09d6a07.tar.lz
thogai-817a42b6b913b162adf5cc37a8ca720bc09d6a07.zip
Support mapping strokes to commands.
* thogai.el (thogai-process-stroke): Support mapping strokes to commands.
-rw-r--r--thogai.el11
1 files 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.