Coverage report: /home/ellis/comp/core/lib/organ/proto.lisp

KindCoveredAll%
expression047 0.0
branch010 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; lib/organ/proto.lisp --- Organ Protocol
2
 
3
 ;;
4
 
5
 ;;; Code:
6
 (in-package :organ)
7
 
8
 (defclass org-stream (fundamental-stream)
9
   ((stream :initarg :stream :reader stream-of)))
10
 
11
 (defclass org-element () ())
12
 
13
 (defclass org-lesser-element (org-element) ())
14
 
15
 (defclass org-greater-element (org-element)
16
   ((contents :initarg :contents :type (vector org-element))))
17
 
18
 (defclass org-object () ())
19
 
20
 (defgeneric org-parse (type input)
21
   (:documentation "Parse string INPUT as an org element of type TYPE."))
22
 
23
 (defgeneric org-parse-lines (type input)
24
   (:documentation "Convenience method. Parse INPUT as a vector
25
 of lines, returning it. Each line object is a cons cell where car is a
26
 keyword and cdr is the raw text parsed.")
27
   (:method ((type (eql t)) (input string))
28
     (let ((lines (read-org-lines-from-string input)))
29
       (loop for x across lines
30
             collect
31
             (cond
32
               ((scan org-headline-rx x) (cons :headline x))
33
               ((scan org-file-property-rx x) (cons :file-property x))
34
               ((scan org-property-start-rx x) (continue))
35
               ((scan org-property-rx x) (cons :node-property x))
36
               ((scan org-end-rx x) (continue))
37
               (t (cons :text x)))))))
38
 
39
 (defgeneric org-create (type &rest initargs)
40
   (:documentation "Create a new org-element of type TYPE."))
41
 
42
 (defgeneric org-push (elt place)
43
   (:documentation "Add org-element ELT to object PLACE.")
44
   (:method ((elt org-element) (place sequence))
45
     (push elt place)))
46
 
47
 (defgeneric org-write (elt stream)
48
   (:documentation "Write org-element ELT to output STREAM.")
49
   (:method ((elt org-element) stream))) ;; no-op
50
 
51
 (defgeneric org-contents (elt)
52
   (:documentation "Extract contents from org-element ELT."))
53
 
54
 (defgeneric (setf org-contents) (elt contents)
55
   (:documentation "Set ELT's contents to CONTENTS. Return ELT."))
56
 
57
 (defgeneric org-property (elt prop)
58
   (:documentation "Extract the value from property PROP of org-element ELT."))
59
 
60
 (defgeneric (setf org-property) (elt prop val)
61
   (:documentation "In org-element ELT set PROP to VAL. Return modified org-element."))
62
 
63
 (defgeneric org-get-element (elt place)
64
   (:documentation "Extract org-element ELT from sequence PLACE."))
65
 
66
 (defgeneric (setf org-get-element) (old new place)
67
   (:documentation "Replace OLD with NEW in sequence of org-elements at PLACE."))
68
 
69
 (defgeneric org-insert-before (elt location place)
70
   (:documentation "Insert org-element ELT before LOCATION in sequence PLACE. Modify PLACE
71
 by side-effect."))
72
 
73
 (defgeneric org-parse-minimal (input)
74
   (:documentation "Parse the minimal set of objects as defined by Org syntax.
75
 
76
 The minimal set includes the symbols defined in +ORG-MINIMAL-OBJECTS+."))
77
 
78
 (defgeneric org-parse-standard (input)
79
   (:documentation "Parse the standard set of object as define by Org syntax.
80
 
81
 The standard set includes the symbols defined in +ORG-STANDARD-OBJECTS+."))