On Sun, Feb 11, 2018 at 10:54 AM Nicolas Goaziou wrote: > > Would you mind adding a test to `test-org/auto-fill-function' for good > measure? I was actually adding a test for org-return as the commit doesn't modify the org-auto-fill-function. The test I added was this.. but doesn't work. Can you please help? Interactively, the org-return change works as expected, but the test fails with this: Test test-org/return condition: (ert-test-failed ((should (equal "* Heading :PROPERTIES: :SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled. :END:" (org-test-with-temp-text "* Heading :PROPERTIES: :SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled. :END:" ... ... ... ...))) :form (equal "* Heading :PROPERTIES: :SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled. :END:" "* Heading :PROPERTIES: :SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled. :END:") :value nil :explanation (array-elt 38 (different-atoms (32 "#x20" "? ") (10 "#xa" "? "))))) FAILED 741/764 test-org/return Here's the patch with test included: From 416be7c4b7adddffc0c41bba2a070c8849e16d82 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Sun, 11 Feb 2018 14:37:10 -0500 Subject: [PATCH] Do not auto-fill when point is in Org property drawer * lisp/org.el (org-return): Set auto-fill-function to nil when point is in an Org property drawer. * testing/lisp/test-org.el (test-org/return): Add test. --- lisp/org.el | 8 +++++++- testing/lisp/test-org.el | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index b45cc06187d..b9daba84e6a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21111,7 +21111,13 @@ object (e.g., within a comment). In these case, you need to use (delete-and-extract-region (point) (line-end-position)))) (newline-and-indent) (save-excursion (insert trailing-data)))) - (t (if indent (newline-and-indent) (newline)))))) + (t + ;; Do not auto-fill when point is in an Org property drawer. + (let ((auto-fill-function (and (not (org-at-property-p)) + auto-fill-function))) + (if indent + (newline-and-indent) + (newline))))))) (defun org-return-indent () "Goto next table row or insert a newline and indent. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 17e7a223c48..1792950bba6 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1190,6 +1190,14 @@ (should (equal "| a |\n\n| b |" (org-test-with-temp-text "| a |\n| b |" + (org-return) + (buffer-string)))) + ;; Do not auto-fill on hitting inside a property drawer. + (should + (equal "* Heading\n:PROPERTIES:\n:SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled.\n\n:END:" + (org-test-with-temp-text "* Heading\n:PROPERTIES:\n:SOME_PROP:This is a very long property value that goes beyond the fill-column. But this is inside a property drawer, so the auto-filling should be disabled.\n:END:" + (setq-local fill-column 10) + (auto-fill-mode 1) (org-return) (buffer-string))))) -- 2.15.0 -- Kaushal Modi