wasm-demo/demo/ermis-f/python_m/cur/0404

64 lines
2.7 KiB
Plaintext

From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw)
Date: Thu, 29 Apr 1999 11:15:12 -0400 (EDT)
Subject: Emacs' python-mode buggy?
References: <al8wvywphai.fsf@myntti.helsinki.fi>
Message-ID: <14120.30592.807745.732604@anthem.cnri.reston.va.us>
Content-Length: 2444
X-UID: 404
>>>>> "MS" == Markus Stenberg <mstenber at cc.Helsinki.FI> writes:
MS> At least by my experiences the Emacs mode (at least, two
MS> versions I tried, 3.75 and whatever came with Python 1.5.2)
MS> seems to have tons of bugs; to be more precise, it seems to
MS> think a lot more of my code than should be is string (and
MS> therefore is green and indentation doesn't work).
MS> Funny thing is, it's colored properly when I load file but
MS> when I start editing some files' some parts, they turn green
MS> (comment-ish) and indentation starts to suck.
MS> Indentation being fairly neccessary feature for Python coding,
MS> is there some option I am missing or am I fucked? (read:
MS> forced to use vim or something)
Contrary to what Tim says, pymode was so buggy when I got it from him
that I renamed that pile of elisp `perl-mode' and rewrote the stuff
from scratch. Tim being a clever bot embedded himself in three elisp
defuns in the Python 1.5.2 version of the file. If you look at the
code closely you'll see that every 19,453rd time he gets run, he
decides to muck up your syntax coloring "just for the fun of it".
Okay, like Tim I lied too (about the "clever bot" part, and maybe
about the rest of it).
Since you don't say, let me make some educated guesses. Are you
running XEmacs (v20.something or 21.0)? In the code in question, do
you have an open parenthesis in column zero someplace higher up in a
triple quoted string (say a module docstring f'r instance)?
This is a known lose on XEmacs -- but it's not a bug caused by pymode.
XEmacs, and older versions of Emacs, makes an assumption that any
character with `open' syntax (e.g. `(', `[', `{') in column zero
starts a top level definition and thus short circuits X/Emacs'
built-in parsing primitives. Works great for Lisp and C; useless
suckage for Python. Unfortunately, AFAIK there's no way to disable
this in Python buffers under XEmacs.
The clue is the broken font-lockage for comments. This is all
controlled by primitives driven by syntax tables, so there's little
that pymode (or pymode's Legion of Corruptors) can mess up.
So the answer is: don't put open parens in column zero inside triple
quoted strings.
Hope that answers it. If not, hit C-c C-b in a python-mode buffer,
include a complete code sample and recipe for me to reproduce the
problem, and email the message to python-mode at python.org
-Barry