Quellcode durchsuchen

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.
Marco Wahl vor 7 Jahren
Ursprung
Commit
b29a972307
2 geänderte Dateien mit 118 neuen und 40 gelöschten Zeilen
  1. 18 14
      lisp/org-inlinetask.el
  2. 100 26
      testing/lisp/test-org-inlinetask.el

+ 18 - 14
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.

+ 100 - 26
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