From 869dc60168e0904ed4965848d7d3e731375beac7 Mon Sep 17 00:00:00 2001 From: shoshin Date: Wed, 16 Nov 2022 21:05:51 -0600 Subject: Add: trivial implementation of find-property-drawer --- coorgi-client.el | 3 +++ coorgi-client.org | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/coorgi-client.el b/coorgi-client.el index 6739837..526cc70 100644 --- a/coorgi-client.el +++ b/coorgi-client.el @@ -38,6 +38,9 @@ (org-element-property :raw-value headline)) hl))))) +(defun coorgi--find-property-drawer (headline) + (caddr (caddr headline))) + (defun coorgify-at-point () (interactive) (save-excursion diff --git a/coorgi-client.org b/coorgi-client.org index 35ec5b5..5cc4f6f 100644 --- a/coorgi-client.org +++ b/coorgi-client.org @@ -1,7 +1,7 @@ #+PROPERTY: header-args:emacs-lisp :lexical t -* Coorgi Client - A collaborative org document sync client. - +* Coorgi Client - A collaborative org document sync client. +** Overview If you evaluate the following block, it will effecively "eval-buffer" on the whole shebang. @@ -18,6 +18,8 @@ on the whole shebang. <> + <> + <> ;;; coorgi-client.el ends here @@ -73,7 +75,6 @@ Converts the current org outline section into a coorgi-node data structure. unless (member key coorgi-properties) append (list key value))) (content-bounds (cons (progn (org-down-element) (org-forward-element) (point)) (plist-get (cadr entry) :contents-end)))) - (print parsed) `( type entry headline ,(plist-get (cadr entry) :title) version ,(string-to-number (plist-get props :COORGI-VERSION)) @@ -251,27 +252,35 @@ we're turning into coorgi nodes and get the relevant data to pack it up recursiv (:parent #2))))) #+end_src -** coorgi--property-drawer-p +** coorgi--find-property-drawer It is useful to know whether or not a headline has a property drawer. + If not, we know that Coorgi doesn't know about it yet. + If so, we need to parse the existing properties into the coorgified entry data structure. + In addition, we get more information about the org document's structure as it gets parsed into its various elements. -#+begin_src emacs-lisp - (defun coorgi--property-drawer-p (headline) - ) +#+name: coorgi--find-property-drawer +#+begin_src emacs-lisp :results none + (defun coorgi--find-property-drawer (headline) + (caddr (caddr headline))) #+end_src *** tests -#+begin_src emacs-lisp - (let ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer))) - (headline (coorgi--find-headline '(headline (:raw-value "MOO")) org-data))) - (coorgi--property-drawer-p headline)) +#+begin_src emacs-lisp :var org-doc=trivial-example() + (let* ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer))) + (headline (coorgi--find-headline '(headline (:raw-value "MOO")) org-data))) + (when (equal (car (coorgi--find-property-drawer headline)) 'property-drawer) "PASS")) #+end_src + +#+RESULTS: +: PASS + * Copyright #+begin_src emacs-lisp :noweb-ref copyright -- cgit v1.2.3