changeset 698: | 96958d3eb5b0 |
parent: | b7183bfd7107 |
author: | Richard Westhaver <ellis@rwest.io> |
date: | Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: | -rw-r--r-- |
description: | fixes |
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 | 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) |
229 | 41 | (let ((first (read-line input nil)) |
136
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)) |
263
b7183bfd7107
add doc/readme.txt, more doc upgrades
Richard Westhaver <ellis@rwest.io>
parents:
229
diff
changeset
|
45 | (loop for l = (read-line input) ;; FIXME: peek-line no work |
136
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 | |
143 | 52 | (define-org-parser (planning :from string) |
53 | (with-input-from-string (s input) |
|
54 | (org-parse :planning s))) |