I've been able to partially modify how emacs highlights syntax of python files. For example I find highlighting the definition of variable to be disturbing and I've done this
'(font-lock-constant-face ((t (:foreground "#2aa198" :weight normal))))
'(font-lock-keyword-face ((t (:foreground "#859900" :weight normal))))
'(font-lock-variable-name-face ((t (:foreground "#839496")))))
But I'd also like imports to be highlighted with different color, stop highlighting "sys.exit()" as a constant etc, treat print as a builtin function, not as keyword etc. So I need to change how emacs parses python code. In vim you can do this by creating a custom syntax file and placing it in special folder, how to do the same for emacs?
from abc import ABC
print('some')
map(int, ('1',))
int('1')
@cached
def name(a, abc='abc'):
pass
name(1, abc='bca')
The right one is how I want syntax highlighting to look and the left one is emacs.
M-x customize-face
. If you want to change how Emacs identifies a particular section of code within a python file to highlight, then please edit your question with a minimal example that we can all copy to our own computer to duplicate what you see, and also specify how you wish to change the default behavior. E.g., maybe you want to create your own face and use that instead of the default face, or maybe you want something not to be highlighted, or maybe ...load-path
, so not that different from Vim.