From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#36056: Regression? (Python Documentation String Indent In Auto Fill Mode) Date: Sun, 08 Sep 2019 10:46:40 -0400 Message-ID: <87zhjealrj.fsf_-_@gmail.com> References: <7310965c-3f16-a013-ed9d-736ad7b8b8be@lycos.com> <878sqzztlc.fsf@secretsauce.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="260979"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 36056@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 08 16:47:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i6yTA-0015na-0B for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Sep 2019 16:47:12 +0200 Original-Received: from localhost ([::1]:49062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6yT8-00035R-Ub for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Sep 2019 10:47:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6yT2-000357-2M for bug-gnu-emacs@gnu.org; Sun, 08 Sep 2019 10:47:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6yT0-0000tF-Lm for bug-gnu-emacs@gnu.org; Sun, 08 Sep 2019 10:47:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6yT0-0000rd-Db for bug-gnu-emacs@gnu.org; Sun, 08 Sep 2019 10:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i6yT0-0000Mo-9C for bug-gnu-emacs@gnu.org; Sun, 08 Sep 2019 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Sep 2019 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36056 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 36056-submit@debbugs.gnu.org id=B36056.15679540101393 (code B ref 36056); Sun, 08 Sep 2019 14:47:02 +0000 Original-Received: (at 36056) by debbugs.gnu.org; 8 Sep 2019 14:46:50 +0000 Original-Received: from localhost ([127.0.0.1]:39025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i6ySo-0000MO-7J for submit@debbugs.gnu.org; Sun, 08 Sep 2019 10:46:50 -0400 Original-Received: from mail-io1-f45.google.com ([209.85.166.45]:43317) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i6ySm-0000MB-RP for 36056@debbugs.gnu.org; Sun, 08 Sep 2019 10:46:49 -0400 Original-Received: by mail-io1-f45.google.com with SMTP id u185so22973983iod.10 for <36056@debbugs.gnu.org>; Sun, 08 Sep 2019 07:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=xlW3Fg+/WfuGg7X07N5hFFwlyqAYIi2HcwigCZwObrE=; b=rlX5MtrXjsk3Q+Ibns0LZJUgGwi2xICJQINTHcBKUSGkM+LOS+d0coB+6a5PvRZTFp cmTnew+KuLCpk8+37it8t+eQgvel8gHIJZjfGNdAhQTCP7XhOsnr1CXdKEe7H0FjoaDg syL49HF9xdxqHJw0401xn2Ku4HrtLNklyllIFbXtGaEj4wG5TwnVcZn0hzrJ3njNBwZO zKN7QWhjmjtF435gow83Y+LOtpE6w4fnH2oGnbMLYmi18fuGwXaDtQ+MzHWt/5tY/sNN WieSK3MCy+alzcrV8dk4IcznpRbrcE1q4nzKQcP285H0pIdeJ1Rf8hqiQD/SqkFBhrsr qBDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=xlW3Fg+/WfuGg7X07N5hFFwlyqAYIi2HcwigCZwObrE=; b=dyA8CmOqB8sWr9CLG7DpIjJsO+ptKTDB8wJKMU3USydKm3eKRB9zIUJYStsM/hRMuT F57GGQg9FkndyJiBBZTUQ3Wmdy7YUtfOEGLo61JUJXV0f734TExTGpfZsDVzB6mdQxPP wa5ifI4K4pl6cRcsR934CD+6N/FUWntaSHWtnnU5fRio0AgtbgnMOuRAymMunBDXiFeF qa6iwwQ5qFAKk+sONCQeY8tTILauEO8wgJXv7v3cNB8Fju1DpHBs/lzYuFk9E9D+d0jU bIH9N9uFs3qbes87NFqsBdq6NeWAYC3SIqTvkeSLRMAl9pLRgH44say8sMicnDk2/QOO enxw== X-Gm-Message-State: APjAAAVcuvQuWLNXQwur1F4Jo5cKN9b3vFMzgSBYhXnvprn4slIqJlxt DBDsNeAVlzql2sLdYNP9oQDxOWBd X-Google-Smtp-Source: APXvYqxFQFcCf0/cc2C5Vplvfi4gBfpsS0QARmxJK5FzHLr4O5STGZMrq4DA9pQ2BHdVw+W6SORW5Q== X-Received: by 2002:a6b:590b:: with SMTP id n11mr341761iob.256.1567954003104; Sun, 08 Sep 2019 07:46:43 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id s201sm30473712ios.83.2019.09.08.07.46.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Sep 2019 07:46:42 -0700 (PDT) In-Reply-To: <878sqzztlc.fsf@secretsauce.net> (Dima Kogan's message of "Sat, 07 Sep 2019 14:26:07 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:166299 Archived-At: --=-=-= Content-Type: text/plain Dima Kogan writes: > This is what I'd expect. After the fix (i.e. if > fill-indent-according-to-mode is t) I get this: > > > 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 > > ''' > > > For some reason it now wants to add one space at the beginning of every > line in a paragraph except the first. Is there some interpretation where > this the "correct" behavior? Thanks for reporting this. The problem seems to be that fill-newline puts the space on the new line when breaking the line, and python-indent-line (which is called when fill-indent-according-to-mode is t) leaves indentation inside strings as-is. Maybe the solution is to bind fill-indent-according-to-mode only during auto-filling? The patch below seems to work for both this bug's OP, and your case. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-fill-paragraph-in-python-docstrings-Bug-36056.patch Content-Description: patch >From 46a01b97025ed2f826af4237044bad5262e06c6a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 8 Sep 2019 10:42:19 -0400 Subject: [PATCH] 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. --- lisp/progmodes/python.el | 8 +++++++- test/lisp/progmodes/python-tests.el | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 14b65669c4..ec5d8c5551 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4084,6 +4084,12 @@ python-fill-paren (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 @@ python-mode (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) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index b1cf7e8806..c5ad1dfb86 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1351,7 +1351,7 @@ python-indent-region-5 expected))))) -;;; Autofill +;;; Filling (ert-deftest python-auto-fill-docstring () (python-tests-with-temp-buffer @@ -1368,6 +1368,17 @@ python-auto-fill-docstring (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)))) + ;;; Mark -- 2.11.0 --=-=-=--