The manual for aspell
is at http://aspell.net/man-html/index.html
Firstly, from http://aspell.net/man-html/Spellchecking-Individual-Files.html#Spellchecking-Individual-Files
If the mode option is not given, then Aspell will use the extension of
the file to determine the current mode. If the extension is .tex, then
tex mode will be used, if the extension is .html, .htm, .php, or .sgml
it will check the file in sgml mode, otherwise it will use url mode.
http://aspell.net/man-html/Notes-on-Various-Filters-and-Filter-Modes.html#Notes-on-Various-Filters-and-Filter-Modes describes the different filter modes. These include
--mode=none
4.4.1.1 None Filter Mode
The none mode is exactly what it says. It turns off all filters.
and
--mode=tex
4.4.1.6 TeX/LaTeX Filter
The tex (all lowercase) filter mode skips over TeX commands and
parameters and/or options to certain commands.
So running as you do either with --mode=tex
or without a mode switch will check the parts of the file that are not macro names. In particular, on your sample file
aspell --lang=en check test.tex
aspell --lang=en --mode=tex check test.tex
both return no errors, whereas
aspell --lang=en --mode=none check test.tex
catches all the macros including valid ones such documentclass
.
Running LaTeX itself is the quickest way to check validity of names of macro constructions. On your file latex test
gives
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo))
! Undefined control sequence.
l.3 \begunn
{document}
?
indicating that \begunn
is not known.
There do exist lint like programs for Latex, see Is there a program equivalent to lint for LaTeX?, which capture some incorrect constructions, but they will not tell you whether a macro name is known to LaTeX for fundamental reasons from the way the system is built up. See How to lint for undefined control sequence? for a discussion.
--mode=tex
means that it skips macro names.aspell --lang=en check /tmp/test.tex
too.