diff options
| author | Noam Postavsky <npostavs@gmail.com> | 2019-09-08 10:42:19 -0400 |
|---|---|---|
| committer | Noam Postavsky <npostavs@gmail.com> | 2019-09-12 20:25:30 -0400 |
| commit | cbb8a8ad979ed7975bfc7e9fa6aeeb4d9d6b7084 (patch) | |
| tree | d03bb7aa2be38b6bb94936bc4fd51304f879d5c4 /lisp/progmodes/python.el | |
| parent | 421084d2cb160261b259bddb687bb2c234f8f1ef (diff) | |
| download | emacs-cbb8a8ad979ed7975bfc7e9fa6aeeb4d9d6b7084.tar.gz | |
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
test.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 14b65669c4b..ec5d8c55512 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4084,6 +4084,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." (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))) + ;;; 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) #'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) |
