emacs python mode problem

Andrew McGregor andrew at indranet.co.nz
Tue Jan 28 02:36:48 EST 2003


--On Monday, January 27, 2003 22:58:59 -0800 Erik Max Francis 
<max at alcyone.com> wrote:

> Chris Fonnesbeck wrote:
>>
>> I've become a little frustrated with the python indenting in python
>> mode for emacs. I have tried setting the indent to 4 spaces both via
>> the configuration menu and by hand in my .emacs file:
>>
>> '(setq-default py-indent-offset 4)
>
> Hmm, it doesn't look like that quote should be there.

That quote effectively turns the line into a comment (it turns a function 
call into a list constant, and then does nothing with it).

If however you're quoting part of something like this from my 
.xemacs/custom.el then it's OK (but notice the different syntax).

(custom-set-variables
 '(paren-mode (quote sexp) nil (paren))
 '(lazy-shot-mode t nil (lazy-shot))
 '(fast-lock-mode t nil (fast-lock))
 '(line-number-mode t)
 '(py-indent-offset 4)
 '(font-lock-mode t nil (font-lock)))

>> However, when editing python files, from time to time the indentation
>> falls back to 8 spaces. Anyone have an idea as to why this may be
>> happening?

Because your settings are wrong, and python mode guessed the indentation 
was 8 spaces.

> I've been using python-mode since I first came on the Python scene and
> I've never seen anything like that.  Could it be that the Python files
> you're editing contain the little #-*- (or whatever they are; I've never
> used them myself) indenting hints?  (I don't even know to what extent
> these are supported, this is an off-the-wall answer.)

Those are always supported in (recent versions of) emacs, so yes, if the 
magic emacs comments in the code (at beginning or end of the file) say 
something other than the default, they prevail.

Andrew





More information about the Python-list mailing list