From 91b2398293159120b4021e1a6deece1f330c0825 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 14 Jul 2020 11:46:38 +0200 Subject: [PATCH] Do not fill paragraph before region * lisp/org.el (org-fill-paragraph): Do not fill paragraph before region. * testing/lisp/test-org.el (test-org/fill-paragraph): Add test. Reported-by: Matt Lundin --- lisp/org.el | 3 +-- testing/lisp/test-org.el | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 8bc24789e..12a853bd6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19375,8 +19375,7 @@ filling the current element." (skip-chars-backward " \t\n") (while (> (point) start) (org-fill-element justify) - (org-backward-paragraph)) - (org-fill-element justify)) + (org-backward-paragraph))) (goto-char origin) (set-marker origin nil)))) (t diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 61e642d4f..4f8c74539 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -752,6 +752,15 @@ (push-mark (point) t t) (goto-char (point-min)) (call-interactively #'org-fill-paragraph) + (buffer-string))))) + (should + (equal "012345678 9\n\n012345678\n9" + (org-test-with-temp-text "012345678 9\n\n012345678 9" + (let ((fill-column 10)) + (transient-mark-mode 1) + (push-mark (point) t t) + (goto-char (point-max)) + (call-interactively #'org-fill-paragraph) (buffer-string)))))) (ert-deftest test-org/auto-fill-function ()