Choose the Right Dictionary Before Running ispell
You will finish with a repeatable way to ask Debian's ispell-wrapper for a language, inspect the exact ispell command it would run, and avoid selecting the wrong dictionary through an overly broad regular expression. The wrapper is supplied by dictionaries-common, version 1.29.7 on the system used for this guide.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about fifteen minutes. You need a Debian system with dictionaries-common, at least one compliant ispell dictionary package, and an ispell executable if you intend to run the final command. The examples inspect configuration first. They do not install packages, change the system-wide default, or edit a dictionary.
1. Confirm the wrapper and its prerequisite
Check that the wrapper is installed, then check for the program it ultimately invokes:
$ command -v ispell-wrapper
/usr/bin/ispell-wrapper
$ command -v ispell
/usr/bin/ispell
The second line is an example of the expected result. If command -v ispell prints nothing, stop at this checkpoint. The wrapper exits before language selection with the message ispell-wrapper is a wrapper to ispell, but ispell is not installed. Installing an ispell implementation and a dictionary is an administrative change, so use your normal package review and approval process rather than guessing a package name.
On this guide's machine the wrapper is installed, but /usr/bin/ispell is absent. That is why the remaining command examples are verified invocations for a machine with the prerequisite installed, not claims that the final spell check ran here.
2. See the configured language sources
The wrapper can obtain a language from several places. The priority is fixed:
--emacs=name, when supplied.--language=regexp, when supplied.- The
ISPELLDEFAULTenvironment variable. - Your
$HOME/.ispell-defaultfile. - The system file
/etc/dictionaries-common/ispell-default.
This order explains a common distraction: changing a default file will not affect a command that already supplies --language, and --language will not win against --emacs. Inspect the non-secret inputs before troubleshooting:
printf 'ISPELLDEFAULT=%s\n' "${ISPELLDEFAULT-<unset>}"
if test -f "$HOME/.ispell-default"; then
printf 'user default: '
cat "$HOME/.ispell-default"
else
printf '%s\n' 'user default: <not set>'
fi
printf 'system default: '
cat /etc/dictionaries-common/ispell-default
An empty system file is not an error by itself. It means the wrapper has no value at that level and must find a language from an earlier source or from the installed dictionaries' own selection data. Do not put passwords or unrelated shell syntax in these files: they contain a language name or matching value, not a command to execute.
3. Prefer an exact emacs dictionary name when you know it
Use --emacs when an editor integration has given you the exact emacs dictionary name:
$ ispell-wrapper --emacs=english --dry-run sample.txt
--
ispell -d ... -w ... -T ... sample.txt
--
The flags shown as ... are deliberately not fixed values. The installed dictionary package supplies the appropriate -d, -w, and -T settings, and those settings vary by language. The dry run prints the assembled command without executing it, which is the safest way to check selection before opening a file in an interactive spell checker.
The emacs name match is case-insensitive but exact. If it does not match an installed emacs dictionary name, the wrapper reports the available values and stops. When both --emacs and --language are present, the emacs name takes precedence and the wrapper warns that the language value was overridden.
4. Use a narrow language regular expression
If you do not have an emacs name, select an installed language with --language:
$ ispell-wrapper --language='span.*8' --dry-run sample.txt
--
ispell -d ... -w ... -T ... sample.txt
--
The expression is matched against installed language names, without regard to case. ISO-8859-1 accented letters are converted to ASCII equivalents for matching. The expression must identify exactly one language. A match that finds none is an error; a match that finds more than one is also an error.
For example, if the installed names include castellano (Spanish TeX mode) and castellano8 (Spanish 8 bit), the expression span is ambiguous. A narrower expression such as span.*8 selects the 8-bit entry. Treat an ambiguity as a configuration problem. Do not rely on whichever result happens to be encountered last.
5. Test an environment-based default without changing files
ISPELLDEFAULT is useful for a session, a wrapper script, or a service environment. Set it only for the command you are testing:
$ ISPELLDEFAULT='span.*8' ispell-wrapper --dry-run sample.txt
--
ispell -d ... -w ... -T ... sample.txt
--
This does not write to your shell's environment permanently and does not alter either default file. The environment value is considered only when --language was not supplied, so inspect the command line if changing it appears to have no effect.
Pass ordinary ispell options after the wrapper's long options and finish with the file to check. If you explicitly pass an option beginning with -d, the wrapper discards the dictionary parameters it selected, because you have chosen the dictionary yourself. That is an advanced escape hatch: it can defeat the language's matching word and character settings, so use it only when you understand the target dictionary.
6. Run the selected command
Once the dry run shows the expected dictionary parameters, remove --dry-run:
$ ispell-wrapper --language='span.*8' sample.txt
This starts ispell with the wrapper's generated options. It may modify the file when you accept corrections, depending on ispell's normal behaviour and the options you pass. Before using it on an important document, copy the file or use version control. Recovery is then the normal restore or revert operation for that copy; the wrapper itself has no undo command and no backup policy of its own.
For automation, keep the language selection explicit and test the exit status of the complete command. Do not parse the dry-run text as a stable API: it is intended for inspection, while the wrapper's job is to assemble and execute an ispell command.
Done means
dictionaries-common, a compliant dictionary, and theispellexecutable are present.- You know which of the five language sources supplies the selected value.
- An exact emacs name or a regular expression matching one language is used.
--dry-runshowed the generated-d,-w, and-Toptions before execution.- You did not confuse an ambiguous match with a successful selection.
- Important documents have a recoverable copy before corrections are accepted.