Commits

Joe Bogner  committed 11d5105

refactor org-parse

  • Participants
  • Parent commits 807cc40

Comments (0)

Files changed (1)

 
 (de org-parse-heading (Line Level Lines)
   (when (> Level 0)
-    (let 
-	(Body (org-parse-body Lines)
-	 Children (org-parse-children Lines Level)
-	 Heading (list 'name Line 'body Body 'children Children)
-	 NextPosition (org-next-sibling Level Lines))
-      (cons Heading NextPosition))))
+    (let (Body (org-parse-body Lines)
+				 Children (org-parse-children Lines Level)
+				 Heading (list 'name Line 'body Body 'children Children)
+				 NextPosition (org-next-sibling Level Lines))
+		 (cons Heading NextPosition))))
 
 (de org-parse (Lines Until)
-  (let (Lst '())
-       (while Lines
-	 (let (
-				Line (car Lines)
-	      Level (org-parse-level Line)
-	      HeadingParse (if (and (>= Level Until) (> Level 0)) (org-parse-heading Line Level (cdr Lines)))
-	      Heading (car HeadingParse)
-	      NextPosition (cdr HeadingParse))
-	   (if (and (<= Level Until) (not (= 0 Level)))
-		(setq Lines NIL)
-	     (if HeadingParse
-		 (prog
-		   (setq Lst (cons Heading Lst))
-		   (setq Lines NextPosition))
-	       (setq Lines (cdr Lines))))))
+	(let (Lst NIL Go 1)
+		(for (Line (and Lines Go) Lines)
+			(let (Line (car Lines)
+						Level (org-parse-level Line)
+						HeadingParse (if (and (>= Level Until) (> Level 0)) (org-parse-heading Line Level (cdr Lines)))
+						Heading (car HeadingParse)
+						NextPosition (cdr HeadingParse))
+			 (if (and (<= Level Until) (not (= 0 Level))) (setq Go NIL))
+	     (if (and Go HeadingParse)
+				 (prog
+					 (setq Lst (cons Heading Lst))
+					 (setq Lines NextPosition))
+				 (setq Lines (cdr Lines)))))
        (reverse Lst)))
 
-# (trace 'org-parse)
-# (trace 'org-parse-children)
-# (trace 'org-next-sibling)
-# (trace 'org-parse-heading)
 
 (printsp (org-parse Lines -1))
-
-
-
-
-
-
-
-
 (bye)