H
Harry George
I would like to change the pre-defined colors in the Emacs
python mode, but I don't have any clue on how to do it.
Somebody can help here?
TIA,
Michele
The coloring is controlled by "font-lock". python-mode.el (found in
e.g., share/emacs/21.3/lisp/progmodes) maps specific words to
font-lock attributes. E.g., "if" is a font-lock-keyword., "print" is
a font-lock-builtin. However, you can probably guess the attributes
you want to change from the font-lock.el, without having to look at
python-mode.el:
(defvar font-lock-comment-face 'font-lock-comment-face
"Face name to use for comments.")
(defvar font-lock-string-face 'font-lock-string-face
"Face name to use for strings.")
(defvar font-lock-doc-face 'font-lock-doc-face
"Face name to use for documentation.")
(defvar font-lock-keyword-face 'font-lock-keyword-face
"Face name to use for keywords.")
(defvar font-lock-builtin-face 'font-lock-builtin-face
"Face name to use for builtins.")
(defvar font-lock-function-name-face 'font-lock-function-name-face
"Face name to use for function names.")
(defvar font-lock-variable-name-face 'font-lock-variable-name-face
"Face name to use for variable names.")
(defvar font-lock-type-face 'font-lock-type-face
"Face name to use for type and class names.")
(defvar font-lock-constant-face 'font-lock-constant-face
"Face name to use for constant and label names.")
(defvar font-lock-warning-face 'font-lock-warning-face
"Face name to use for things that should stand out.")
(defvar font-lock-reference-face 'font-lock-constant-face
"This variable is obsolete. Use `font-lock-constant-face'.")
Once you know the proper font-lock attribute, you can change the color
by settings in you personal .emacs, e.g.:
(defun python-initialise ()
(interactive)
(setq default-tab-width 4)
(setq indent-tabs-mode nil)
(set-face-foreground `font-lock-comment-face "green")
(set-face-background `font-lock-comment-face "red")
)