summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshoshin <shoshin@cicadas.surf>2022-11-20 22:48:32 -0600
committershoshin <shoshin@cicadas.surf>2022-11-20 22:48:32 -0600
commit7efd38455bdde17287d680ce561ca5c8ded121a5 (patch)
treeb1ad53a0632249e4149bc30e722895b06aa08c80
parenta70953bf7c3466b2a166d3a3e9f92d2560d2527a (diff)
Add: parsed doc property drawer beginnings
-rw-r--r--annotations2
-rw-r--r--coorgi-client.org71
2 files changed, 68 insertions, 5 deletions
diff --git a/annotations b/annotations
index f00a565..3f18094 100644
--- a/annotations
+++ b/annotations
@@ -1,3 +1,3 @@
(("~/projects/coorgi-client/coorgi-client.org" ((109 325 "please refine this block, i know you've got some good language for it out there -g" "Coorgi stands for \"cooperative org interchange\", and intends to enable
multiple users to sync org documents between one another. Possible uses
-include issue trackers, shared agendas, and near real-time collaboration.")) "4e3141987ad14628245a6cc8b771e9f8"))
+include issue trackers, shared agendas, and near real-time collaboration.")) "9e9810137e361612d0a2511d288b60ba")) \ No newline at end of file
diff --git a/coorgi-client.org b/coorgi-client.org
index 7594d54..9ac4083 100644
--- a/coorgi-client.org
+++ b/coorgi-client.org
@@ -74,11 +74,74 @@ edits and updates.
*** TODO example proof of concept
-For example:
+First lets start with an un-coorgified org document with one headline:
-#+begin_src emacs-lisp :var org-doc=trivial-example() :results verbatim
- (let ((subject (with-temp-buffer (insert org-doc) (org-element-parse-buffer))))
- (org-element-interpret-data subject))
+#+name: uncoorgified-example-1
+#+begin_src org
+ ,* Heading 1 :foo:
+
+ v a p o r w a v e
+#+end_src
+
+If we want to programmatically add a property drawer to this headline
+by modifying the parsed org document tree, it will require several
+steps.
+
+**** TODO Calculate where the property drawer should begin
+
+- [X] calculate without tags
+- [ ] add length of unaligned tags
+
+A property drawer always starts immediately after the headline,
+so we'll need to calculate the position for the drawer's :begin property.
+
+It will be one more than the headline's :begin plus the length of the
+headline's :raw-value plus it's :level.
+
+In addition, we'll need to add the total length of the heading's tags
+and some room for spacing. Tags are unfortunately likely to realign,
+as they will end up being set in a user's buffer based on the current
+value of the org-tags-column variable.
+
+#+name: property-drawer-should-begin
+#+begin_src emacs-lisp :var org-doc=uncoorgified-example-1()
+ (let* ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer)))
+ (headline (cl-third org-data))
+ (props (cadr headline))
+ (h-length (length (plist-get (cadr headline) :raw-value)))
+ (h-begin (plist-get (cadr headline) :begin))
+ (h-level (plist-get (cadr headline) :level)))
+ (+ 1 h-length h-begin h-level)))
+#+end_src
+
+#+RESULTS: property-drawer-should-begin
+: 12
+
+**** TODO Recalculate existing element positions
+
+We'll need to add the total number of characters of a property drawer
+to the existing :begin and :end values of nested org elements.
+
+#+begin_src emacs-lisp :var org-doc=uncoorgified-example-1() :results code
+ (let* ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer)))) org-data)
+#+end_src
+
+#+RESULTS:
+#+begin_src emacs-lisp
+(org-data nil
+ (headline
+ (:raw-value "Heading 1" :begin 1 :end 98 :pre-blank 1 :contents-begin 81 :contents-end 98 :level 1 :priority nil :tags
+ ("foo")
+ :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title
+ (#("Heading 1" 0 9
+ (:parent #1)))
+ :parent #0)
+ (section
+ (:begin 81 :end 98 :contents-begin 81 :contents-end 98 :post-blank 0 :post-affiliated 81 :parent #1)
+ (paragraph
+ (:begin 81 :end 98 :contents-begin 81 :contents-end 98 :post-blank 0 :post-affiliated 81 :parent #2)
+ #("v a p o r w a v e" 0 17
+ (:parent #3))))))
#+end_src
** defvar coorgi-properties