i'm setting emacs python ide, , i've found plenty of material online explain auto-completion, among variety of other features. can't figure out, though, how syntax highlighter highlighting magic on operators.
how can customize emacs in python mode make + - different colors? i'd make integers, floats, , parentheses different colors well.
i have setup programming modes. defines 2 separate faces, 1 operators , 1 "end statement" symbol (not useful in python, obviously). can modify "\\([][|!.+=&/%*,<>(){}:^~-]+\\)"
regex match operators interested in , customize faces color want.
(defvar font-lock-operator-face 'font-lock-operator-face) (defface font-lock-operator-face '((((type tty) (class color)) nil) (((class color) (background light)) (:foreground "dark red")) (t nil)) "used operators." :group 'font-lock-faces) (defvar font-lock-end-statement-face 'font-lock-end-statement-face) (defface font-lock-end-statement-face '((((type tty) (class color)) nil) (((class color) (background light)) (:foreground "darkslateblue")) (t nil)) "used end statement symbols." :group 'font-lock-faces) (defvar font-lock-operator-keywords '(("\\([][|!.+=&/%*,<>(){}:^~-]+\\)" 1 font-lock-operator-face) (";" 0 font-lock-end-statement-face)))
then, enable adding hook relevant modes (this example assumes using "python-mode"):
(add-hook 'python-mode-hook '(lambda () (font-lock-add-keywords nil font-lock-operator-keywords t)) t t)
Comments
Post a Comment