changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/organ/heading.lisp

changeset 287: 609931bd65ba
parent: b7183bfd7107
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 19 Apr 2024 21:54:00 -0400
permissions: -rw-r--r--
description: organ updates, readme.org
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
1
 ;;; lib/organ/obj.lisp --- Org Heading
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
2
 
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
3
 ;;
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
4
 
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
5
 ;;; Code:
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
6
 (in-package :organ)
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
7
 (defun planning-line-p (l) (scan org-planning-rx l))
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
8
 (defun property-start-p (l) (scan org-property-start-rx l))
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents:
diff changeset
9
 
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
10
 (defun org-parse-planning-and-properties (input)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
11
   "Parse INPUT returning the following values:
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
12
 
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
13
 (PLANNING PROPERTIES REST)"
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
14
   (let ((planning) properties)
263
b7183bfd7107 add doc/readme.txt, more doc upgrades
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
15
     (loop for l = (read-line input) ;; FIXME: peek-line
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
16
           until (not l)
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
17
           when (planning-line-p l)
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
18
             do (push (org-parse :planning-line (read-line input)) planning)
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
19
           when (property-start-p l)
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
20
             do (setf properties (org-parse :property-drawer input)))
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
21
     (values planning properties (read-until-end input))))
134
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
22
   
128
99f2ab6bc8ba organ work
ellis <ellis@rwest.io>
parents: 127
diff changeset
23
 (defclass org-heading () 
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
24
   ((headline :initarg :headline :initform (org-create :headline) :type org-headline :accessor org-headline)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
25
    (planning :initarg :planning :initform nil :type (or null org-planning) :accessor org-planning)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
26
    (properties :initarg :properties :initform nil :type (or null org-property-drawer) :accessor org-properties)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
27
    (contents :initarg :contents :initform nil :type (or null (vector (or org-section org-heading))) 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
28
              :accessor org-contents)))
134
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
29
 
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
30
 (defmethod org-create ((type (eql :header)) &rest initargs &key &allow-other-keys)
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
31
   (apply #'make-instance (sym-to-org-class-name type) initargs))
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
32
 
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
33
 ;; TODO 2024-03-17: fix org-parse-planning-properties -- hangs
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
34
 (define-org-parser (heading :from stream)
143
64d36c0e3942 podman shenanigans
ellis <ellis@rwest.io>
parents: 136
diff changeset
35
     (let ((headline (org-parse :headline (read-line input))))
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
36
       ;; (multiple-value-bind (planning properties rest)
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
37
       ;; (org-parse-planning-and-properties input)
287
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
38
       (make-instance 'org-heading
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
39
         :headline headline
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
40
         ;; :planning planning
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
41
         ;; :properties properties
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
42
         ;; :contents (org-parse :section (read-until-end rest)))
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 143
diff changeset
43
         )))
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
44
 
134
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
45
 (define-org-parser (heading :from string)
d5ee1f5f3cf4 org headline priority stuff
ellis <ellis@rwest.io>
parents: 128
diff changeset
46
   (with-input-from-string (s input)
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 134
diff changeset
47
     (org-parse :heading s)))