changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/organ/element/lesser/planning.lisp

changeset 136: 6ad95601645e
parent: a5ae5a58c4cd
child: 64d36c0e3942
author: ellis <ellis@rwest.io>
date: Wed, 27 Dec 2023 23:47:25 -0500
permissions: -rw-r--r--
description: org work, once we fix org-parse-planning-and-properties we ready to rumble
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
1
 ;;; lib/organ/element/lesser/planning.lisp --- Org Planning Elements
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
2
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
3
 ;; A planning element matches the pattern:
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
4
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
5
 #|
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
6
 HEADING
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
7
 PLANNING
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
8
 |#
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
9
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
10
 ;; HEADING is just a heading. 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
11
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
12
 ;; PLANNING matches the pattern: 'KEYWORD: TIMESTAMP'.
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
13
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
14
 ;; KEYWORD is one of DEADLINE, SCHEDULED, CLOSED.
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
15
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
16
 ;;; Code:
128
99f2ab6bc8ba organ work
ellis <ellis@rwest.io>
parents:
diff changeset
17
 (in-package :organ)
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
18
 
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
19
 (sb-int:defconstant-eqx +org-planning-keywords+ '("DEADLINE" "SCHEDULED" "CLOSED") #'equal)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
20
 
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
21
 ;; helper object, not public API
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
22
 (define-org-object planning-line ((keyword "" :type string) (timestamp "" :type string)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
23
 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
24
 ;; always consume the string
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
25
 (define-org-parser (planning-line :from string)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
26
   (multiple-value-bind (match subs)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
27
       (scan-to-strings org-planning-rx input)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
28
     (when match
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
29
       (let ((kw (aref subs 0))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
30
             (ts (aref subs 1)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
31
         (when (and kw ts)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
32
           (let ((pl (org-create :planning-line)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
33
             (setf (org-planning-line-keyword pl) kw
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
34
                   (org-planning-line-timestamp pl) ts)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
35
             pl))))))
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
36
 
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
37
 (define-org-element planning ((contents :initarg :contents :accessor org-contents :type (vector org-planning-line) :initform (make-array 0 :element-type 'org-planning-line :adjustable t :fill-pointer 0)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
38
   :lesser t)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
39
 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
40
 (define-org-parser (planning :from stream)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
41
   (let ((first (read-line input nil :eof))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
42
         (p (org-create :planning)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
43
     (when-let ((pl1 (org-parse :planning-line first)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
44
       (vector-push-extend pl1 (org-contents p))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
45
       (loop for l = (peek-line input)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
46
             until (not l)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
47
             with pl = (org-parse :planning-line (read-line input))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
48
             until (not pl)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
49
             do (vector-push-extend pl (org-contents p)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
50
       p)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
51
                                    
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
52