I sometimes experience "color bleeding" in auctex, and wasn't able to find the source of the problem for a long time. In particular because I wasn't able to reproduce the issue. I also can't post documents where it occurred because they contain non public data, are complex, not minimal etc.
Now I noticed that the problem is gone if I comment out the following sections of my init.el:
(defcustom pm-inner/python (pm-inner-chunkmode "python" :head-matcher "\\\\begin{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}\\(\\[[^]\\]+]\\)?" :tail-matcher "\\\\end{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}" :mode 'python-mode) "python typical chunk." :group 'innermodes :type 'object) (defcustom pm-poly/latex-python (pm-polymode "latex-python" :hostmode 'pm-host/latex :innermodes '(pm-inner/python)) "latex-python typical polymode." :group 'polymodes :type 'object) (define-polymode poly-latex+python-mode pm-poly/latex-python) (add-to-list 'auto-mode-alist '("\\.tex$" . poly-latex+python-mode)) It is a polymode configuration for automatically going to python mode inside a latex document if python-chunks (inside a pycode environment for example) occur.
So do you have any idea, why this code could lead to color bleeding and how to investigate it further (in particular to get a reproducible minimal example which shows the problem).
$in yourpycodeenvironment and that causes the bleeding?\\(\\[[^]\\]+]\\)?is wrong; it should read"\\(\\[[^]]+\\]\\)?"