Home About Archive RSS

Offline dictionary lookups within Emacs

There is a dictionary-mode in Emacs. It used to be a separate package, but now comes as part of Emacs. The usual way to use it is to (setq dictionary-server "dict.org") in init.el (or equivalents) to tell Emacs to look up dictionary definitions from the internet when used. There are a lot of dictionaries in dict.org. The availability of the full text of the Webster 1913 dictionary within it has been much lauded in the Emacsphere by wordsmiths eager to vary their outpourings' formulations. However, I am not always online. I like to keep as much functionality as possible available to me offline to not become over-reliant on the internet or loose functionality when the internet is unavailable.

The solution is simply to install the dictd server and the dictionary packages you want on your computer. In Debian, these are available as dictd and a number of packages that supply dictd-dictionary for it. In Arch, dictd is an ordinary package in the community repo, but the dictionaries has to be added through the AUR. The dictd server and related dictionary files are however not available yet for GNU Guix. The Arch Wiki has an excellent page on dictd if you want more information on its usage. Once installed, you can just change the aforementioned dictionary-server variable from "dict.org" to "localhost" and Emacs will find your installed dictionaries. Depending on the distro, you may also have to systemctl enable dictd.service and systemctl start dictd.service to make certain dictd runs at every startup as well as immediately.

The selection of freely available Norwegian Bokmål dictionaries is rather slim. I only found an English - Norwegian dictionary that seemed slightly useful to me. I wish there was as Norwegian Bokmål - English dictionary as well since that would sometimes be useful for me even if I have a decent English vocabulary. There are some dictionaries from other European languages to Norwegian Bokmål, but I seldom use other languages than English these days. (I used to play opera, cantatas and masses and then those would have been useful to me.) There is also a Norwegian Nynorsk - Norwegian Bokmål dictionary by freedict. It could occasionally be useful when I read very old Nynorsk (Landsmaal). I wish there were a comprehensive Norwegian Bokmål dictionary with word definitions, synonyms, IPA pronunciation, example of usage and expressions. I would use it especially for synonyms and spelling. Since I have lived and worked some years in Denmark and Sweden, my Bokmål spelling isn't as good as it used to be, and ten years of using English as my working language after I returned to Norway did not really improve it either. I naturally blame the morons in the government of Denmark-Norway that decided to support Napoleon for all my current spelling troubles. Or maybe the Swedes that broke up the Kalmar Union should ultimately be to blame? Ok, maybe I need to take some responsibility myself as well…

American English is well covered by the GNU version of the Collaborative International Dictionary of English (dict-gcide) that includes the full text of the 1913 Webster's Unabridged Dictionary, the 1906 Century Dictionary and some other additions. I also installed WordNet (dict-wn) for synonyms. There are also some good computer term dictionaries like the Jargon File (dict-jargon), Virtual Entity of Relevant Acronyms (dict-vera) and the Free On Line Dictionary of Computing (dict-foldoc) available. I miss a dictionary with both British and American spelling and also IPA pronunciation since I try to stick with British spelling and RP. It is a pity that Oxford University Press do not release the Oxford English Dictionary or my favourite, the Oxford Advanced Learner's Dictionary, under a free culture license so it could be included as well. I have the Advanced Learner's Dictionary as a paperback in my bookshelf, and there is a website with it available gratis, but leaving Emacs breaks my flow when writing, the internet is not always available and my paperback is only available in my home. In my opinion, a university should use free culture and software licenses for everything they produce since when public money is used, it is only fair that the tax-payers get access to the works they funded. Also, the freedom to use, study, modify and share information should be the core values of any school or university.

I use both M-x dictionary-search and M-x dictionary-lookup-definition. The former lets you write in a search term while the latter looks up the word at point. The latter is obviously very useful while reading while the former may be more useful when writing, except if you want to find a synonym while revising your text where the latter becomes useful again. There is no need to change dictionary language for dictionary-mode unless you have installed too many dictionaries or dictionaries of languages with a lot of collision of vocabulary and spelling. Norwegian and English share a lot of vocabulary, but seldom collide in spelling, so I see no need to exclude any of the relevant dictionaries in either language. If you are overwhelmed with hits, it is possible to change dictionary inside the dictionary-mode buffer to limit the number of entries you get.

Combined with recently setting up flyspell-prog-mode for prog-mode and flyspell-mode for text-mode and (setq ispell-dictionary "british") in my init.el, I now feel more confident than before when writing text in Emacs, whether in code or not. (Dictionaries for lookup with dictionary mode and dictionaries for spell checking are separate and aspell or hunspell has to be installed with relevant dictionaries on your distro for ispell-dictionary to be set to the language you want for spell checking.) It's nice with spell checking for variable names and comments. Maybe I should add a toggle function with a keybinding for ispell-local-dictionary between "british" and "nb" to avoid having to use ispell-change-dictionary.

© Einar Mostad 2010 - 2025. Content is licensed under the terms of CC BY SA except code which is GNU GPL v3 or later.