10.1.2 Searching, Replacing, And Spell Checking

Incremental search, a process by which the system prompts the user for a search string and moves the selection to the next available match while allowing the user to add more characters to the search string, is the search technique of choice among most Emacs users. As the system successively finds each match, it provides the user the option of continuing the search. Incremental search is a more complex instance of traditional search interaction because in addition to either stopping or continuing the search, the user can modify the current search in a number of ways including specifying a longer (or shorter) search string.

All of the user commands available during incremental search are documented in the online Emacs info manual. These are speech-enabled by Emacspeak to provide spoken prompts as the dialog begins; auditory icons indicate a search hit or search miss as the search progresses. Along with auditory icons search-hit and search-miss the user also hears the current line spoken, and in the case of a search hit, the matching text is aurally highlighted by using the standard audio formatting technique of changing voice characteristic. This feedback proves extremely effective when the search pattern appears several times on a single line; the user is unambiguously cued to the current match.

Search and replace actions are an extension to the basic conversational gestures of a search dialog. In addition to specifying a search string, the user also specifies a replacement string. On the Emacspeak desktop, this functionality is provided by command query-replace. The speech-enabled version of this interaction prompts the user for the search and replacement texts. The auditory feedback during the interactive search and replacement process parallels that described in the case of incremental search. Audio formatting to indicate the occurrence that is about to be replaced proves an effective means of avoiding erroneous modifications to the text being edited. As an example, consider using command query-replace to locate and replace the second occurrence of foo with bar in the text

Do not change this fool, but change this food.

When the search matches the first occurrence of foo in word fool, the aural highlighting helps the user in answering “no” in response to question “should this occurrence be replaced”. In addition to allowing the user to supply a simple “yes or no” answer for each match, command query-replace also allows the user to specify a number of other valid answers as described in the online Emacs documentation.

Spell Checking

A more complex instance of conversational gesture “search and replace” is exhibited by standard spell checking dialogues. Spell checking differs from the search and replace dialog described above in that the search and replacement text is guessed by the system based on an available dictionary. Words that are not found in the dictionary are flagged as potential spelling errors, and the system offers an interactive search and replace dialog for each of these possible errors. During this dialog, the system successively selects each occurrence of the possibly erroneous word and offers a set of possible replacements. Unlike in the case of simple search and replace, more than one possible replacement string is offered, since a potential spelling error can be corrected by more than one word appearing in the dictionary.

In the visual interface, such spell checking dialogues are realized by displaying the available choices in a pop-up window and allowing the user to pick a correction Once a correction is selected, the user is offered the choice of interactively replacing the erroneous word with the correction.

The spell checking interface on the Emacspeak desktop is speech-enabled to provide fluent auditory feedback. The visual interface parallels that described above and is provided by package ispell which is part of the standard Emacs distribution. Emacspeak provides a spoken prompt that is composed of the line containing the possibly erroneous word (which is aurally highlighted to set it apart from the rest of the text on that line) and the available corrections. Each correction is prefixed with a number that the user can use to select it. Once a correction is selected, the interaction continues with the query and replace interaction described earlier. The speech interface to the spell checker is as fluent as the visual interface. Notice that Emacspeak users do not need to concern themselves with the details of the visual display such as “the corrections are displayed in a window at the top of the screen”.

In addition to the standard spell checker described above, newer versions of Emacs include an “on-the-fly” spell checker that flags erroneous words as they are typed. Emacspeak speech-enables package flyspell so that such erroneous words are aurally highlighted.