diff options
Diffstat (limited to 'thogai.el')
-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))))) |