I think instead of (similar to the I command)
it should be (similar to the A command)
:
A
Accept the word for the rest of this hunspell session.
Let's check the man
page again:
The -a option is intended to be used from other programs through a pipe.
In this mode, hunspell prints a one-line version identification message,
and then begins reading lines of input.
So, when in -a mode
, hunspell
session ends after reading and processing the last line of input. Furthermore,
When in the -a mode, hunspell will also accept lines of single words prefixed
with any of '*', '&', '@', '+', '-', '~', '#', '!', '%', ''', or '^'. A line
starting with '*' tells hunspell to insert the word into the user's dictionary
(similar to the I command)[........] A line prefixed with '#' will cause the
personal dictionary to be saved.
Prefixing a single word line with *
(note there should be no space between word and prefix) will add that word to the user's dictionary but only for the current hunspell
session, since, as per the man
page, only a line prefixed with #
will cause the personal dictionary to be saved (the on-disk file, that is). Hence running
echo "*goosfraba" | hunspell -a
does absolutely nothing. hunspell
adds goosfraba to the dictionary for this session then exits (no other lines to process). You have to add a second line prefixed with #
in order to save the recently added word(s):
echo -e "*goosfraba\n#" | hunspell -a
Let's see:
::spell-checking goosfraba:
echo -e "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
& goosfraba 1 0: goofball
& = Word
is not in the dictionary, there is one near miss: goofball.
::adding goosfraba to the dictionary then spell-checking during the same hunspell
session (two lines):
echo -e "*goosfraba\ngoosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
*
* = Word
is in the dictionary.
::spell-checking goosfraba again (new hunspell
session):
echo -e "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
& goosfraba 1 0: goofball
& = Again, word
is not in the dictionary (nothing was saved during the previous session)
::adding goosfraba to the dictionary and saving during the same hunspell
session (two lines):
echo -e "*goosfraba\n#" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
::spell-checking goosfraba again (new hunspell
session):
echo "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
*
* = Word
is in the dictionary.
So I realise this is an old question, but I seem to keep revisiting this situation and maybe you are too.
KDE uses "Sonnet" these days as the spelling framework. Apparently it can use Hunspell underneath (and also Aspell, which is no longer maintained?)
Anyway, I needed to figure this out myself again today, and wanted to leave a note for posterity... the Sonnet setting in the KDE spell checking (Regional Settings, Spell Check) will cause a silent failure if your particular regional variant is not fully installed - in my case Australian English (en_AU).
Try starting KMail (for example) from a shell and notice:
sonnet.core: Missing trigrams for languages: QSet("en_GB", "en_CA", "en_AU")
So my distro did not automatically pull in my en_AU dictionaries, and setting that region for spelling did not complain about or change that situation.
This may be a source of your problem - also try disabling automatic language detection until you have your dictionary issues sorted.
Best Answer
I solved this for
aspell
.Create a sorted file
aspell_no
containing words you do NOT want spell check to recognize.Run the following code:
Test it:
Get it working in emacs (may need to restart flyspell or emacs to get this to work):