diff options
author | Arun Isaac | 2022-06-12 22:56:08 +0530 |
---|---|---|
committer | Arun Isaac | 2022-06-12 22:56:08 +0530 |
commit | a35b72046d2c6f3f3e83bd995d2c1769d44d2f4c (patch) | |
tree | f4bf3206351e508bf0c9c0fb44f8d7f16db78187 | |
parent | f78a74a066ebcec7b9de6c53583475ed64f074fb (diff) | |
download | thogai-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.el | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -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 |