Indentation using XEmacs

When in Python mode, xemacs uses 8 spaces for each indent level by default. This value can be changed by inserting the following lines in the xemacs startup file (e.g.: ~/.xemacs/custom.el).

(custom-set-variables
 '(py-indent-offset 4))

This works, if xemacs opens an empty file or if the file has been created using 4 spaces for each indent level. Otherwise xemacs creates a local variable that reflects how the file was edited so far. You can check the value of py-indent-offset by

M-x describe-variable py-indent-offset

Suppose we edit the following file:

#!/usr/local/bin/python

def func():
        print( "hello world"   # indent level: 8 spaces)

func()

The commnd M-x describe-variable py-indent-offset produces the following output:

`py-indent-offset' is a variable declared in Lisp.
  -- loaded from "python-mode"

Value: 8

This value is specific to the current buffer.

Default-value: 4

Documentation:
*Amount of offset per level of indentation.
`C-c :' can usually guess a good value when
you're editing someone else's Python code.

To solve this problem you have to indent the line print( "Hello world") manually to 4 spaces, then invoke the emacs command "C-c :" (py-guess-indent-offset).