This page describes library Synonyms, synonyms.el, by DrewAdams, which lets you search and browse an English thesaurus, the Moby Thesaurus II file, `mthesaur.txt’, which is available here:

So, What's a Thesaurus, Anyway?

Synonyms uses Moby Thesaurus II, but there is nothing special about that. In fact, you could alternatively use any file of comma-separated values (CSV) as your thesaurus. All that matters is that the file is organized as lines of comma-separated values. The first term in each line is in some (navigational) sense treated as an entry. Each of the other terms in the same line are treated as synonyms, which really means only that they are, for some reason, grouped together.

If, for example, you had a CSV file of personal contacts, where the first term in each line was a last name or a company name, then you could use library Synonyms to query it or browse it, producing the same kind of output as for the thesaurus. Similarly, if you had a thesaurus in another language, besides English, you can use that instead.

The thesaurus is divided into entries, which are like glossary entries: each entry is followed by associated words and phrases, which, for lack of a better word, I refer to as synonyms. For example, ‘democracy’ is an entry, and it is followed by its synonyms. Some synonyms are not also entries. For example, ‘patriarchy’ is in the thesaurus as a synonym but not as an entry.

Note: What I call “synonyms” here are not necessarily synonyms, in the sense of having the same or even similar meanings. They are simply terms collected together with the same thesaurus entry because they are related in some way – the grouping is what defines their relation. In Moby Thesaurus II, the meanings of synonyms in the same group do have something in common, but this might be simply the fact that they are terms of a similar kind. For example, the “synonyms” following the ‘democracy’ thesaurus entry are words such as ‘dictatorship’ and ‘autocracy’. These are different forms of the same general thing: government – they are certainly not synonymous with each other or with the entry ‘democracy’.

Using Synonyms

You can use Synonyms to search and browse the thesaurus.

Searching the Thesaurus

The main command is ‘synonyms’. It prompts you for a word or phrase to look up in the thesaurus. The synonyms found are then displayed – simple. For example, `M-x synonyms RET democracy’ displays synonyms for ‘democracy’.

The default input value for command ‘synonyms’ is the word under the cursor or the text in the region (selection), provided that a region is active and you are in TransientMarkMode (recommended).

Your input is actually treated as a regular expression

(regexp), so you can also input patterns like `for.*ion’, which will match thesaurus entries ‘formation’, ‘formulation’, ‘fornication’, ‘fortification’, and `forward motion’. Note that the last of these is a phrase rather than a single word.

Using a regexp as input is a powerful way to search, but be aware that it can be costly in CPU time and computer memory if the regexp is not appropriate. The regexp `.*’ will, for example, likely use up available memory before being able to return the entire thesaurus (it’s very large). You can always use ‘C-g’ to interrupt a thesaurus search if you mistakenly use an inefficient regexp.

Using a Prefix Argument To Do More

You can use a prefix argument to modify searching and the presentation of search results, as follows:

    1. Return also synonyms that are matched partially by the input.
    2. Search the entire thesaurus for input matches, even if the input matches a thesaurus entry.

Preferences (Options)

If you find yourself often using a particular prefix argument (for example, to append results), then you might want to instead change the default behavior to reflect this preference. Options ‘synonyms-match-more-flag’ and ‘synonyms-append-result-flag’ correspond to using ‘C-u’ and ‘M--’, respectively. In fact, a prefix argument simply toggles the value of the corresponding option for the duration of the command. So, for example, if ‘synonyms-append-result-flag’ is ‘t’ and you use ‘M--’, then results will not be appended.

Partially Matching ( `C-u, sense #1)

