给定函数
def foo():
"""
etc
stuff
"""
pass当我在文档字符串上运行M到段落时,emacs (24.3.1,python.el)会像这样重新格式化foo:
def foo():
"""etc
stuff
"""
pass我该如何告诉python.el不要管它呢?(我知道这种行为是新的,在另一台计算机(我无法访问)上的老emacs没有这样做)。
发布于 2014-05-20 17:38:52
python.el正在做的实际上是Python约定(尽管在第一行之后没有空行)-参见PEP-0257的示例:
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看看python.el,改变这种行为的参数是'python-fill-docstring-style',它默认为pep-257,但提供了一些替代方案:
: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))https://stackoverflow.com/questions/23765887
复制相似问题