Skip to content

condy0919/fanyi.el

Repository files navigation

build License Supports Emacs 27.1-28.x MELPA

fanyi.el

fanyi.el is a simple yet powerful multi-dictionaries interface for Emacs, currently it includes:

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 turns bookmark into a vocabulary notebook.
  • outline-mode, TAB to collapse on section.
  • ol (aka org-link), org-store-link on a fanyi buffer, the link can be inserted later via org-insert-link. It's accomplished by introducing a fanyi link type. e.g., C-c C-o on [[fanyi:happy][description of happy]] will invoke a fanyi search. Since ol depends on org package, this integration needs an explicit (require 'ol-fanyi).

Installation

Install fanyi.el from MELPA with:

M-x package-install RET fanyi RET

Usage

M-x 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+
(setq read-extended-command-predicate #'command-completion-default-include-p)

CAUTIOUS: 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)))

;; For non-`use-package' users
(custom-set-variables
 '(fanyi-providers '(fanyi-haici-provider
                     fanyi-youdao-thesaurus-provider
                     fanyi-etymon-provider
                     fanyi-longman-provider)))

By default, M-x fanyi-dwim will move the point to the new created *fanyi* buffer.

(setq fanyi-auto-select nil)

to keep the point.

For windows users,

(setq fanyi-sound-player-support-https t)

if your sound player can be launched with your-sound-player url. Otherwise it will be called like your-sound-player - <(the voice file), where - is interpreted as stdin which is an UNIX convention.

FAQ

  1. 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)
  2. Longman throws an user-error It's expected. File an issue please.

Screenshots

status indicator 海词 分布 Etymon Longman 有道同义词英文 有道同义词中文

Similar projects

About

Not only English-Chinese translator for Emacs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published