heimatlos
heimatlos

Reputation: 229

Python highlighting in emacs

I am using emacs 23 -nw and xterm installed on Debian Squeeze. I need highlighting with python but I don't have it. How can I enable it?

Edit: Thanks for all answers, the problem is that

Sorry my question was not very precise and I even accept -10 but I don't have highlight which would give me red highlight for lines starting # etc. To be more precise I have a very a dull highlight; lines with # are white, lines between """ """ are green, some of the variable names are yellow but don't know why not all. [import, as, from] are light blue, [open, max, and other function names] are dark blue etc. And besides my 200 lines of code is working.

Upvotes: 3

Views: 5265

Answers (3)

Inaimathi
Inaimathi

Reputation: 14065

If you run Emacs from xterm with emacs -nw, you'll have a different color layout than if you run the same color mode in an X window. Differences include big changes in the highlighting of comments, different colors assigned to various keywords and (rarely in my experience, though Python comments seem to fall into this category) failure to highlight some elements.

I'm not really sure why this happens, but it doesn't seem to be a problem on your end since it's consistent on every machine I've worked on. If it really bugs you, and you really, really want to keep running from xterm, take a look at the color-theme module, it may help.

Upvotes: 1

jjlin
jjlin

Reputation: 4703

Emacs 23 should know about Python out of the box. Does the name of your Python file end with .py, or does the file have #!/usr/bin/env python as the first line? If you're creating a new file, make sure the filename ends with .py. You can also use M-x python-mode as mentioned in another answer. If none of that works, check that your terminal actually supports color.

Upvotes: 1

mj_
mj_

Reputation: 6447

I'm not sure if this is right, but try the following.

1) M-x

2) type in "python-mode". Tab completion works here so type in "pyth" and hit tab and you can see what your options are.

mj

Upvotes: 2

Related Questions