background
I’m tempted to blame Ross Baker for this; he had posted a link to his Emacs config on the Fediverse, and while scrolling through it I had noticed that he had added a dictionary package that, on macOS, would send dictionary queries to dict.org.
As Baker himself observes, this is a less-than-ideal setup. He would
rather run dictd locally on his Mac. So would I since I
prefer to turn off wifi when I’m writing.
However, while the Nix
package manager provides dictd in the “dict” package,
it doesn’t provide much in the way of dictionary packages. There’s a
version of the WordNet dictionary that can be used with
dictd, but doesn’t include other dictionaries like GNU’s version of
the Collaborative International Dictionary of English or the Devil’s
Dictionary by Ambrose Bierce.
integration with macOS
However, macOS comes with a dictionary app called, naturally enough,
Dictionary.app. Furthermore, it is
possible to add custom dictionaries that have been formatted for this
app by unzipping them into ~/Library/Dictionaries/. I was thus able to add
a version of the 1913
Webster’s dictionary formatted for use in Dictionary.app in the websterParser
repository on GitHub.
However, all of the above is prep work. I might have Webster’s 1913
in Dictionary.app, but I’d still have to
open that app and focus it if I want to do lookups unless I adjust my
Emacs config.
Fortunately, I don’t have to do the integration myself; there’s a package for this. This is how I’ve got it installed in my config:
(cond ((eq system-type 'darwin)
(use-package osx-dictionary
:bind (("C-c d l" . osx-dictionary-search-word-at-point)
("C-c d i" . osx-dictionary-search-input)))))
integration with GNU/Linux
Integration between Emacs and dictd on
GNU/Linux should be far simpler.
(cond ((eq system-type 'gnu/linux)
(use-package dictionary
:bind (("C-c d l" . dictionary-lookup-definition))
:config
(dictionary-server "localhost"))))I’ll have to test this the next time I’m on one of my Linux machines.
sdcv
There’s a CLI utility called sdcv that uses StarDict-formatted
dictionaries. There’s an Emacs
package, but I’m already using it in Emacs’ eshell so
installing sdcv-mode isn’t an espeically high priority for
me. Maybe next weekend.