GNU ELPA - jinx

jinx

Description
Enchanted Spell Checker
Latest
jinx-0.8.tar, 2023-Apr-28, 100 KiB
Maintainer
Daniel Mendler <mail@daniel-mendler.de>
Website
https://github.com/minad/jinx
Browse ELPA's repository
CGit or Gitweb
Badge
Manual
jinx

To install this package, run in Emacs:

M-x package-install RET jinx RET

Full description

GNU Emacs GNU ELPA GNU-devel ELPA MELPA MELPA Stable

Jinx is a fast just-in-time spell-checker for Emacs. Jinx highlights misspelled words in the text of the visible portion of the buffer. For efficiency, Jinx highlights misspellings lazily, recognizes window boundaries and text folding, if any. For example, when unfolding or scrolling, only the newly visible part of the text is checked if it has not been checked before. Each misspelling can be corrected from a list of dictionary words presented as a completion menu.

Installing Jinx is straight-forward and configuring takes not much intervention. Jinx can safely co-exist with Emacs's built-in spell-checker.

Jinx's high performance and low resource usage comes from directly calling the widely-used API of the Enchant library (see libenchant). Jinx automatically compiles jinx-mod.c and loads the dynamic module at startup. By binding directly to the native Enchant API, Jinx avoids the slower backend process communication with Aspell. Thanks to the Enchant API, this method is widely used by other text editors and supports Nuspell, Hunspell, Aspell and a few lesser known backends.

Jinx supports spell-checking multiple languages in the same buffer. See the jinx-languages variable to customize for multiple languages. Jinx can flexibly ignore misspellings via faces (jinx-exclude-faces and jinx-include-faces), regular expressions (jinx-exclude-regexps), and programmable predicates. Jinx comes preconfigured for the most important Emacs major modes. For modes listed in jinx-camel-modes composite words in camelCase and PascalCase are accepted.

1 Installation

Jinx can be installed from GNU ELPA and MELPA directly or with package-install.

Jinx requires libenchant. Enchant library is a required dependency for Jinx to compile its module at install time. If pkg-config is available when installing Jinx, Jinx will use pkg-config to locate libenchant.

On Debian or Ubuntu, install the packages libenchant-2-dev and pkg-config. On Fedora or RHEL, install the package enchant2-devel. On Mac, install enchant2 and pkgconfig.

2 Configuration

Jinx has two modes: the command, global-jinx-mode activates globally; and the command, jinx-mode, for activating for specific modes.

;; Alternative 1: Enable Jinx globally
(add-hook 'emacs-startup-hook #'global-jinx-mode)

