* 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
test.
(goto-char (line-end-position))))
t)
+(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))
+ (do-auto-fill)))
+
\f
;;; Skeletons
(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 'normal-auto-fill-function) #'python-do-auto-fill)
(set (make-local-variable 'beginning-of-defun-function)
#'python-nav-beginning-of-defun)
expected)))))
\f
-;;; Autofill
+;;; Filling
(ert-deftest python-auto-fill-docstring ()
(python-tests-with-temp-buffer
(forward-line 1)
(should (= docindent (current-indentation))))))
+(ert-deftest python-fill-docstring ()
+ (python-tests-with-temp-buffer
+ "\
+r'''aaa
+
+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.")
+ (fill-paragraph)
+ (should (= (current-indentation) 0))))
+
\f
;;; Mark