Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skangas/flymake-codespell

Codespell backend for Emacs flymake-mode
https://github.com/skangas/flymake-codespell

Last synced: 7 days ago
JSON representation

Codespell backend for Emacs flymake-mode

Awesome Lists containing this project

README

        

* flymake-codespell

This is a [[https://github.com/codespell-project/codespell][codespell]] backend for [[https://www.gnu.org/software/emacs/manual/html_node/flymake/index.html][Flymake]] in Emacs, used to
automatically highlight errors as you type. It requires Emacs version
26.1 or newer.

Unlike most other spellcheckers, codespell does not have a dictionary
of known words. Instead it has a list of common typos, and checks
only for those. This means that it's far less likely to generate
false positives, especially when used on source code, or any file with
a lot of specific terms like documentation or research.

* Prerequisites

First, install ~codespell~ on your system. For example, if you're
using Debian GNU/Linux, run this command in a terminal:

: sudo apt install codespell

Once codespell is installed, install this package by typing the
following in Emacs:

: M-x package-install RET flymake-codespell RET

* Usage

You must make sure the ~flymake-codespell-setup-backend~ function is
called in the modes where you want to use it. For example, to make
sure it is run in all programming language modes, add the following
line to your init file:

: (add-hook 'prog-mode-hook 'flymake-codespell-setup-backend)

You can substitute ~prog-mode-hook~ for any mode hook. For example,
to add it to all text modes:

: (add-hook 'text-mode-hook 'flymake-codespell-setup-backend)

You must also make sure ~flymake~ is enabled in the same modes. Type
~M-x flymake-mode~ to enable it for the running session, or set up
hooks. For example:

: (add-hook 'prog-mode-hook 'flymake-mode)

See the [[Https://www.gnu.org/software/emacs/manual/html_node/flymake/index.html][Flymake manual]] for more details.

* Usage with use-package

The ~use-package~ can simplify your init file, and is available
out-of-the-box starting with Emacs 29.1. For older versions, you must
first install ~use-package~. Here is a ~use-package~ declaration that
you can copy into your init file:

: (use-package flymake-codespell
: :ensure t
: :hook (prog-mode . flymake-codespell-setup-backend))

This enables ~flymake-codespell~ in all programming language modes,
and automatically installs it the next time you restart Emacs, if it
isn't already.

To add this to several modes, use something like the following:

: (use-package flymake-codespell
: :ensure t
: :hook ((prog-mode . flymake-codespell-setup-backend)
: (text-mode . flymake-codespell-setup-backend)))

Here's a ~use-package~ declaration to unable flymake in the same modes:

: (use-package flymake
: :hook (prog-mode text-mode))

* Customization

To customize ~flymake-codespell~, type:

: M-x customize-group RET flymake-codespell RET

If you prefer adding customizations to your init file, try setting the
variables ~flymake-codespell-program~ and
~flymake-codespell-program-arguments~. These are their default
values:

: (setq flymake-codespell-program "codespell")
: (setq flymake-codespell-program-arguments "")

You could also use this ~use-package~ declaration:

: (use-package flymake-codespell
: :ensure t
: :custom ((flymake-codespell-program "codespell")
: (flymake-codespell-program-arguments ""))
: :hook ((prog-mode . flymake-codespell-setup-backend)
: (text-mode . flymake-codespell-setup-backend)))

* Alternatives

Here are some alternatives to ~flymake-codespell~:

- [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Spelling.html#index-flyspell_002dprog_002dmode][flyspell-prog-mode]], which comes with Emacs out-of-the-box.

* Contribute

This library is part of [[https://elpa.gnu.org/packages/url-scgi.html][GNU ELPA]] and therefore requires a [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Copyright-Assignment.html][copyright assignment]]
to the [[https://www.fsf.org/][Free Software Foundation]] for any non-trivial contributions.

Please email me a patch, or open a pull request on GitHub, according
to your preferences.

* Contact

You can find the latest version of flymake-codespell here:

https://www.github.com/skangas/flymake-codespell

Bug reports, comments, and suggestions are welcome! Send them to
Stefan Kangas or report them on GitHub.

#+DATE: 2022-12-09
#+AUTHOR: Stefan Kangas
#+EMAIL: [email protected]