Emacs Dictionary Lookup
addendem: this page is outdated and is kept here for historical purposes.
See this page instead Emacs: Lookup Google, Dictionary, Documentation
This page shows you how to install a package to lookup word definition within emacs.
Emacs Dictionary Client
Torsten Hilbrich has writen a package named
dictionary.el that looks up a open source dictionary server at
Download it at:
Follow the installation instructions in the file. Once you installed it, you can put this in your emacs init file:
;; press F8 on keypad to lookup definition (global-set-key (kbd "<f8>") 'dictionary-lookup-definition)
You can set up the default dictionary to use. You do this by typing 【Alt+x customize-group】, then “dictionary”, then scroll to “Dictionary Default Dictionary”. If you want WordNet to be your default dictionary, put “wn” in the field. Then, click “Save for Future Sessions” at the top, then “Finish”.
To search all available dictionaries on the server, use the
*. That's the default behavior. (The result of looking up all
dictionaries is sometimes confusing.)
To see a list of available dictionaries, first lookup a word, then move your cursor to the “[Select Dictionary]” and hit Enter. The word before the colon is the keyword to use.
Problems with “dictionary.el”
There are few problems with
- You cannot set it to look up more than one dictionary. It's either one specific dictionary, or all dictionaries on the server. For example, i only want to use Webster 1913 (web1913), WordNet (wn), and Moby Thesaurus (moby-thes). However, it is not possible to have results of these in one pane.
- Plural form of a word will result in “Not Found”. You have to use the singular form. For example, try lookup “chairs”.
- Words containing foreign chars, such as “passé”, will result a error. You need to lookup a form without the foreign char: “passe”.
- If you have a phrase containing space such as “Union Jack” in buffer, there's no way to lookup that phrase. You will have to start a new search and manually type the phrase yourself.
- It moves the cursor to the result pane. This behavior is not emacs's convention.
The following wrapper code fixes above problems dictionary_lookup_fix.el.
The command “lookup-word-definition-in-emacs” looks up WordNet, Webster 1913, Moby Thesaurus, and combine their results in one pane. You can change or add more by modifying the code.
You should also setup a hotkey to the command. See: Emacs: How to Define Keys.
Sometimes if there is no result in one of the dictionary, the function will choke. I haven't had time to dig, but for now a work-around is to comment out the following section in
(unless nomatching (beep) (insert "Word not found, maybe you are looking " "for one of these words\n\n") (dictionary-do-matching word dictionary "." 'dictionary-display-only-match-result) (dictionary-post-buffer))
Problems of dict.org + Emacs
dict.org within emacs is quite annoying. Here's some problems:
- The open source dictionary is inferior in many ways by far in comparison to commercial dictionaries. See: Problems of Open Source Dictionaries.
- dict.org is usually slow. Takes several seconds, and sometimes the server is down. In comparison, most other online dictionaries render the page within 1 second in a browser.
- When dict.org is slow or down, emacs stuck and you can't do anything else. (emacs does not support threads)
If you have a question, put $5 at patreon and message me.