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: ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mthes10.zip.
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
‘autocracy’. These are different forms of the same general thing: government – they are certainly not synonymous with each other or with the entry
You can use Synonyms to search and browse 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
Your input is actually treated as a regular expression (regexp), so you can also input patterns like `for.*ion’, which will match thesaurus entries
‘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.
You can use a prefix argument to modify searching and the presentation of search results, as follows:
‘C-u’– Search for additional synonyms, in two senses:
‘M--’– Append the search results to the any previous results, in buffer
‘*Synonyms*’. (Normally, the new results replace any previous results.)
‘C-u C-u’– This is the same as
‘M--’: Search more and append results.
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-append-result-flag’ correspond to using
‘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
‘t’ and you use
‘M--’, then results will not be appended.
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
‘reformatory’, and so on – there is no need to input `
.*format.*’ to match the same synonyms.
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
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
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
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.
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:
‘S-TAB’during completion to see the list of all synonyms (thesaurus terms) that match your minibuffer input so far.
‘C-o’, `C-[next]’, and `[C-prior]’ during completion to display the synonyms of the current completion candidate.
Icicles provides two commands for using completion to insert thesaurus entries in a buffer:
‘icicle-complete-thesaurus-entry’completes a word in a text buffer to any word or phrase in the thesaurus. I bind it to `
‘icicle-insert-thesaurus-entry’inserts thesaurus words and phrases in a text buffer. It is a multi-command, which means that, within a single call to it, you can insert any number of thesaurus entries, in succession. If you want to, you can write an entire book using a single call to
See Icicles - Multi-Commands for more information on multi-commands.
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:
‘C-mouse-2’– same as
‘M-mouse-2’– same as
‘C-M-mouse-2’– same as
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-forward’. In buffer
‘*Synonyms*’, these are bound to the following key sequences, for convenience:
‘r’ bindings correspond to the history bindings in InfoMode. The
‘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
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.
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
‘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.
‘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).
‘*Synonyms*’, you can simply hit
‘d’ followed by
‘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.
Enjoy! – DrewAdams