1

There are some words I want flyspell to ignore in some buffers, but not others.

For example, in one buffer I want etaoin to not be flagged by flyspell because in that context it's not a misspelling (because, say, I'm talking about typesetting) -- but in other buffers, that should be considered a misspelled word.

It seems like there could be some way to do this with file-local variables? Something like

# Local Variables:
# flyspell-ignore-words: ("etaoin" "shrdlu")
# End:

so that in that buffer, etaoin and shrdlu would be considered correct, but incorrect elsewhere (if they're not in your dictionary, of course).

Suggestions?

1
  • 1
    Try placing something like this at the bottom of the file -- do not use the Local Variables format for this particular purpose: LocalWords: foo bar baz In addition, you may wish to investigate the variable ispell-buffer-session-localwords .
    – lawlist
    Feb 12, 2023 at 16:32

2 Answers 2

2

I can't directly convert @lawlist's comment into an answer, but it's exactly what I wanted: ispell.el has

(defconst ispell-words-keyword "LocalWords: "
  "The keyword for local oddly-spelled words to accept.
The keyword will be followed by any number of local word spellings.
There can be multiple instances of this keyword in the file.")

For my particular question, you would do

LocalWords: etaoin shrdlu

It seems like, if you really want to use file-local variables, one should be able to also set ispell-buffer-session-localwords to the corresponding list, but I haven't been able to get the quoting and such to work. But since the above is simple and does precisely what I want, there seems to be no need.

(Amusingly, "localwords" gets flagged as misspelled when you add it.)

0

Flyspell relies on an external spell–checker called Ispell (although your OS may come with a substitute such as Aspell instead). It provides no means of ignoring specific words, either on a buffer–local basis or otherwise.

You can choose a different dictionary for a buffer by setting ispell-local-dictionary. You can do so as a file or directory variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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