diff options
author | Arun Isaac | 2022-06-12 23:22:00 +0530 |
---|---|---|
committer | Arun Isaac | 2022-06-12 23:23:23 +0530 |
commit | 0143af1c0b538b7c5ae008966e5d3cf73dd68c16 (patch) | |
tree | 3a10db3c035e1222ee0dd61ae79b98e2225b2fa9 | |
parent | 9c833e0e420e64cbb2292958bca5913300528cc0 (diff) | |
download | thogai-0143af1c0b538b7c5ae008966e5d3cf73dd68c16.tar.gz thogai-0143af1c0b538b7c5ae008966e5d3cf73dd68c16.tar.lz thogai-0143af1c0b538b7c5ae008966e5d3cf73dd68c16.zip |
Abstract out insertion of literal translations.
* thogai.el (thogai-insert-translation): Abstract out literal
translation insertion logic into ...
(thogai-insert-literal): ... new function.
-rw-r--r-- | thogai.el | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -190,6 +190,29 @@ Insert space at point unless at the beginning of a line or thogai-attach-next) (insert " "))) +(defun thogai-insert-literal (literal-translation) + "Insert LITERAL-TRANSLATION at point. + +Insert LITERAL-TRANSLATION at point, respecting +`thogai-capitalize-next-word' and +`thogai-uncapitalize-next-word'." + (insert (funcall (thogai-compose + ;; Capitalize first letter. + (if thogai-capitalize-next-word + (lambda (str) + (setq thogai-capitalize-next-word nil) + (concat (upcase (substring str 0 1)) + (substring str 1))) + 'identity) + ;; Uncapitalize first letter. + (if thogai-uncapitalize-next-word + (lambda (str) + (setq thogai-uncapitalize-next-word nil) + (concat (downcase (substring str 0 1)) + (substring str 1))) + 'identity)) + literal-translation))) + (defun thogai-insert-translation (translation &optional subtranslation) "Insert TRANSLATION at point. @@ -248,22 +271,7 @@ callers should never pass non-nil SUBTRANSLATION." ;; 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 - (lambda (str) - (setq thogai-capitalize-next-word nil) - (concat (upcase (substring str 0 1)) - (substring str 1))) - 'identity) - ;; Uncapitalize first letter. - (if thogai-uncapitalize-next-word - (lambda (str) - (setq thogai-uncapitalize-next-word nil) - (concat (downcase (substring str 0 1)) - (substring str 1))) - 'identity)) - translation)))) + (thogai-insert-literal translation))) ;; Recurse for rest of translation. (unless (string= rest-of-translation "") (thogai-insert-translation rest-of-translation t))))) |