I use mmm-mode in order to add python code in LaTeX. So i have something like this in my emacs config:
(use-package mmm-mode
:ensure t
:config
(mmm-add-group 'latex-python
'((latex-python-envs
:submode python-mode
:face mmm-default-submode-face
:front "\\\\begin{\\(pycode\\|pyverbatim\\)}.*\n"
:back "\\\\end{~1}\n"
:save-matches 1)
(latex-python-cmds
:submode python-mode
:face mmm-default-submode-face
:front "\\\\pyc?{"
:back "}")))
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'latex-mode nil 'latex-python))
It works, namely the python code is highlighted and formatted in the block between begin{pycode} end{pycode}
However, flyspell does not recognize the python mode in the block, so it thinks that errors are almost everywhere. The code is highlighted as erroneous. How to tell flyspell that the block has python code?
ispell-skip-region-alist
orispell-tex-skip-alists
works for ispell but not for flyspell.