Fix python docstring auto-fill (Bug#36056)

* lisp/progmodes/python.el (python-mode): Set
fill-indent-according-to-mode locally to t.  This lets auto-fill do
the right thing when auto-filling inside a docstring.  The default was
to nil on 2001-11-25 "(fill-indent-according-to-mode): Default to nil"
with the comment that it "screws up CC-mode's filling tricks".  But
presumably it shouldn't be a problem for python-mode.
* test/lisp/progmodes/python-tests.el (python-auto-fill-docstring):
New test.
This commit is contained in:
Noam Postavsky 2019-06-21 07:49:22 -04:00
parent f46b16b9fb
commit 0f01a58c39
2 changed files with 19 additions and 0 deletions

View file

@ -5379,6 +5379,7 @@ REPORT-FN is Flymake's callback function."
(set (make-local-variable 'paragraph-start) "\\s-*$")
(set (make-local-variable 'fill-paragraph-function)
#'python-fill-paragraph)
(set (make-local-variable 'fill-indent-according-to-mode) t) ; Bug#36056.
(set (make-local-variable 'beginning-of-defun-function)
#'python-nav-beginning-of-defun)

View file

@ -1340,6 +1340,24 @@ this is an arbitrarily
(should (string= (buffer-substring-no-properties (point-min) (point-max))
expected)))))
;;; Autofill
(ert-deftest python-auto-fill-docstring ()
(python-tests-with-temp-buffer
"\
def some_function(arg1,
arg2):
\"\"\"
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
(auto-fill-mode +1)
(goto-char (point-max))
(newline)
(search-backward "Lorem")
(let ((docindent (current-indentation)))
(forward-line 1)
(should (= docindent (current-indentation))))))
;;; Mark