diff options
author | Marco Wahl <marcowahlsoft@gmail.com> | 2017-12-28 17:59:52 +0100 |
---|---|---|
committer | Marco Wahl <marcowahlsoft@gmail.com> | 2017-12-28 17:59:52 +0100 |
commit | b29a9723074343a54f99630f65285ab9694c3d78 (patch) | |
tree | 6745a7b4c20d14959513cf99c1ff0bc006a4c3eb | |
parent | ab6135779170b28ed9c968da0120a5e2e8e64890 (diff) | |
download | org-mode-b29a9723074343a54f99630f65285ab9694c3d78.tar.gz |
org-inlinetask:Fix folding of inline tasks within plain list
This is the fix proposed by Nicolas. See
http://lists.gnu.org/archive/html/emacs-orgmode/2017-12/msg00564.html
Add and accommodate some tests.
-rw-r--r-- | lisp/org-inlinetask.el | 32 | ||||
-rw-r--r-- | testing/lisp/test-org-inlinetask.el | 126 |
2 files changed, 118 insertions, 40 deletions
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index 4a8e43d..bc90b63 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -182,24 +182,28 @@ The number of levels is controlled by `org-inlinetask-min-level'." (defun org-inlinetask-goto-end () "Go to the end of the inline task at point. -Return point." + Return point." (save-match-data (beginning-of-line) (let* ((case-fold-search t) - (inlinetask-re (org-inlinetask-outline-regexp)) - (task-end-re (concat inlinetask-re "END[ \t]*$"))) + (inlinetask-re (org-inlinetask-outline-regexp)) + (task-end-re (concat inlinetask-re "END[ \t]*$"))) (cond - ((looking-at task-end-re)) - ((looking-at inlinetask-re) - (forward-line) - (cond - ((looking-at task-end-re)) - ((looking-at inlinetask-re)) - ((org-inlinetask-in-task-p) - (re-search-forward inlinetask-re nil t)))) - (t (re-search-forward inlinetask-re nil t))) - (end-of-line) - (point)))) + ((looking-at-p task-end-re) + (forward-line)) + ((looking-at-p inlinetask-re) + (forward-line) + (cond + ((looking-at-p task-end-re) (forward-line)) + ((looking-at-p inlinetask-re)) + ((org-inlinetask-in-task-p) + (re-search-forward inlinetask-re nil t) + (forward-line)) + (t nil))) + (t + (re-search-forward inlinetask-re nil t) + (forward-line))))) + (point)) (defun org-inlinetask-get-task-level () "Get the level of the inline task around. diff --git a/testing/lisp/test-org-inlinetask.el b/testing/lisp/test-org-inlinetask.el index 2025f72..6830b16 100644 --- a/testing/lisp/test-org-inlinetask.el +++ b/testing/lisp/test-org-inlinetask.el @@ -27,41 +27,115 @@ ;;; Test movement -(ert-deftest test-org-inlinetask/goto-end () - "Tests around org-inlinetask." +(ert-deftest test-org-inlinetask/org-inlinetask-goto-end () ;; Goto end. (should - (equal "** H\n***** I\n***** END<point>\nfoo" - (let ((org-inlinetask-min-level 5) - (org-adapt-indentation t)) - (org-test-with-temp-text - "** H\n<point>***** I\n***** END\nfoo" - (org-inlinetask-goto-end) - (insert "<point>") - (buffer-string))))) + (equal + (let ((org-inlinetask-min-level 5) + (org-adapt-indentation t)) + (org-test-with-temp-text + "** H +<point>***** I +***** END +foo" + (org-inlinetask-goto-end) + (insert "<point>") + (buffer-string))) + "** H +***** I +***** END +<point>foo")) ;; Goto end. End is buffer end. (should - (equal "** H\n***** I\n***** END<point>" - (let ((org-inlinetask-min-level 5) - (org-adapt-indentation t)) - (org-test-with-temp-text - "** H\n<point>***** I\n***** END" - (org-inlinetask-goto-end) - (insert "<point>") - (buffer-string))))) + (equal + (let ((org-inlinetask-min-level 5) + (org-adapt-indentation t)) + (org-test-with-temp-text + "** H +<point>***** I +***** END" + (org-inlinetask-goto-end) + (insert "<point>") + (buffer-string))) + "** H +***** I +***** END<point>")) ;; Goto end. Starting somewhere. (should - (equal "** H\n***** I\n***** END<point>\n***** I\n***** END" - (let ((org-inlinetask-min-level 5) - (org-adapt-indentation t)) - (org-test-with-temp-text - "** H\n****<point>* I\n***** END\n***** I\n***** END" - (org-inlinetask-goto-end) - (insert "<point>") - (buffer-string)))))) + (equal + (let ((org-inlinetask-min-level 5) + (org-adapt-indentation t)) + (org-test-with-temp-text + "** H +****<point>* I +***** END +***** I +***** END" + (org-inlinetask-goto-end) + (insert "<point>") + (buffer-string))) + "** H +***** I +***** END +<point>***** I +***** END")) + (should + (equal + (let ((org-inlinetask-min-level 5) + (org-adapt-indentation t)) + (org-test-with-temp-text + "** H +***** I +<point> inside +***** END +***** I +***** END" + (org-inlinetask-goto-end) + (insert "<point>") + (buffer-string))) + "** H +***** I + inside +***** END +<point>***** I +***** END"))) + +(ert-deftest test-org-inlinetask/inlinetask-within-plain-list () + "Fold inlinetasks in plain-lists. +Report: +http://lists.gnu.org/archive/html/emacs-orgmode/2017-12/msg00502.html" + (should + (org-test-with-temp-text + "* Test +<point>- x + - a +*************** List folding stopped here +*************** END + - b +" + (org-cycle-internal-local) + (invisible-p (1- (search-forward "- b")))))) + +(ert-deftest test-org-inlinetask/folding-directly-consecutive-tasks () + "Fold directly consecutive inlinetasks." + (should + (org-test-with-temp-text + "* Test +<point>- x + - a +*************** List folding stopped here +*************** END +*************** List folding stopped here +*************** END + - b +" + (org-cycle-internal-local) + (invisible-p (1- (search-forward "- b")))))) + + (provide 'test-org-inlinetask) ;;; test-org-inlinetask.el ends here |