Emacs' python-mode buggy?

Tim Peters tim_one at email.msn.com
Thu Apr 29 01:47:02 EDT 1999


[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






More information about the Python-list mailing list