summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shoshin Shangreaux <shoshin@cicadas.surf>2022-11-16 14:17:13 -0600
committerGrant Shoshin Shangreaux <shoshin@cicadas.surf>2022-11-16 14:17:13 -0600
commit5a8383e8399785ac4efb1a407149f6222a2b169d (patch)
treeeef7bae4f2c3f3f804c4aca73b69fbc952de8470
parent5a39c3e08418d5370ec0737207b1158f8c59001a (diff)
Clean: some restructuring and note updates
-rw-r--r--coorgi-client.org116
1 files changed, 65 insertions, 51 deletions
diff --git a/coorgi-client.org b/coorgi-client.org
index 119998f..05b5469 100644
--- a/coorgi-client.org
+++ b/coorgi-client.org
@@ -20,7 +20,7 @@
;;; coorgi-client.el ends here
#+end_src
-* dependencies
+* Dependencies
#+begin_src emacs-lisp :results silent :noweb-ref dependencies
(require 'cl-lib)
@@ -64,6 +64,7 @@ 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))
@@ -74,55 +75,6 @@ Converts the current org outline section into a coorgi-node data structure.
contents ,(buffer-substring-no-properties (car content-bounds) (cdr content-bounds))))))
#+end_src
-*** helpers
-**** coorgi--find-heading
-
-We need to used the parsed version of the org buffer to look up the elements
-we're turning into coorgi nodes and get the relevant data to pack it up recursively.
-
-#+name: coorgi--find-heading
-#+begin_src emacs-lisp :results none
- (defun coorgi--find-heading (heading org-data)
- (car (org-element-map org-data 'headline
- (lambda (hl)
- (when (string-equal (org-element-property :raw-value hl)
- (org-element-property :raw-value heading))
- hl)))))
-#+end_src
-
-#+begin_src emacs-lisp :var org-doc=trivial-example() :results code
- (let ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer))))
- (coorgi--find-heading '(headline (:raw-value "MOO")) org-data))
-#+end_src
-
-#+RESULTS:
-#+begin_src emacs-lisp
-(headline
- (:raw-value "MOO" :begin 1 :end 142 :pre-blank 0 :contents-begin 7 :contents-end 142 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :FOO "bar" :COORGI-KEY "101" :COORGI-LAST-MODIFIED "123" :COORGI-LAST-MODIFIED-BY "colin/123" :COORGI-VERSION "1" :title
- (#("MOO" 0 3
- (:parent #0)))
- :parent
- (org-data nil #0))
- (section
- (:begin 7 :end 142 :contents-begin 7 :contents-end 142 :post-blank 0 :post-affiliated 7 :parent #0)
- (property-drawer
- (:begin 7 :end 136 :contents-begin 20 :contents-end 129 :post-blank 1 :post-affiliated 7 :parent #1)
- (node-property
- (:key "coorgi-version" :value "1" :begin 20 :end 39 :post-blank 0 :post-affiliated 20 :parent #2))
- (node-property
- (:key "coorgi-last-modified-by" :value "colin/123" :begin 39 :end 75 :post-blank 0 :post-affiliated 39 :parent #2))
- (node-property
- (:key "coorgi-last-modified" :value "123" :begin 75 :end 102 :post-blank 0 :post-affiliated 75 :parent #2))
- (node-property
- (:key "coorgi-key" :value "101" :begin 102 :end 119 :post-blank 0 :post-affiliated 102 :parent #2))
- (node-property
- (:key "foo" :value "bar" :begin 119 :end 129 :post-blank 0 :post-affiliated 119 :parent #2)))
- (paragraph
- (:begin 136 :end 142 :contents-begin 136 :contents-end 142 :post-blank 0 :post-affiliated 136 :parent #1)
- #("hello\n" 0 6
- (:parent #2)))))
-#+end_src
-
*** Testing
**** Trivial Org Example
@@ -183,7 +135,7 @@ No matter where the cursor is in the buffer (there's only one coorgi node)
(expected
(type entry headline "MOO" version 1 last-modified-by "colin/123" last-modified "123" key "101" properties
(:FOO "bar")
- content "\n\nhello\n\n" children nil)))
+ content "\nhello\n\n" children nil)))
#+end_src
***** TODO When the cursor at the top of the document
@@ -242,6 +194,68 @@ a cow
another cow
#+end_src
+** coorgi--find-heading
+
+We need to used the parsed version of the org buffer to look up the elements
+we're turning into coorgi nodes and get the relevant data to pack it up recursively.
+
+#+name: coorgi--find-heading
+#+begin_src emacs-lisp :results none
+ (defun coorgi--find-heading (heading org-data)
+ (car (org-element-map org-data 'headline
+ (lambda (hl)
+ (when (string-equal (org-element-property :raw-value hl)
+ (org-element-property :raw-value heading))
+ hl)))))
+#+end_src
+
+#+begin_src emacs-lisp :var org-doc=trivial-example() :results code
+ (let ((org-data (with-temp-buffer (insert org-doc) (org-element-parse-buffer))))
+ (coorgi--find-heading '(headline (:raw-value "MOO")) org-data))
+#+end_src
+
+#+RESULTS:
+#+begin_src emacs-lisp
+(headline
+ (:raw-value "MOO" :begin 1 :end 142 :pre-blank 0 :contents-begin 7 :contents-end 142 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :FOO "bar" :COORGI-KEY "101" :COORGI-LAST-MODIFIED "123" :COORGI-LAST-MODIFIED-BY "colin/123" :COORGI-VERSION "1" :title
+ (#("MOO" 0 3
+ (:parent #0)))
+ :parent
+ (org-data nil #0))
+ (section
+ (:begin 7 :end 142 :contents-begin 7 :contents-end 142 :post-blank 0 :post-affiliated 7 :parent #0)
+ (property-drawer
+ (:begin 7 :end 136 :contents-begin 20 :contents-end 129 :post-blank 1 :post-affiliated 7 :parent #1)
+ (node-property
+ (:key "coorgi-version" :value "1" :begin 20 :end 39 :post-blank 0 :post-affiliated 20 :parent #2))
+ (node-property
+ (:key "coorgi-last-modified-by" :value "colin/123" :begin 39 :end 75 :post-blank 0 :post-affiliated 39 :parent #2))
+ (node-property
+ (:key "coorgi-last-modified" :value "123" :begin 75 :end 102 :post-blank 0 :post-affiliated 75 :parent #2))
+ (node-property
+ (:key "coorgi-key" :value "101" :begin 102 :end 119 :post-blank 0 :post-affiliated 102 :parent #2))
+ (node-property
+ (:key "foo" :value "bar" :begin 119 :end 129 :post-blank 0 :post-affiliated 119 :parent #2)))
+ (paragraph
+ (:begin 136 :end 142 :contents-begin 136 :contents-end 142 :post-blank 0 :post-affiliated 136 :parent #1)
+ #("hello\n" 0 6
+ (:parent #2)))))
+#+end_src
+
+** coorgi--property-drawer-p
+
+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)
+ )
+#+end_src
+
* Copyright
#+begin_src emacs-lisp :noweb-ref copyright