Skip to content

About

Merriam-Webster Thesaurus in Emacs

Topics

Resources

Stars

116 stars

Watchers

4 watching

Forks

Repository files navigation

Merriam-Webster Thesaurus and Dictionary

https://github.com/agzam/mw-thesaurus.el/actions/workflows/run-tests.yml/badge.svg

For more than 150 years, in print and now online, Merriam-Webster has been America’s leading and most-trusted provider of language information.

This package allows you to lookup a word and displays its thesaurus definition in a pleasing outline (Org-mode) format. It looks words up in the Collegiate Dictionary too.

assets/thesaurus.gif

Configure

Entirely optional, and you don’t have to do it at all

Again, this is not required for the package to work! You may want to do it anyway.

In order to use the Merriam-Webster API, it is necessary to register and obtain a free API key for the Collegiate Thesaurus.

A free key allows like 1000 lookups a day, and every user of this package shares the default one.

Whether Merriam-Webster enforces the limit is unknown, because the API sends no rate-limit headers.

By default, this package uses one registered key; for whatever reason, if you prefer your own or the default fails, then set a new key.

People have been actively using the package for many years, and the key still works just fine, yet I could imagine some kind of spam detection upstream block-listing the key. Well, if that happens, just get a free account and set a key.

  • Register free account at Merriam-Webster’s Developer Center
  • Obtain a key
  • Set the var
    (setq mw-thesaurus-api-key "YOUR-API-KEY")
        

The dictionary uses a second shared key, for the Collegiate Dictionary; a free account can hold keys for two references. To use your own, set mw-thesaurus-dictionary-api-key the same way.

Two more tabs need keys of your own, as the package ships none: Spanish, for the Spanish-English Dictionary, and Medical, for the Medical Dictionary. Each tab shows only while its key is set:

(setq mw-thesaurus-spanish-api-key "YOUR-SPANISH-KEY"
      mw-thesaurus-medical-api-key "YOUR-MEDICAL-KEY")

It is on MELPA.

use-package example

(use-package mw-thesaurus
  :bind (("C-c t" . mw-thesaurus-lookup-dwim)
         ("C-c d" . mw-thesaurus-dictionary-lookup-dwim))
  :hook (mw-thesaurus-mode . variable-pitch-mode)
  :config
  ;; window on the right side
  (add-to-list
   'display-buffer-alist
   `(,mw-thesaurus-buffer-name
     (display-buffer-reuse-window
      display-buffer-in-direction)
     (direction . right)
     (window . root)
     (window-width . 0.3))))

Doom/Evil users may want to remap org specific keys

Doom binds RET in Org buffers to +org/dwim-at-point through evil-org-mode-map, and that minor mode’s keys outrank the thesaurus buffer’s own. Remap the command so RET looks up the word at point:

(map! :after mw-thesaurus
      :map mw-thesaurus-read-only-map
      [remap evil-record-macro] #'mw-thesaurus--quit
      [remap +org/dwim-at-point] #'mw-thesaurus-lookup-at-point)

Commands

mw-thesaurus-lookup-dwim - bind that to any desired hotkey, and it would automatically search for a thesaurus definition using the region (if you have any text selected) or a word at the point, or if there’s nothing - it prompts you for a word.

mw-thesaurus-dictionary-lookup-dwim - the same for the Collegiate Dictionary: pronunciation, inflections, numbered senses with examples, and the word’s history. Dictionary pages show in the same buffer.

If the word has no entry, e.g. because of a typo, the first spelling suggestion shows instead.

Many dictionary entries also explain how close synonyms differ, as “Choose the Right Synonym” does on merriam-webster.com. The Synonym Chooser tab shows these explanations: the words compared, what sets each apart, and an example of each.

Keys available in mw-thesaurus-mode

The header line names the tabs, Thesaurus, Dictionary and Synonym Chooser, plus Spanish and Medical when their keys are set, and marks the one shown; a click on another one switches to it. For a word without a synonym explanation, the Synonym Chooser says so.

RET lookup for the word at the cursor (lets you “drill” into definition further), in the reference shown; from the Synonym Chooser, in the dictionary

o show the word in the next tab

M-1 to M-5 show the word in Thesaurus, Dictionary, Synonym Chooser, Spanish and Medical

l (H with evil) go back to the previous lookup, without a new request

q kill mw-thesaurus buffer and close the window

These keys act while the page is read-only, as it is after every lookup. C-x C-q makes the page writable: then it types them, and evil’s keys work as in any buffer. Bind your own single keys in mw-thesaurus-read-only-map; a key bound in mw-thesaurus-mode-map acts on writable pages too.

C-c C-o open the page on merriam-webster.com

Related packages

wiktionary-bro.el
etymology lookup
define-it
definition lookup
define-word
definition lookup - grabs it from wordnik.com
quick-sdcv
modern fork of much older sdcv.el - interface to Stardict CLI. Lifesaver for when you suddenly have no internet.

About

Merriam-Webster Thesaurus in Emacs

Topics

Resources

Stars

116 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages