diff options
author | shoshin <shoshin@cicadas.surf> | 2022-11-21 16:31:33 -0600 |
---|---|---|
committer | shoshin <shoshin@cicadas.surf> | 2022-11-21 16:31:33 -0600 |
commit | 299671ac954e5f7d721ee2d6a4ea63718a6be843 (patch) | |
tree | e598526629e3b5694d7f8be458709809b3ac793f | |
parent | 7efd38455bdde17287d680ce561ca5c8ded121a5 (diff) |
Add: tag length counting for property drawer start value
-rw-r--r-- | annotations | 2 | ||||
-rw-r--r-- | coorgi-client.org | 39 |
2 files changed, 21 insertions, 20 deletions
diff --git a/annotations b/annotations index 3f18094..6c19cc6 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.")) "9e9810137e361612d0a2511d288b60ba"))
\ No newline at end of file +include issue trackers, shared agendas, and near real-time collaboration.")) "80a7138d69b10cf76e6d481cc6426e63"))
\ No newline at end of file diff --git a/coorgi-client.org b/coorgi-client.org index 9ac4083..f9bc542 100644 --- a/coorgi-client.org +++ b/coorgi-client.org @@ -87,16 +87,14 @@ 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 +**** DONE Calculate where the property drawer should begin 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. +headline's :raw-value plus it's :level. Oh and one more plus that due +to the newline. 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, @@ -108,14 +106,17 @@ value of the org-tags-column variable. (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))) + (h-length (length (plist-get props :raw-value))) + (h-begin (plist-get props :begin)) + (h-level (plist-get props :level)) + (tags (plist-get props :tags)) + (tags-count (length tags)) + (tags-length (+ 2 (cl-reduce #'+ (mapcar (lambda (t) (length t)) tags))))) + (+ 2 h-length h-begin h-level tags-length)) #+end_src #+RESULTS: property-drawer-should-begin -: 12 +: 18 **** TODO Recalculate existing element positions @@ -200,16 +201,16 @@ Given this org document: #+name: trivial-example #+begin_src org -,* MOO -:PROPERTIES: -:coorgi-version: 1 -:coorgi-last-modified-by: colin/123 -:coorgi-last-modified: 123 -:coorgi-key: 101 -:foo: bar -:END: + ,* MOO + :PROPERTIES: + :coorgi-version: 1 + :coorgi-last-modified-by: colin/123 + :coorgi-last-modified: 123 + :coorgi-key: 101 + :foo: bar + :END: -hello + hello #+end_src |