Reputation: 40319
Given a function
def foo():
"""
etc
stuff
"""
pass
when I run M-q to paragraph up my docstrings, emacs (24.3.1, python.el) will reformat foo like this:
def foo():
"""etc
stuff
"""
pass
How do I tell python.el to leave it alone? (I know this behavior is new, an older emacs on a different computer (that I don't have access to) didn't do this).
Upvotes: 4
Views: 403
Reputation: 122052
What python.el
is doing is actually the Python convention (albeit without a blank line after the first line) - see PEP-0257's example:
def complex(real=0.0, imag=0.0):
"""Form a complex number.
Keyword arguments:
real -- the real part (default 0.0)
imag -- the imaginary part (default 0.0)
"""
if imag == 0.0 and real == 0.0:
return complex_zero
Looking at the source code for python.el
, the parameter to alter this behaviour is 'python-fill-docstring-style'
, which defaults to pep-257
but offers some alternatives:
:type '(choice
(const :tag "Don't format docstrings" nil)
(const :tag "Django's coding standards style." django)
(const :tag "One newline and start and Two at end style." onetwo)
(const :tag "PEP-257 with 2 newlines at end of string." pep-257)
(const :tag "PEP-257 with 1 newline at end of string." pep-257-nn)
(const :tag "Symmetric style." symmetric))
Upvotes: 4