feat(emacs/lean-input): add lean-input-export-translations
This commit is contained in:
parent
30571ce418
commit
cb83eca2f3
1 changed files with 22 additions and 0 deletions
|
@ -1091,3 +1091,25 @@ Suitable for use in the :set field of `defcustom'."
|
|||
|
||||
(provide 'lean-input)
|
||||
;;; lean-input.el ends here
|
||||
|
||||
(defun lean-input-export-translations ()
|
||||
"Export the current translation, (input, output) pairs for
|
||||
input-method, in a javascript format. It can be copy-pasted to
|
||||
leanprover.github.io/js/input-method.js"
|
||||
(interactive)
|
||||
(with-current-buffer
|
||||
(get-buffer-create "*lean-translations*")
|
||||
(insert "var corrections = {")
|
||||
(--each
|
||||
(lean-input-get-translations "Lean")
|
||||
(let* ((input (substring (car it) 1))
|
||||
(outputs (cdr it)))
|
||||
|
||||
(insert (format "{%s:\"" (prin1-to-string input)))
|
||||
|
||||
(cond ((vectorp outputs)
|
||||
(insert (elt outputs 0)))
|
||||
(t (insert-char outputs)))
|
||||
|
||||
(insert (format "\"},\n" input))))
|
||||
(insert "};")))
|
||||
|
|
Loading…
Reference in a new issue