Emacs Dictionary Lookup
2015-04-30 addendem: this page is outdated and is kept here for historical purposes. See this page instead Elisp: Command to Lookup Doc
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 dict.org
.
Download it at:
http://www.myrkr.in-berlin.de/dictionary/index.html.
Follow the installation instructions in the file. Once you installed it, 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
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
keyword *
. 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 dictionary.el
.
- 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 is 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 Keys: Define Key.
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 dictionary.el
:
(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
Looking up 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)