aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-12 22:57:33 +0530
committerArun Isaac2022-06-12 22:57:33 +0530
commit9c833e0e420e64cbb2292958bca5913300528cc0 (patch)
treeaa45cea4ad2df7cca9bc521dda3e3e14855bd737
parenta35b72046d2c6f3f3e83bd995d2c1769d44d2f4c (diff)
downloadthogai-9c833e0e420e64cbb2292958bca5913300528cc0.tar.gz
thogai-9c833e0e420e64cbb2292958bca5913300528cc0.tar.lz
thogai-9c833e0e420e64cbb2292958bca5913300528cc0.zip
Implement glue operator.
* thogai.el (thogai-glue): New variable. (thogai-insert-translation): Implement glue operator.
-rw-r--r--thogai.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/thogai.el b/thogai.el
index 6a0dbc6..73fd118 100644
--- a/thogai.el
+++ b/thogai.el
@@ -91,6 +91,14 @@ to.")
If non-nil, the next part of the translation is attached without
a space, and the variable is reset to nil.")
+(defvar thogai-glue
+ nil
+ "Flag indicating whether to glue the next translation.
+
+If non-nil and the next part of the translation also starts with
+a glue operator, it is attached without a space, and the variable
+is reset to nil.")
+
(defvar thogai-capitalize-next-word
nil
"Flag indicating whether to capitalize the next word.
@@ -204,6 +212,14 @@ callers should never pass non-nil SUBTRANSLATION."
(string-suffix-p "^}" str)))
(insert (string-remove-prefix "{" (string-remove-suffix "^}" translation)))
(setq thogai-attach-next t))
+ ;; Glue operator
+ ((pred (lambda (str)
+ (and (string-prefix-p "{&" str)
+ (string-suffix-p "}" str))))
+ (unless thogai-glue
+ (thogai-insert-space))
+ (insert (string-remove-prefix "{&" (string-remove-suffix "}" translation)))
+ (setq thogai-glue t))
;; Capitalize next word.
("{-|}"
(setq thogai-capitalize-next-word t))
@@ -229,6 +245,9 @@ callers should never pass non-nil SUBTRANSLATION."
(_
(unless subtranslation
(thogai-insert-space))
+ ;; Reset `thogai-attach-next' and `thogai-glue'.
+ (setq thogai-attach-next nil
+ thogai-glue nil)
(insert (funcall (thogai-compose
;; Capitalize first letter.
(if thogai-capitalize-next-word