簡體   English   中英

Python.el在文檔字符串上錯誤處理了我的M-q縮進

[英]Python.el mishandling my M-q indentations on docstrings

給定一個功能

def foo():
  """
  etc
  stuff
  """
  pass

當我運行Mq到我的文檔字符串段落時,emacs(24.3.1,python.el)會像這樣重新格式化foo:

def foo():
  """etc
  stuff
  """
  pass

我如何告訴python.el不管它? (我知道這種行為是新的,不同計算機上的舊emacs(我無法訪問)不會這樣做)。

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))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM