diff options
author | Arun Isaac | 2022-06-13 01:03:41 +0530 |
---|---|---|
committer | Arun Isaac | 2022-06-13 01:03:41 +0530 |
commit | 4cee01cc6298add2ab39508c58c76ac4d90486bd (patch) | |
tree | 2c6892df8212a34642db18be85953ae679cf78c8 | |
parent | 71ceaf98bfba0a9e697b4fa7ae3cb51e108afadb (diff) | |
download | thogai-4cee01cc6298add2ab39508c58c76ac4d90486bd.tar.gz thogai-4cee01cc6298add2ab39508c58c76ac4d90486bd.tar.lz thogai-4cee01cc6298add2ab39508c58c76ac4d90486bd.zip |
Carry through non-first-part-p on command translations.
* thogai.el (thogai-insert-translation): Rename argument
subtranslation to non-first-part-p and carry it through when command
translations are processed.
-rw-r--r-- | thogai.el | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -216,12 +216,14 @@ Insert LITERAL-TRANSLATION at point, respecting (setq thogai-attach-next nil thogai-glue nil)) -(defun thogai-insert-translation (translation &optional subtranslation) +(defun thogai-insert-translation (translation &optional non-first-part-p) "Insert TRANSLATION at point. -TRANSLATION is a string mapped to in a steno dictionary. If -SUBTRANSLATION is non-nil, this is a recursive call. External -callers should never pass non-nil SUBTRANSLATION." +TRANSLATION is a string mapped to in a steno dictionary. + +If NON-FIRST-PART-P is non-nil, no literal parts of TRANSLATION +have been processed yet. This is an internal recursion variable. +External callers should always pass nil as the value." (pcase (save-match-data (string-match (rx string-start (or (one-or-more (not ?{)) (sequence ?{ (one-or-more (not ?{)) ?}))) @@ -243,7 +245,7 @@ callers should never pass non-nil SUBTRANSLATION." ;; Prefix ((pred (lambda (str) (string-suffix-p "^}" str))) - (unless subtranslation + (unless non-first-part-p (thogai-insert-space)) (thogai-insert-literal (string-remove-prefix "{" (string-remove-suffix "^}" translation))) @@ -252,7 +254,7 @@ callers should never pass non-nil SUBTRANSLATION." ((pred (lambda (str) (and (string-prefix-p "{&" str) (string-suffix-p "}" str)))) - (unless (or subtranslation thogai-glue) + (unless (or non-first-part-p thogai-glue) (thogai-insert-space)) (thogai-insert-literal (string-remove-prefix "{&" (string-remove-suffix "}" translation))) @@ -280,12 +282,18 @@ callers should never pass non-nil SUBTRANSLATION." (delete-char -1))) ;; Simple literal translation (_ - (unless subtranslation + (unless non-first-part-p (thogai-insert-space)) (thogai-insert-literal translation))) ;; Recurse for rest of translation. (unless (string= rest-of-translation "") - (thogai-insert-translation rest-of-translation t))))) + (thogai-insert-translation + rest-of-translation + ;; Carry through non-first-part-p on pure command translation + ;; parts that do not insert anything. + (if (member translation (list "{^}" "{-|}" "{*-|}" "{>}" "{*>}" "{*!}")) + non-first-part-p + t)))))) (defun thogai-reverse-strokes (strokes) "Reverse the effects of STROKES. |