changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 698: 96958d3eb5b0
parent: 609931bd65ba
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 ;;; lib/organ/obj.lisp --- Org Heading
2 
3 ;;
4 
5 ;;; Code:
6 (in-package :organ)
7 (defun planning-line-p (l) (scan org-planning-rx l))
8 (defun property-start-p (l) (scan org-property-start-rx l))
9 
10 (defun org-parse-planning-and-properties (input)
11  "Parse INPUT returning the following values:
12 
13 (PLANNING PROPERTIES REST)"
14  (let ((planning) properties)
15  (loop for l = (read-line input) ;; FIXME: peek-line
16  until (not l)
17  when (planning-line-p l)
18  do (push (org-parse :planning-line (read-line input)) planning)
19  when (property-start-p l)
20  do (setf properties (org-parse :property-drawer input)))
21  (values planning properties (read-until-end input))))
22 
23 (defclass org-heading ()
24  ((headline :initarg :headline :initform (org-create :headline) :type org-headline :accessor org-headline)
25  (planning :initarg :planning :initform nil :type (or null org-planning) :accessor org-planning)
26  (properties :initarg :properties :initform nil :type (or null org-property-drawer) :accessor org-properties)
27  (contents :initarg :contents :initform nil :type (or null (vector (or org-section org-heading)))
28  :accessor org-contents)))
29 
30 (defmethod org-create ((type (eql :header)) &rest initargs &key &allow-other-keys)
31  (apply #'make-instance (sym-to-org-class-name type) initargs))
32 
33 ;; TODO 2024-03-17: fix org-parse-planning-properties -- hangs
34 (define-org-parser (heading :from stream)
35  (let ((headline (org-parse :headline (read-line input))))
36  ;; (multiple-value-bind (planning properties rest)
37  ;; (org-parse-planning-and-properties input)
38  (make-instance 'org-heading
39  :headline headline
40  ;; :planning planning
41  ;; :properties properties
42  ;; :contents (org-parse :section (read-until-end rest)))
43  )))
44 
45 (define-org-parser (heading :from string)
46  (with-input-from-string (s input)
47  (org-parse :heading s)))