changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 490: 7a7e6c273f52
parent: 609931bd65ba
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 30 Jun 2024 17:54:33 -0400
permissions: -rw-r--r--
description: skel component updates
1 ;;; lib/organ/document.lisp --- Org Document API
2 
3 ;;
4 
5 ;;; Code:
6 (in-package :organ)
7 
8 (defclass org-document ()
9  ((meta :initform nil :initarg :meta :type (or null org-zeroth-section) :accessor doc-meta)
10  (tree :initform nil :initarg :tree :type (or (vector org-heading) null) :accessor doc-tree)))
11 
12 (defmethod org-create ((type (eql :document)) &rest initargs)
13  (apply #'make-instance (sym-to-org-class-name type) initargs))
14 
15 (defmethod org-parse ((type (eql :document)) (input pathname))
16  (if (probe-file input)
17  (let ((res (org-create type)))
18  (with-open-file (fstream input)
19  (setf (doc-meta res)
20  (org-parse :meta fstream))
21  (setf (doc-tree res)
22  (coerce
23  (loop for c = (peek-char nil fstream nil nil)
24  while (char= c #\*)
25  collect (org-parse :heading fstream))
26  '(vector org-heading))))
27  res)
28  (org-file-missing input)))