소스 검색

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>
Kaushal Modi 7 년 전
부모
커밋
fe7619cd18
2개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      lisp/org.el
  2. 8 0
      testing/lisp/test-org.el

+ 7 - 1
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.

+ 8 - 0
testing/lisp/test-org.el

@@ -1190,6 +1190,14 @@
   (should
    (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)))))