Python.el在docstrings上错误处理我的Mq缩进

Pau*_*han 4 python emacs

给定一个功能

def foo():
  """
  etc
  stuff
  """
  pass
Run Code Online (Sandbox Code Playgroud)

当我运行Mq到我的文档字符串段落时,emacs(24.3.1,python.el)会像这样重新格式化foo:

def foo():
  """etc
  stuff
  """
  pass
Run Code Online (Sandbox Code Playgroud)

我如何告诉python.el不管它?(我知道这种行为是新的,不同计算机上的旧emacs(我无法访问)不会这样做).

jon*_*rpe 5

什么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
Run Code Online (Sandbox Code Playgroud)

查看源代码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))
Run Code Online (Sandbox Code Playgroud)