syntax highlightening

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")
)
 
M

Michele Simionato

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
 
M

Michael Hudson

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?

Move point over the color you want to change. Execute "M-x
customize-face", hit return and play around.

There may be a more systematic way of doing this, but I don't know
what...

Cheers,
mwh

--
> Look I don't know. Thankyou everyone for arguing me round in
> circles.
No need for thanks, ma'am; that's what we're here for.
-- LNR & Michael M Mason, cam.misc
 
M

Michele Simionato

<snip>

That was very interesting. I will try it and see what I can get.
Thanks,


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,459
Latest member
Vida00R129

Latest Threads

Top