Can Emacs be set up to display Python code in Python mode and display docstrings in ReST mode?

5

1

I often edit Python code in my Emacs and have it set up to display Python files in Python mode. I often find myself formatting dosctrings as ReStructured Text and I was thinking that it would be great if I could have Emacs show these docstrings as in ReST mode. Is this possible somehow?

Thomas Arildsen

Posted 2015-11-27T13:07:49.020

Reputation: 727

1

Did you have a look at http://www.emacswiki.org/emacs/MultipleModes ?

– fredtantini – 2015-11-27T14:38:26.753

Answers

3

You can try this minor mode

https://github.com/glyph/python-docstring-mode

with that conf:

(add-to-list 'load-path "/path/to/python-docstring-mode-master")
(require 'python-docstring)
(add-hook 'python-mode-hook (lambda () (python-docstring-mode t)))

djangoliv

Posted 2015-11-27T13:07:49.020

Reputation: 171

I have tried installing python-docstring via package. It seems to install OK but is nowhere to be found afterwards and gives an error when I try requireing it. – Thomas Arildsen – 2016-01-22T11:16:08.980

1I don't use package but you can download and unzip it in /path/to/python-docstring-mode-master to have a try – djangoliv – 2016-01-22T11:56:04.717