From: tim_one at email.msn.com (Tim Peters)
Date: Thu, 29 Apr 1999 01:47:02 -0400
Subject: Emacs' python-mode buggy?
In-Reply-To: <7g8np4$kvf@chronicle.concentric.net>
Message-ID: <000901be9203$b4c32e40$199e2299@tim>
Content-Length: 1249
X-UID: 803                                                  

[Christopher Petrilli]
> ...
> WEll, I have noticed some problems with tripple-quoted strings on
> occasion,  but I see similar problems in other modes, so I THINK it's
> something to do with how (x)emacs applie the font-lock-mode parameters.

The Emacs language modes rely on heavy-duty functions written in C to do the
bulk of their parsing.  These Emacs parsing functions are configurable, but
not quite configurable enough to capture all of Python's rules.  In
particular, triple-quoted strings aren't in their repertoire and can't be
added, so given something like

    """
       "Hi!" I'm a doc string
    """

Emacs "sees" it as a sequence of 4 strings with some crap in the middle:

    ""
    "\n        "
    Hi!
    " I'm a doc string\n    "
    ""

elisp is too slow to do the character-at-a-time parsing that would be needed
to fix cases like this, so-- like all other language modes --pymode settles
for what it can get.  AFAIK it should *never* screw up in the absence of
triple-quoted strings, though, and you can help it make sense of those by
pretending you're the Emacs C parsing function, using judicious backslash
escapes until you stop confusing yourself <wink>.

you-want-to-see-a-nightmare-try-perl-mode-ly y'rs  - tim






