Is there python code highlighting in emacs ?

Harry George hgg9140 at cola.ca.boeing.com
Thu Mar 22 09:33:49 EST 2001


You solution looks a bit complex.  I'm using:
  (add-hook 'python-mode-hook 'turn-on-font-lock)
as in:

(load "python-mode")
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode)
            interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
(add-hook 'python-mode-hook 'turn-on-font-lock)
(setq python-mode-hook 'python-initialise)
(defun python-initialise ()
  (interactive)
  (setq default-tab-width 4)
  (setq indent-tabs-mode nil))


John McMonagle <jmcmonagle at velseis.com.au> writes:

> > 
> > > >
> > > > The hilit19 package in emacs provides keyword highlighting when editing
> > > > code.  For example, if you are writing in C, comments are italicised in
> > > > red, strings are in grey, import statements are in lavender, functions
> > > > are in bold-blue, etc.
> > > >
> > > > Does anyone know if there is python support in the hilit19 emacs lisp
> > > > package ?
> > >
> > > I don't know about hilit19, but I use python-mode which highlights
> > > using font-lock-mode. Comes with GNU Emacs 20.whatever. Try M-x
> > > python-mode and see if anything happens.
> > >
> > > python-mode does many other useful things, too. I can't imagine
> > > working without it at this point.
> > >
> > 
> > I already use python-mode which works fine for indenting, etc.  How do I
> > configure this font-lock-mode for python  ? What do I add to my .emacs
> > file ?
> > 
> 
> Worked it out.
> 
> Add the following to your .emacs file:
> 
> (add-hook 'python-mode-hook '(lambda() (font-lock-mode 1)))
> 
> 

-- 
Harry George                E-mail:  harry.g.george at boeing.com
The Boeing Company          Renton:  (425) 237-6915
P. O. Box 3707  02-CA       Everett: (425) 266-3868
Seattle, WA 98124-2207      Page:    (425) 631-8803  



More information about the Python-list mailing list