about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--thogai.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/thogai.el b/thogai.el
index 7933ed1..6a0dbc6 100644
--- a/thogai.el
+++ b/thogai.el
@@ -172,6 +172,16 @@ The last function in FUNCTIONS is applied first."
                 functions
                 arg)))
 
+(defun thogai-insert-space ()
+  "Insert space at point if necessary.
+
+Insert space at point unless at the beginning of a line or
+`thogai-attach-next' is non-nil."
+  (unless (or (= (line-beginning-position)
+                 (point))
+              thogai-attach-next)
+    (insert " ")))
+
 (defun thogai-insert-translation (translation &optional subtranslation)
   "Insert TRANSLATION at point.
 
@@ -217,14 +227,8 @@ callers should never pass non-nil SUBTRANSLATION."
           (delete-char -1)))
        ;; Simple literal translation
        (_
-        ;; Insert a space unless at the beginning of line.
-        (unless (or subtranslation
-                    (= (line-beginning-position)
-                       (point))
-                    thogai-attach-next)
-          (insert " "))
-        ;; Reset `thogai-attach-next'.
-        (setq thogai-attach-next nil)
+        (unless subtranslation
+          (thogai-insert-space))
         (insert (funcall (thogai-compose
                           ;; Capitalize first letter.
                           (if thogai-capitalize-next-word