When partially matching input (‘C-u’, sense #1), complete synonyms are matched against your input. This means that you generally need not add a preceding or trailing `.*’ to try to match a complete synonym. For example, input ‘format’ will match the complete synonyms ‘conformation’, ‘efformation’, ‘format’, ‘formation’, ‘formative’, ‘formational’, ‘information’, ‘informative’, ‘informational’, ‘malformation’, ‘deformation’, ‘reformation’, ‘transformation’, ‘reformatory’, and so on – there is no need to input `.*format.*’ to match the same synonyms.

Searching Beyond Entries ( `C-u, sense #2)

To better understand the meaning of #2 above for ‘C-u’ (to continue the search even if your input matches an entry), try, for example, ‘C-u M-x synonyms RET widespread’. You’ll see not only the main synonyms listed for ‘widespread’ as an entry, but also lots of different meanings of ‘widespread’, judging by the entries for which it is listed as a synonym:

  `accepted', `ample', `broad', `broadcast', `capacious',
  `catholic', `commodious', `commonness', `conventional',
  `currency', `current', `customary', `deep', `deltoid',
  `diffuse', `discrete', `dispersed', `disseminated',
  `dissipated', `distributed', `epidemic', `established',
  `everyday', `expansive', `extended', `extensive', `familiar',
  `fan shaped', `far flung', `far reaching', `flaring', `full',
  `general', `indiscriminate', `infinite', `large scale',
  `liberal', `normal', `normality', `open', `ordinary',
  `outstretched', `pervasive', `popular', `prescribed',
  `prescriptive', `prevailing', `prevalence', `prevalent',
  `public', `rampant', `received', `regnant', `regular',
  `regulation', `reign', `rife', `roomy', `ruling', `run',
  `scattered', `set', spacious`', `sparse', `splay', `sporadic',
  `sprawling', `spread', `standard', `stock', `straggling',
  `stretched out', `sweeping', `time-honored', `traditional',
  `universal', `usual', `vast', `voluminous', `wholesale', `wide
  open', `wide', and `wonted'.

These are just the entries! Each of these is of course followed by its own synonyms - perhaps 100 or 300, including ‘widespread’.

This list of entries is not the same list as the synonyms for entry ‘widespread’. There are words and phrases here that are not in the latter list, and vice versa. For example, the former (but not the latter) list includes ‘full’; the latter (but not the former) list includes ‘wide-reaching’.

The latter are the words most closely related to ‘widespread’. The list above are the other thesaurus entries (corresponding to main categories) to which ‘widespread’ is most closely related. Looking at all of the synonym groups in which ‘widespread’ appears can tell you additional information about its meanings - and it can provide additional synonyms for ‘widespread’.

Using Completion with Synonyms

You can complete words and phrases in the minibuffer, as input to command ‘synonyms’, and you can use Synonyms together with Icicles to complete a partial word in a text buffer into a word or phrase in the thesaurus.

Minibuffer Input Completion

You can enter any text to match against thesaurus synonyms. When you are prompted by command ‘synonyms’ to enter this text, you can also use input completion to complete to a thesaurus synonym. That is, even though you can enter any text (including a regexp), completion will only complete to synonyms in the thesaurus.

Two different versions of the main command, ‘synonyms’, are provided here. If Icicles has already been loaded when you load synonyms.el (recommended), then the second, more powerful version is used; if not, the first version is used. The second takes advantage of all Icicles features. In particular, it lets you:

Completing Text Using the Thesaurus

Icicles provides two commands for using completion to insert thesaurus entries in a buffer:

See Icicles - Multi-Commands for more information on multi-commands.

Browsing the Thesaurus

Besides using command ‘synonyms’ to search for synonyms, you can use Synonyms to browse the thesaurus. This is really just the same thing as searching, but key and mouse bindings are provided in buffer ‘*Synonyms*’, so you need not input anything – just point and click the hyperlinks. Buffer ‘*Synonyms*’ is in Synonyms major mode, which provides a few additional features.

You can still choose to search (browse) for additional synonyms or append search results, without bothering with a prefix argument, by using modifier keys (Control, Meta) with a mouse click:

Easy to remember; easy to use.

Another way of browsing is to revisit previous search-result pages. You can do this using commands ‘synonyms-history-backward’ and ‘synonyms-history-forward’. In buffer ‘*Synonyms*’, these are bound to the following key sequences, for convenience:

The ‘l’ and ‘r’ bindings correspond to the history bindings in InfoMode. The ‘p’ and ‘n’ bindings stand for “previous” and “next”. The bindings to additional mouse buttons correspond to typical bindings for Back and Forward in Web browsers.

In addition to these bindings, the same history commands can be accessed by clicking links [Back] and [Forward] with ‘mouse-2’.

If you have previously used the append option (via, for example, ‘M-mouse2’), so that there are multiple search results in buffer ‘*Synonyms*’, then using a history command simply takes you to the preceding (for [Back]) or following (for [Forward]) result in the buffer, measured from the current cursor position. Depending on the cursor position, this might be different from the previous or next search made previously.

This is for convenience, but it is also more efficient in the case of a regexp search that takes a long time. Except for this special treatment of appended results, whenever you navigate the search-results history you are actually searching again for a synonym you sought previously. The case of appended results is analogous to accessing a Web browser cache when navigating the history.

You can of course use modifier keys (Control, Meta) while you click links [Back] and [Forward], to impose their usual behavior: search for additional synonyms or append search results, or both.

Finally, some people prefer menus, so there is a Synonyms menu bar menu when you are in Synonyms mode, complete with all of the functionalities described above.

For more information on the browsing possibilities in buffer ‘*Synonyms*’, use `?’ in Synonyms mode.

Dictionary Definitions, Antonyms, etc.

Synonyms works with a large but simple database of groups of words and phrases that are synonyms of each other. This database does not provide definitions of words or phrases; it simply groups them. Command ‘synonym-definition’ (aka ‘dictionary-definition’) lets you look up a word or phrase (or a regexp) using one or more dictionaries on the Web. That is usually the best source for this kind of information, but you obviously need an Internet connection to use this command.

Options (variables) ‘synonyms-dictionary-url’ and ‘synonyms-dictionary-alternate-url’ are URLs you can set to point to the dictionaries of your choice. The default value of ‘synonyms-dictionary-alternate-url’ looks up the search term in multiple dictionaries, and it lets you use wildcards. Use `C-h v synonyms-dictionary-alternate-url’ for more information. The default value of ‘synonyms-dictionary-url’ usually provides a quicker answer. Both of these URLs also give you access to additional information about the search term (antonyms, etymology, even pronunciation).

In buffer ‘*Synonyms*’, you can simply hit ‘d’ followed by ‘RET’ or ‘mouse-2’ to look up a term that is in the buffer. Just as for looking up a synonym by clicking ‘mouse-2’, if you select text (region), then that text is looked up.


CategoryCompletion CategoryRegexp CategorySpelling CategoryHypermedia CategoryPersonalInformationManager