[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 0f01a58 3/4: Fix python docstring auto-fill (Bug#36
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] master 0f01a58 3/4: Fix python docstring auto-fill (Bug#36056) |
Date: |
Sat, 22 Jun 2019 19:27:28 -0400 (EDT) |
branch: master
commit 0f01a58c390faf30c33b369fc81b2a14ec5b7f2e
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
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.
---
lisp/progmodes/python.el | 1 +
test/lisp/progmodes/python-tests.el | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 188bc97..e1f9a33 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -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)
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index a517909..87cee18 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1341,6 +1341,24 @@ this is an arbitrarily
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
(ert-deftest python-mark-defun-1 ()