dict.el 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ;;; dict.el --- Spelling, translating, …
  2. ;; Copyright © 2014-2016 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. (require 'al-key)
  14. ;;; Global keys
  15. (al/bind-keys
  16. :prefix-map al/translation-map
  17. :prefix-docstring "Map for dictionaries, translating and friends."
  18. :prefix "<XF86Spell>"
  19. ("<XF86Spell>" . al/dictem-run-word)
  20. ("s" . dictem-run-search)
  21. ("m" . dictem-run-match)
  22. ("i" . al/dictem-run-show-all-info)
  23. ("d" . al/dictem-run-dict-search)
  24. ("q" . dictem-kill-all-buffers)
  25. ("e" (al/google-translate-using-languages "en" "ru"))
  26. ("r" (al/google-translate-using-languages "ru" "en"))
  27. ("f" (al/google-translate-using-languages "fr" "ru"))
  28. ("l" (let ((google-translate-translation-directions-alist
  29. '(("la" . "ru") ("ru" . "la")
  30. ("la" . "en") ("en" . "la"))))
  31. (al/google-translate-smooth-translate)))
  32. ("g" (let ((google-translate-translation-directions-alist nil))
  33. (al/google-translate-smooth-translate))))
  34. (al/bind-keys
  35. :prefix-map al/spell-map
  36. :prefix-docstring "Map for flyspell and friends."
  37. :prefix "H-s"
  38. ("r" . flyspell-region)
  39. ("b" . flyspell-buffer)
  40. ("n" . flyspell-goto-next-error)
  41. ("H-n" . flyspell-goto-next-error))
  42. ;;; Misc settings and packages
  43. (with-eval-after-load 'ispell
  44. (ispell-change-dictionary "en" 'global))
  45. (setq flyspell-use-meta-tab nil)
  46. (with-eval-after-load 'flyspell
  47. (defconst al/flyspell-keys
  48. '(("C-M-g n" . flyspell-goto-next-error))
  49. "Alist of auxiliary keys for `flyspell-mode-map'.")
  50. (al/bind-keys-from-vars 'flyspell-mode-map 'al/flyspell-keys))
  51. (al/autoload "dictem"
  52. dictem-run-search
  53. dictem-run-match)
  54. (with-eval-after-load 'dictem
  55. (when (require 'al-dictem nil t)
  56. (dictem-initialize)
  57. (advice-add 'dictem :override 'al/dictem)
  58. (advice-add 'dictem-define-on-press
  59. :override 'al/dictem-define-on-press))
  60. (setq dictem-use-existing-buffer nil)
  61. (al/bind-keys
  62. :map dictem-mode-map
  63. ("." . dictem-previous-link)
  64. ("e" . dictem-next-link)
  65. ("u" . dictem-define-on-press)
  66. ("h" . dictem-previous-section)
  67. ("n" . dictem-next-section)
  68. ("m" . dictem-hyperlinks-menu)
  69. ("M" . dictem-run-match)
  70. ("Q" . dictem-kill-all-buffers))
  71. (add-hook 'dictem-postprocess-match-hook
  72. 'dictem-postprocess-match)
  73. (add-hook 'dictem-postprocess-definition-hook
  74. 'dictem-postprocess-definition-separator)
  75. (add-hook 'dictem-postprocess-definition-hook
  76. 'dictem-postprocess-definition-hyperlinks)
  77. (add-hook 'dictem-postprocess-show-info-hook
  78. 'dictem-postprocess-definition-hyperlinks))
  79. (with-eval-after-load 'al-dictem
  80. (setq al/dictem-dicts
  81. '(nil "mueller7" "korolew_en-ru" "korolew_ru-en"
  82. "slovnyk_ru-en" "ushakov" "fd-eng-lat" "fd-lat-eng")))
  83. (with-eval-after-load 'google-translate-core-ui
  84. (setq
  85. google-translate-show-phonetic t
  86. google-translate-listen-button-label "Listen"))
  87. (with-eval-after-load 'google-translate-smooth-ui
  88. (when (require 'dvorak-russian-computer nil t)
  89. (setq google-translate-preferable-input-methods-alist
  90. '((dvorak-russian-computer "ru"))))
  91. (setq
  92. google-translate-translation-directions-alist
  93. '(("en" . "ru") ("ru" . "en"))
  94. google-translate-input-method-auto-toggling t)
  95. (google-translate--setup-minibuffer-keymap)
  96. (defconst al/google-translate-keys
  97. '(("C-." . google-translate-previous-translation-direction)
  98. ("C-e" . google-translate-next-translation-direction))
  99. "Alist of auxiliary keys for google-translate.")
  100. (al/bind-keys-from-vars 'google-translate-minibuffer-keymap
  101. '(al/minibuffer-keys al/google-translate-keys)))
  102. ;;; dict.el ends here