Skip to content

Instantly share code, notes, and snippets.

@kdmsnr
Created May 4, 2020 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdmsnr/7209a98e9ccacec449011e11f46fdcf7 to your computer and use it in GitHub Desktop.
Save kdmsnr/7209a98e9ccacec449011e11f46fdcf7 to your computer and use it in GitHub Desktop.
(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