flymake-codespell
- Description
- Flymake backend for codespell
- Latest
- flymake-codespell-0.1.0.20231030.222337.tar (.sig), 2024-Mar-31, 30.0 KiB
- Maintainer
- Stefan Kangas <stefankangas@gmail.com>
- Atom feed
- flymake-codespell.xml
- Website
- https://www.github.com/skangas/flymake-codespell
- Browse ELPA's repository
- CGit or Gitweb
- Badge
To install this package from Emacs, use package-install
or list-packages
.
Full description
1. flymake-codespell
This is a codespell backend for 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.
2. 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
3. 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 Flymake manual for more details.
4. 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))
5. 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)))
6. Alternatives
Here are some alternatives to flymake-codespell
:
- flyspell-prog-mode, which comes with Emacs out-of-the-box.
7. Contribute
This library is part of GNU ELPA and therefore requires a copyright assignment to the Free Software Foundation for any non-trivial contributions.
Please email me a patch, or open a pull request on GitHub, according to your preferences.
8. 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 <stefankangas@gmail.com> or report them on GitHub.