Created
May 4, 2020 23:55
-
-
Save kdmsnr/7209a98e9ccacec449011e11f46fdcf7 to your computer and use it in GitHub Desktop.
This file contains 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
(require 'url-util) | |
(defun my:deepl-translate (&optional string) | |
(interactive) | |
(setq string | |
(cond ((stringp string) string) | |
((use-region-p) | |
(buffer-substring (region-beginning) (region-end))) | |
(t | |
(save-excursion | |
(let (s) | |
(forward-char 1) | |
(backward-sentence) | |
(setq s (point)) | |
(forward-sentence) | |
(buffer-substring s (point))))))) | |
(run-at-time 0.1 nil 'deactivate-mark) | |
(browse-url | |
(concat | |
"https://www.deepl.com/translator#en/ja/" | |
(url-hexify-string string) | |
))) | |
(global-set-key (kbd "C-c C-c") 'my:deepl-translate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment