aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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