aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-12 22:56:08 +0530
committerArun Isaac2022-06-12 22:56:08 +0530
commita35b72046d2c6f3f3e83bd995d2c1769d44d2f4c (patch)
treef4bf3206351e508bf0c9c0fb44f8d7f16db78187
parentf78a74a066ebcec7b9de6c53583475ed64f074fb (diff)
downloadthogai-a35b72046d2c6f3f3e83bd995d2c1769d44d2f4c.tar.gz
thogai-a35b72046d2c6f3f3e83bd995d2c1769d44d2f4c.tar.lz
thogai-a35b72046d2c6f3f3e83bd995d2c1769d44d2f4c.zip
Abstract out insertion of space into a separate function.
* thogai.el (thogai-insert-translation): Abstract out space insertion logic into ... (thogai-insert-space): ... new function.
-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