Created
October 23, 2015 09:57
-
-
Save lislon/d5c82c9f77c1b24d8219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Google translate interactive mode | |
| (define-derived-mode google-translate-interactive-mode | |
| text-mode "Google Translate" | |
| (defun my/next-line-empty-p () | |
| "Check if next line empty" | |
| (save-excursion | |
| (beginning-of-line 2) | |
| (save-match-data | |
| (looking-at "[ \t]*$")))) | |
| (defun my/translate-word-and-next-line () | |
| "Shows translation of current line in help buffer and inserts | |
| new line after it" | |
| (interactive) | |
| (let ((buffer (current-buffer)) ) | |
| (move-beginning-of-line nil) | |
| (set-mark-command nil) | |
| (move-end-of-line nil) | |
| (google-translate-at-point) | |
| (switch-to-buffer buffer) | |
| (if (eq (point) (point-max)) | |
| (newline-and-indent) | |
| (end-of-line 2)) | |
| )) | |
| (use-local-map (make-sparse-keymap)) | |
| (local-set-key (kbd "RET") 'my/translate-word-and-next-line) | |
| (define-key evil-normal-state-map (kbd "RET") 'my/translate-word-and-next-line)) | |
| (defun my/google-translate-repl () | |
| "Interactive major mode for translating multiply words" | |
| (interactive) | |
| (let ((buffer (get-buffer-create "Google Translate REPL"))) | |
| (switch-to-buffer buffer) | |
| (google-translate-interactive-mode) | |
| (evil-insert-state) | |
| (goto-char (buffer-end 1)))) | |
| (evil-leader/set-key "x g i" 'my/google-translate-repl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment