# describe-word(3)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

describe-word - Display a dictionary definition of a word

## SYNOPSIS

describe-word "word"

## DESCRIPTION

describe-word can be used to interface to an external dictionary to get a definition of a given word. The interface has two modes of interface, the first simply launches an external program which provides the definition in its own user interface, e.g. MS Bookshelf. The second interface launches an external program which prints out the definition to `stdout`, MicroEmacs can then pull out the definition and display it in describe-word's own GUI.

When executed describe-word will use the current word under the cursor as the initial word or will prompt the user if the cursor is not in a word.

When describe-word's dialog is used the information presented is defined as follows:

Word

The word being defined, the entry can be edited and the new word will be automatically looked-up when the edit is completed.

Insert

The effect of this button is dependent on where describe-word was executed. If executed from the Meaning button within the spell checker the Word entry is changed to the current word. When executed outside the spell checker the definition of the current word is inserted into the current buffer.

Exit

Closes the dialog.

Main definition box

Displays the definition of the current word. The user can select a new word to describe by clicking the left mouse button on any word within the current definition.

## NOTES

describe-word is a macro implemented in `word.emf`.

Due to the size and availability of dictionaries etc. MicroEmacs is released without describe-word set up, the user must setup it up.

describe-word must be setup for each required language as follows:

1)

A command-line interface to a dictionary of the required language must be found. This could simply be a text file containing one word definition per line and using grep(1) as the command-line interface. In this example the text file could take the following form:

    A () The first letter of the English...
    Aam (n.) A Dutch and German measure of liquids...
    Aardvark (n.) An edentate mammal...
    .
    .

The grep command-line interface required to look-up the word "`aardvark`" would be:

    grep -i "^aardvark (" words.txt

The output produced from this will be the single line giving the required definition. A second common interface would be executing an external dictionary program typically using a command-line option to specify the word to define, e.g.:

    mydict -d "aardvark"

2)

The MicroEmacs language name must be found, this can be done by first using user-setup(3) or spell-buffer(3) to ensure that the current language is set the the require one and then running describe-word. The command will probably fail, but before it does it will set the variable `.describe-word.lang`, use the command describe-variable(2) to get the value of this variable, this value is the internal language name. For example, when the current language is American or American (Ext) the language name is `american`.

3)

To execute the command-line interface the variable `.describe-word.`<language>`-command` must be set to the command-line required to obtain a word definition with the string "`%s`" used in place of the word and "`%%`" using in place of a single "`%`". For the first example in (1) above the following would be required:

    set-variable .describe-word.american-command ...
            ... "grep -i \"^%s (\" /tmp/words.txt"

For the second example:

    set-variable .describe-word.american-command "mydict -d \"%s (\""

4)

Only required for the second mode, for use with describe-word's own GUI, the setting of another variable is required, the presence of this variable determines which mode is to be used.

The variable `.describe-word.`<language>`-search` must be set to a regex search pattern which will match the required definition(s) in the command out put, the first group ("`\(...\)`") must enclose the required definition, again "`%s`" can be used in place of the word and "`%%`" for a single "`%`". describe-word simply uses search-buffer(2) repeatedly to find all definitions of the current word, it then uses the value of the variable @s1(4) to get the individual definitions. For example for the first example the following is required:

    set-variable .describe-word.american-search  "^\(%s (.*\)\n"

Note that the word being defined should be kept in the definition if possible as the spell rules are used to look-up base words when a derivitive of a word is not found, therefore the word being defined may not be clear (e.g. deactivate can be derived from activate but their meanings are very different). Also long text lines are automatically wrapped by the GUI.

The required variables should be added to the user setup file.

## SEE ALSO

spell-buffer(3).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>