diff options
author | Kaushal Modi <kaushal.modi@gmail.com> | 2018-02-11 14:37:10 -0500 |
---|---|---|
committer | Kaushal Modi <kaushal.modi@gmail.com> | 2018-02-11 15:19:49 -0500 |
commit | fe7619cd184847227e9c1085b4f3c13a553f007b (patch) | |
tree | 693bee24c41d50455ccfa2cde6453ea7f0ef7157 | |
parent | 38bf7561d04647efd32ac4c6d13cc7612bbafde7 (diff) | |
download | org-mode-fe7619cd184847227e9c1085b4f3c13a553f007b.tar.gz |
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.
<http://lists.gnu.org/r/emacs-orgmode/2018-02/msg00102.html>
-rw-r--r-- | lisp/org.el | 8 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el index b45cc06..b9daba8 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 17e7a22..6bea90a 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1191,6 +1191,14 @@ (equal "| a |\n\n| b |" (org-test-with-temp-text "| a |<point>\n| b |" (org-return) + (buffer-string)))) + ;; Do not auto-fill on hitting <RET> 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.<point>\n:END:" + (setq-local fill-column 10) + (auto-fill-mode 1) + (org-return) (buffer-string))))) (ert-deftest test-org/meta-return () |