2

Whenever I run flyspell-buffer (using hunspell) in a LaTeX-document, my comments marked with % are spell-checked aswell, although I don't want them to be spell-checked. The simplest solution (setq ispell-check-comments nil) does not do anything. I also tried to let ispell ignore all lines commented out by % with

    (defun flyspell-ignore-TeX-comments ()
    "Ignore lines starting with %."
    (not (string-match "^ *%" (thing-at-point 'line t))))
    (put 'text-mode 'flyspell-mode-predicate 'flyspell-ignore-TeX-comments)

This did not do anything either. The comments are recognized as such, though, since they are colored by font-lock-comment-face. I have explicitly turned off flyspell-prog-mode with (add-hook 'prog-mode-hook 'turn-off-flyspell t).

And now for the weirdest part. When I go to Tools -> Spell-Checking -> Customize, emacs tells me that ispell Check Comments is toggled off and if I spell-check my document with Tools -> Spell-Checking -> Spell-Check Buffer, they are ignored as intended, but if I run M-x flyspell-buffer RET, they are not!

Does anyone have an idea what I did wrong?

1

flyspell and ispell are two different packages.

Yes, flyspell does use a bit of APIs of ispell.

But it does not mean you can set any flag of ispell to tweak flyspell. It's very possible the flag has no impact on the limited APIs which flyspell uses.

To use your predicate, you need run (flyspell-mode 1) at least once.

It's because flyspell-mode-on will load your per major mode predicate flyspell-ignore-TeX-comments into flyspell-generic-check-word-predicate.

Code from flyspell-mode-on, enter image description here

flyspell-mode and flyspell-prog-mode are two minor modes to automate the spelling check. You can only turn on one of them.

By default, they are not turned on. So I don't understand why you need turn off flyspell-prog-mode.

I'm not sure (add-hook 'prog-mode-hook 'turn-off-flyspell t) can turn off flyspell-prog-mode. To turn off flyspell-prog-mode, you need (flyspell-prog-mode -1).

BTW, you can use https://github.com/redguardtoo/wucuo instead of flyspell-mode or flyspell-prog-mode.

1
  • Thanks for your answer! I now switched to wucuo. There, you can just set the font-faces wucuo is supposed to check (and I set them to font-lock-string-face. Simply turning flyspell-mode on did not work, unfortunately, but that might be because there's something wrong with my function. Jun 15 '21 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.