fanyi.el
fanyi.el
is a simple yet powerful multi-dictionaries interface for Emacs, currently it includes:
海词
有道翻译
, UnofficialoutdatedAPI有道同义词
, Unofficial APIetymonline
Longman
LibreTranslate
, Free and Open Source Machine Translation API.American Heritage dictionary
, unusable in China due to high latency. Not fully implemented
fanyi.el
has integrations with:
imenu
, M-x imenu to jump to dictionary section directly.bookmark
, C-x r m to make a bookmark for current query word which turnsbookmark
into a vocabulary notebook.outline-mode
, TAB to collapse on section.ol
(org-link
),org-store-link
on a fanyi buffer, the link can be inserted later viaorg-insert-link
. It's accomplished by introducing afanyi
link type. e.g., C-c C-o on[[fanyi:happy][description of happy]]
will invoke a fanyi search. Sinceol
depends onorg
package, this integration needs an explicit(require 'ol-fanyi)
.
Installation
Install fanyi.el
from MELPA with:
M-x package-install RET fanyi RET
If you're an American Heritage Dictionary
user, make sure Minion New
font is
installed. Otherwise the pronunciation may be displayed in tofu, or an
all-the-icons
icon if you have all-the-icons
installed.
# family: Minion New Bold
# https://ahdictionary.com/application/resources/fonts/MinionNew-Bold.ttf
#
# family: Minion New Italic
# https://ahdictionary.com/application/resources/fonts/MinionNew-Italic.ttf
curl https://ahdictionary.com/application/resources/fonts/MININ___.TTF -o Minion.ttf
# linux
mv Minion.ttf ~/.local/share/fonts/
# macOS
mv Minion.ttf ~/Library/Fonts/
Usage
Call fanyi-dwim
, or fanyi-dwim2
if you can confirm the word at point is
wanted. A new command fanyi-from-history
is introduced to browse the search
history.
If you want M-x fanyi to list only fanyi-dwim
, fanyi-dwim2
and
fanyi-from-history
, try
;; Emacs 28 only
(setq read-extended-command-predicate #'command-completion-default-include-p)
Don't customize fanyi-providers
via setq
, use the custom system instead.
;; If you want English-English dictionary only.
(use-package fanyi
:ensure t
:custom
(fanyi-providers '(fanyi-etymon-provider
fanyi-longman-provider)))
;; Default, comment out the providers you don't need.
(use-package fanyi
:ensure t
:custom
(fanyi-providers '(;; 海词
fanyi-haici-provider
;; 有道同义词词典
fanyi-youdao-thesaurus-provider
;; Etymonline
fanyi-etymon-provider
;; Longman
fanyi-longman-provider
;; LibreTranslate
fanyi-libre-provider)))
;; For non-`use-package' users
(custom-set-variables
'(fanyi-providers '(fanyi-haici-provider
fanyi-youdao-thesaurus-provider
fanyi-etymon-provider
fanyi-longman-provider
fanyi-libre-provider)))
If you're a Windows user,
(setq fanyi-sound-player-support-https t)
may be helpful since - is interpreted as stdin
is an UNIX convention. If
fanyi-sound-player-support-https
is non-nil, the url will be passed to
fanyi-sound-player
directly.
FAQ
-
Audio button icon displayed in tofu. The icon is emoji, install the proper font to display it. If you use archlinux,
yay -S ttf-symbola
without additional settings. For MacOS users, add the following elisp to your Emacs config.;; "Apple Color Emoji" is bundled with MacOS. ;; ;; Emacs 29, 28 (set-fontset-font t 'emoji (font-spec :family "Apple Color Emoji") nil 'prepend) ;; Emacs 27 (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend)
-
Longman throws an
user-error
It's expected. File an issue please.