mmm-mode, python-mode and doctest-mode?

Edward Loper edloper at gradient.cis.upenn.edu
Tue Aug 7 04:58:06 EDT 2007


[John J Lee]
> Is it possible to get doctest-mode to work with mmm-mode and python-mode 
> nicely so that docstrings containing doctests are editable in 
> doctest-mode?

I recently released a new version of doctest-mode [1], and I came across 
your email [2] (it was on the first page of google hits for 
"doctest-mode").  So I decided to have a go at getting doctest-mode to 
play nicely with mmm-mode.  The result is available here:

https://python-mode.svn.sf.net/svnroot/python-mode/trunk/python-mode/doctest-mode.el

I still consider it alpha code (the version that's available for 
download on the official doctest-mode webpage [3] doesn't include the 
mmm-mode features), but it works pretty well for me.  If you want to 
give it a spin, let me know what you think.  The following should load 
everything you need:

(autoload 'doctest-mode "doctest-mode" "doctest mode" t)
(autoload 'doctest-register-mmm-classes "doctest-mode")
(doctest-register-mmm-classes t t)

It defines 2 classes.  Quoting from the docstring for doctest-register- 
mmm-classes:

> `doctest-docstring'
> 
>     Used to edit docstrings containing doctest examples in python-
>     mode.  Docstring submode regions start and end with triple-quoted
>     strings (\"\"\").  In order to avoid confusing start-string
>     markers and end-string markers, all triple-quote strings in the
>     buffer are treated as submode regions (even if they're not
>     actually docstrings).  Use (C-c % C-d) to insert a new doctest-
>     docstring region.  When `doctest-execute' (C-c C-c) is called
>     inside a doctest-docstring region, it executes just the current
>     docstring.  The globals for this execution are constructed by
>     importing the current buffer's contents in Python.
> 
> `doctest-example'
> 
>     Used to edit doctest examples in text-editing modes, such as
>     `rst-mode' or `text-mode'.  Docstring submode regions start with
>     optionally indented prompts (>>>) and end with blank lines.  Use
>     (C-c % C-e) to insert a new doctest-example region.  When
>     `doctest-execute' (C-c C-c) is called inside a doctest-example
>     region, it executes all examples in the buffer.

Take care,
-Edward

[1] doctest-mode 0.4 announcement:
 
http://mail.python.org/pipermail/python-announce-list/2007-August/006038.html

[2] email re mmm-mode:
     http://mail.python.org/pipermail/python-list/2005-November/354482.html

[3] doctest-mode homepage:
     http://www.cis.upenn.edu/~edloper/projects/doctestmode/

[4] doctest-mode walkthrough:
     http://tinyurl.com/25bljc

[5] doctest-mode subversion:
 
https://python-mode.svn.sf.net/svnroot/python-mode/trunk/python-mode/doctest-mode.el





More information about the Python-list mailing list