;; Alternative 2: Enable Jinx per mode
(dolist (hook '(text-mode-hook prog-mode-hook conf-mode-hook))
  (add-hook hook #'jinx-mode))

Jinx autoloads the commands jinx-correct and jinx-languages. Invoking jinx-correct corrects the misspellings. Binding jinx-correct to M-$ chord takes over that chord from Emacs's default assignment to ispell word. Since Jinx is independent of the Emacs's Ispell package, M-$ can be re-used.

(keymap-global-set "<remap> <ispell-word>" #'jinx-correct)
  • M-$ triggers correction for the misspelled word before point.
  • C-u M-$ triggers correction for the entire buffer.

A sample configuration with the popular use-package macro is shown here:

(use-package jinx
  :hook (emacs-startup . global-jinx-mode)
  :bind ([remap ispell-word] . jinx-correct))

3 Correcting words

Suggested corrections are displayed as a completion menu. You can press digit keys to quickly select a suggestion. Furthermore the menu offers options to save the word temporarily for the current session, in the personal dictionary or in the file-local variables. Note that you can enter arbitrary input at the correction prompt in order to make the correction. By pressing M-n (M-p) again in the correction menu, you can skip to the next (previous) misspelling.

The completion menu is compatible with all popular completion UIs: Vertico, Mct, Icomplete, Ivy, Helm and of course default completion. In case you use Vertico I suggest that you tweak the completion display via vertico-multiform-mode for the completion category jinx. You can for example use the grid display such that more suggestions fit on the screen.

(add-to-list 'vertico-multiform-categories
	     '(jinx grid (vertico-grid-annotate . 25)))
(vertico-multiform-mode 1)

4 Enchant backends and personal dictionaries

Enchant uses different backends for different languages. The backends are ordered as specified in the personal configuration file ~/.config/enchant/enchant.ordering and the system-wide configuration file /usr/share/enchant-2/enchant.ordering. Enchant uses Hunspell as default backend for most languages. There are a few exceptions. For English Enchant prefers Aspell and for Finnish and Turkish special backends called Voikko and Zemberek are used. On non-Linux operating systems Enchant may also integrate with the spell-checker provided by the operating system.

Depending on the backend the personal dictionary will be taken from different locations, e.g., ~/.aspell.LANG.pws or ~/.config/enchant/. It is possible to symlink different personal dictionaries such that they are shared by different spell checkers. See the Enchant manual for details.

5 Alternative spell-checking packages

There exist multiple alternative spell-checking packages for Emacs, most famously the builtin ispell.el and flyspell.el packages. The main advantages of Jinx are its automatic checking of the visible text, its sharp focus on performance and the ability to easily use multiple dictionaries at once. The following three alternative packages come closest to the behavior of Jinx.

  • jit-spell: Jinx UI borrows ideas from Augusto Stoffel's Jit-spell. Jit-spell uses the less efficient Ispell process communication instead Jinx's calling native API. Since Jit-spell highlights misspellings in the entire buffer and does not confine to just the visible text, Jit-spell affected load and latency negatively in my tests (issue on github).
  • spell-fu: The idea to check words just in the visible text came from Campbell Barton's spell-fu package. Spell-fu is fast but incurs high memory overhead on account of its dictionary in a hash table. For languages with compound words and inflected word forms, this overhead magnifies (issue on codeberg). By accessing the Enchant API directly, Jinx avoids any overhead. Jinx also benefits from the advanced spell-checker algorithms of Enchant (affixation, compound words, etc.).
  • flyspell: Flyspell is Emacs's built-in package. Flyspell highlights misspellings while typing. Only the word under the cursor is spell-checked. Jinx, on the other hand, is more effective because it automatically checks for misspellings in the entire visible text of the buffer at once. Flyspell can check the entire buffer but must be instructed to do so via the command flyspell-buffer.

6 Contributions

Since this package is part of GNU ELPA contributions require a copyright assignment to the FSF.

Old versions

jinx-0.7.tar.lz2023-Apr-2117.4 KiB
jinx-0.6.tar.lz2023-Apr-1716.3 KiB
jinx-0.5.tar.lz2023-Apr-0515.6 KiB
jinx-0.4.tar.lz2023-Mar-2714.5 KiB
jinx-0.3.tar.lz2023-Mar-2714.0 KiB
jinx-0.2.tar.lz2023-Mar-2611.1 KiB

News

1 Version 0.8 (2023-04-28)

  • jinx-correct: Consistently move backward to the previous misspelling. In order to move backward further, press M-$ again (or M-p). Move forward with M-n.
  • jinx-correct-select: Support more than 10 quick keys.
  • jinx-languages: New argument LANGS.
  • Add jinx-faces customization group.
  • Add configurable save actions via jinx--save-keys.
  • Detect C compiler via $CC or executable-find.

2 Version 0.7 (2023-04-21)

  • Bugfixes
  • jinx-languages: Only ask in file-backed buffers if file-local variable should be saved.
  • Push undo-boundary before correcting a word, such that corrections are not undone in a single step.
  • jinx-correct: Use + as prefix to add word to the current session.
  • Add jinx-correct-map bound in the jinx-correct minibuffer.
  • Add navigation keys to correction UI. The commands jinx-correct-next and jinx-correct-previous are bound to the keys M-n and M-p in the jinx-correct-map respectively. The commands accept prefix arguments to skip over a number of misspellings.
  • Add quick selection keys to correction UI. The command jinx-correct-select is bound to the keys 1 to 9 in the jinx-correct-map.
  • Try to locate the native module jinx-mod.so first on the load-path before attempting to compile it. This is useful if the module is packed and installed separately.

3 Version 0.6 (2023-04-17)

  • Fix the type of a few characters: . punctuation character, ' word character, % and $ identifier characters.
  • Abandon flyspell-mode-predicate completely. Rely on faces only.
  • jinx-languages: The value must be a string now. Multiple language codes can be separated by space.
  • jinx-languages: Ask if the file-local variable should be saved when changing the language.
  • Add jinx-local-words to save file-local words. jinx-correct supports saving to jinx-local-words by pressing *.
  • Add a lighter and a minor mode menu.
  • Avoid scheduling the idle timer while typing a word.

4 Version 0.5 (2023-04-05)

  • Add jinx-languages command to switch languages locally or globally.
  • jinx-correct: When checking the whole buffer via C-u M-$, don't restore original point position upon C-g to ease cursory edits. Instead push a mark which can be used to go back to the original position.
  • Add jinx-mode-map to make it easy to bind keys if jinx-mode is enabled. The map is empty by default.
  • Ignore single quotes and apostrophes at the beginning and end of words. Please provide feedback if this is a reasonable approach.
  • Support spell checking of camelCased words via the jinx-camel-modes variable.

5 Version 0.4 (2023-03-27)

  • jinx-languages: Fall back to $LANG environment variable, since current-locale-environment is an Emacs 29 addition.
  • jinx--mod-wordchars: Handle non-UTF8 return values gracefully.
  • jinx-correct: Always start from nearest overlay.
  • jinx-misspelled: Use less obtrusive color for the underlining.

6 Version 0.3 (2023-03-27)

  • Add jinx-misspelled-map.
  • jinx-correct: Unfold invisible line when correcting misspellings.
  • jinx-correct: Show number of misspellings.
  • Add emacs-module.h to avoid compilation problems.
  • jinx-languages: Use current-locale-environment by default.

7 Version 0.2 (2023-03-26)

  • Start of changelog.