Introduce node properties (first :visibility)

This commit is contained in:
Renaud Casenave-Péré 2023-01-19 13:09:48 +01:00
parent 132146049f
commit a71cd29bb0

View file

@ -15,6 +15,7 @@
#:make-org-document
#:make-org-line
#:make-org-headline
#:property-of
#:headline-of
#:append-node
#:process-last-node
@ -23,7 +24,11 @@
(in-package :sextant/org/nodes)
(defclass org-node ()
((previous :initarg :previous
((properties :initarg :properties
:type list
:initform nil
:documentation "The property list of this node.")
(previous :initarg :previous
:type org-node
:accessor previous-of
:initform nil
@ -79,10 +84,24 @@
(defun make-org-headline (depth title raw-text line-ending)
(make-instance 'org-headline :depth depth :title title
:raw-text raw-text :line-ending line-ending))
:raw-text raw-text :line-ending line-ending
:properties (list :visibility :expanded)))
(defgeneric property-of (node key &optional default))
(defmethod property-of ((node org-node) key &optional default)
(with-slots (properties) node
(getf properties key default)))
(defgeneric (setf property-of) (new-value node key &optional default))
(defmethod (setf property-of) (new-value (node org-node) key &optional default)
(declare (ignore default))
(with-slots (properties) node
(setf (getf properties key) new-value)))
(defgeneric headline-of (node))
(defmethod headline-of ((node org-line))
@ -127,6 +146,7 @@
(when (next-headline-of old)
(setf (next-headline-of new) (next-headline-of old)
(previous-headline-of (next-headline-of old)) new))
(setf (slot-value new 'properties) (slot-value old 'properties))
t)
(defmethod replace-node ((old org-headline) (new org-line))