WcheckMode

Download

Download the code from GitHub repository, from Melpa or Marmalade package archive.

Note: There have been some backward-incompatible changes in 2011-06-29 and some of the configuration options used in previous versions do not work anymore. The previous “spelling suggestions” feature has been generalized to “actions” feature. Now user can configure any kind of actions for marked text, not just spelling suggestions. Please read the documentation of variable ‘wcheck-language-data’ and README text in the source repository.

Introduction

Wcheck mode is a general-purpose text-checker interface for Emacs text editor. Wcheck mode a minor mode which provides an on-the-fly text checker. It checks the visible text area, as you type, and possibly highlights some parts of it. What is checked and how are all configurable.

Wcheck mode can use external programs or Emacs Lisp functions for checking text. For example, Wcheck mode can be used with spell-checker programs such as Ispell, Enchant and Hunspell, but actually any tool that can receive text from standard input stream and send text to standard output can be used. Wcheck mode sends parts of buffer’s content to an external program or an Emacs Lisp function and, based on their output, decides if some parts of text should be marked in the buffer.

Features

In Wcheck mode’s configuration different configuration units are called “languages”. In terms of a spelling checker it is natural to think of them as different human languages. Wcheck mode is not limited to that, though. Language is just a configuration unit for certain kind of text checking purpose.

Each language can use its own checker engine (external program or a function), command-line arguments and other settings, such as the regular expressions and syntax table that are used to match words (or other text elements) in Emacs buffer. User can choose which “face” is used to mark text elements in buffer.

User can create language-specific and major mode specific settings defining which “faces” to read or skip in buffers. A typical use for this feature is to spell-check only those areas in buffer which are written in the target language. For example, in email messages usually the message body and Subject header are important enough to spell-check. In programming modes user could spell-check only documentation strings and comments (or the opposite if you want to use Wcheck mode to check keywords and syntax of the programming language itself).

Wcheck mode can also be configured to offer any kind of actions for marked text. Actions are presented to user through a menu which is activated either by (1) clicking the right mouse button on a marked text or (2) executing interactive command ‘wcheck-actions’ while the cursor (the point) is on a marked text.

If you use Wcheck mode as a spelling checker then it’s natural to configure an action menu that offers spelling suggestions for the misspelled word. The action menu could also have an option to add the marked word to spell-checker’s dictionary, so that the word is recognized in the future. That’s only one application for Wcheck mode, though. Wcheck mode can be configured to find almost any kind of text elements from buffer, mark them, and offer any kind of actions for marked text.

How does it compare to other spell-checkers?

The open design makes Wcheck mode (internally) quite different from spell-checkers like Flyspell mode and Speck mode. They are specific tools for spell-checking through Ispell or compatible program and are therefore very much tied to Ispell’s features and command-line interface. This can be useful if you want to use Ispell or fully compatible program for spell-checking natural languages. However, not all human languages can be supported through Ispell and there can also be other kind of text-checking needs.

The motivation behind Wcheck mode is to offer more general-purpose and configurable interface for text checking. It can be configured to work with almost anything: user’s custom shell, Awk or Perl scripts, Lisp functions or other checkers and text filters. Even if you only need a spelling checker for human languages Wcheck mode can be a good choice. It has more configuration possibilities than other spell-checkers and the on-the-fly checker performs very well. It’s a true real-time checker.

Install

Put wcheck-mode.el file to some directory in your Emacs’s ‘load-path’ and add the following lines to Emacs’s initialization file (~/.emacs):

    (autoload 'wcheck-mode "wcheck-mode"
      "Toggle wcheck-mode." t)
    (autoload 'wcheck-change-language "wcheck-mode"
      "Switch wcheck-mode languages." t)
    (autoload 'wcheck-actions "wcheck-mode"
      "Open actions menu." t)
    (autoload 'wcheck-jump-forward "wcheck-mode"
      "Move point forward to next marked text area." t)
    (autoload 'wcheck-jump-backward "wcheck-mode"
      "Move point backward to previous marked text area." t)

Configuration and basic usage

The internal documentation of variable ‘wcheck-language-data’ has a complete description on how to configure Wcheck mode language data. For easy configuration you can use the options in the customize group named wcheck (M-x customize-group RET wcheck RET).

It might be convenient to bind Wcheck mode commands to some easily accessible keys, for example:

    (global-set-key (kbd "C-c s") 'wcheck-mode)
    (global-set-key (kbd "C-c l") 'wcheck-change-language)
    (global-set-key (kbd "C-c c") 'wcheck-actions)
    (global-set-key (kbd "C-c n") 'wcheck-jump-forward)
    (global-set-key (kbd "C-c p") 'wcheck-jump-backward)

Interactive command ‘wcheck-mode’ toggles the text-checker for the current buffer. Command ‘wcheck-change-language’ is used to switch languages and command ‘wcheck-actions’ (or the right mouse button) opens an actions menu for marked text. Commands ‘wcheck-jump-forward’ and ‘wcheck-jump-backward’ jump to next or previous marked text area.

Examples

See the README file for configuration examples. Wcheck mode users are encouraged to put their configuration examples here, though.


CategorySpelling