Commit cbb8a8ad authored by Noam Postavsky's avatar Noam Postavsky
Browse files

Fix fill-paragraph in python docstrings (Bug#36056)

* lisp/progmodes/python.el (python-do-auto-fill): New function.
(python-mode): Set it as normal-auto-fill-function, and don't set
fill-indent-according-to-mode.  Having the latter set during
fill-paragraph gives wrongs result, because python-indent-line doesn't
remove indentation added by filling.
* test/lisp/progmodes/python-tests.el (python-fill-docstring): New
parent 421084d2
......@@ -4084,6 +4084,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'."
(goto-char (line-end-position))))
(defun python-do-auto-fill ()
"Like `do-auto-fill', but bind `fill-indent-according-to-mode'."
;; See Bug#36056.
(let ((fill-indent-according-to-mode t))
;;; Skeletons
......@@ -5379,7 +5385,7 @@ REPORT-FN is Flymake's callback function."
(set (make-local-variable 'paragraph-start) "\\s-*$")
(set (make-local-variable 'fill-paragraph-function)
(set (make-local-variable 'fill-indent-according-to-mode) t) ; Bug#36056.
(set (make-local-variable 'normal-auto-fill-function) #'python-do-auto-fill)
(set (make-local-variable 'beginning-of-defun-function)
......@@ -1351,7 +1351,7 @@ this is an arbitrarily
;;; Autofill
;;; Filling
(ert-deftest python-auto-fill-docstring ()
......@@ -1368,6 +1368,17 @@ def some_function(arg1,
(forward-line 1)
(should (= docindent (current-indentation))))))
(ert-deftest python-fill-docstring ()
this is a test this is a test this is a test this is a test this is a test this is a test.
(search-forward "test.")
(should (= (current-indentation) 0))))
;;; Mark
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment