Incorrect syntax highlighting with py-underscore-word-syntax-p
When I set py-underscore-word-syntax-p
, function definitions containing the words print
and/or file
are incorrectly highlighted. For example:
def print_this_file():
When _
is treated as a word character, it correctly highlights with print_this_file
in py-def-face
. When _
isn't a word character, it incorrectly highlights with print
in font-lock-keyword-face
, _this_
in default
, and file
in py-builtins-face
. Other keywords and builtins highlight correctly in all cases.
The problem seems to be the font-lock-add-keywords
call to conditionally set the highlighting of print
and file
depending on Python version. That adds the two keywords to the front of font-lock-keywords
, giving them higher priority than function definitions, etc.
According to the docs, font-lock-add-keywords
accepts an optional how argument, and setting that to t
adds the keywords to the end of the list instead of the beginning. That fixes the function def problem for me, but I haven't checked for any other effects it might have.
As an aside, would it be worth having py-python-edit-version
default to "python3" now that Python 2 has been unsupported for a while? As far as I can tell, the only place that's referenced is the print/file keyword setup.
Thanks!