Correcting words with flyspell via custom interface.
Emacs Lisp
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.org

flyspell-correct

https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg

flyspell-correcthttp://melpa.org/packages/flyspell-correct-badge.svghttps://stable.melpa.org/packages/flyspell-correct-badge.svg
flyspell-correct-ivyhttp://melpa.org/packages/flyspell-correct-ivy-badge.svghttps://stable.melpa.org/packages/flyspell-correct-ivy-badge.svg
flyspell-correct-helmhttp://melpa.org/packages/flyspell-correct-helm-badge.svghttps://stable.melpa.org/packages/flyspell-correct-helm-badge.svg
flyspell-correct-popuphttp://melpa.org/packages/flyspell-correct-popup-badge.svghttps://stable.melpa.org/packages/flyspell-correct-popup-badge.svg

Correcting words with flyspell via custom interface.

Read intro post

This package provides functionality for correcting words via custom interfaces. There are two functions for this: flyspell-correct-word-generic to correct word at point, flyspell-correct-previous-word-generic to correct any visible word before point and flyspell-correct-next-word-generic to correct any visible word after point. In most cases second function is more convenient (at least in my opinion), so don’t forget to bind it.

(define-key flyspell-mode-map (kbd "C-;") #'flyspell-correct-previous-word-generic)

When invoked, it will show the list of corrections suggested by Flyspell. Most interfaces also allow you to save new word to your dictionary, accept this spelling in current buffer or for a whole session.

Default interface is implemented using completing-read, but it’s highly advised to use flyspell-correct-ido (which comes bundled with this package) or any interface provided by following packages: flyspell-correct-ivy, flyspell-correct-helm and flyspell-correct-popup.

Using flyspell-correct-dummy interface

In order to use flyspell-correct-dummy interface you have to install flyspell-correct package in any preferred way and then add following snippet to relevant part of your init.el file.

(require 'flyspell-correct)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic)

This is the only bundled interface that does not allow to save or accept current spelling.

Using flyspell-correct-ido interface

In order to use flyspell-correct-ido interface you have to install flyspell-correct package in any preferred way and then add following snippet to relevant part of your init.el file.

(require 'flyspell-correct-ido)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic)

Using flyspell-correct-ivy interface

In order to use flyspell-correct-ivy interface you have to install flyspell-correct-ivy package in any preferred way and then add following snippet to relevant part of your init.el file.

(require 'flyspell-correct-ivy)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic)

Note that in order to access save actions in ivy interface you need to press M-o. More on ivy mini buffer key bindings you can read in official documentation.

Using flyspell-correct-helm interface

In order to use flyspell-correct-helm interface you have to install flyspell-correct-helm package in any preferred way and then add following snippet to relevant part of your init.el file.

(require 'flyspell-correct-helm)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic)

Using flyspell-correct-popup interface

In order to use flyspell-correct-popup interface you have to install flyspell-correct-popup package in any preferred way and then add following snippet to relevant part of your init.el file.

(require 'flyspell-correct-popup)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic)

Custom interfaces

One can easily implement custom interface for flyspell-correct-word-generic and flyspell-correct-previous-word-generic. It has to be function that takes two arguments - candidates and misspelled word. It has to return either replacement word or (command, word) tuple that will be passed to flyspell-do-correct. Check flyspell-correct-popup for example of interface that uses this feature.

Auto correction mode

/Take my advice and don’t use this functionality unless you find flyspell-correct-previous-word-generic function useless for your purposes. Seriously, just try named function for completion. You can find more info in this comment./

This package also provides auto correction minor mode called flyspell-correct-auto-mode. When enabled it will automatically invoke flyspell-correct-previous-word-generic after certain delay configured by flyspell-correct-auto-delay when there is at least one misspelled word.

(add-hook 'flyspell-mode-hook #'flyspell-correct-auto-mode)

One can also configure interface specially for flyspell-correct-previous-word-generic called by flyspell-correct-auto-mode by setting value of flyspell-correct-auto-mode-interface.

Reasoning

There are already packages like helm-flyspell and flyspell-popup. So why would anyone create yet another similar package? The reason is simple - to support another interface or completion system. flyspell-correct started because ivy was missing similar to helm-flyspell package. But I didn’t want to create a package just for ivy. The reasoning is simple - all those packages should have similar functionality but different interface. Adding something new to one if these packages ideally should be reflected in all others. So I decided to create generic package that works with any interfaces. It’s not about one package containing all possible interfaces, but about package that gives you functionality with interface of your choice.

Screenshots

Ivy interface

images/screenshot-ivy-1.png

images/screenshot-ivy-2.png

Popup interface

images/screenshot-popup.png

Helm interface

images/screenshot-helm.png

Acknowledgements

This package is available thanks to these people:

Additional thanks to all contributors: