From 5a39c3e08418d5370ec0737207b1158f8c59001a Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Fri, 11 Nov 2022 22:05:58 -0600 Subject: Add: tangled file and fix some org babel settings --- coorgi-client.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 coorgi-client.el (limited to 'coorgi-client.el') diff --git a/coorgi-client.el b/coorgi-client.el new file mode 100644 index 0000000..5f296c7 --- /dev/null +++ b/coorgi-client.el @@ -0,0 +1,63 @@ +;;; coorgi-client.el --- A collaborative org document sync client. -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Grant Shangreaux + +;; Author: Grant Shangreaux +;; Maintainer: Grant Shangreaux +;; Created: 11 Nov 2022 +;; Keywords: org sync collaborative +;; URL: https://cicadas.surf/cgit/coorgi-client.git + +;; This file is not part of GNU Emacs. + +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this file. If not, see . + +(require 'cl-lib) + +(defvar coorgi-properties '(:COORGI-KEY + :COORGI-LAST-MODIFIED + :COORGI-LAST-MODIFIED-BY + :COORGI-VERSION) + "List of properties coorgi cares about.") + +(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))))) + +(defun coorgify-at-point () + (save-excursion + (let* ((current-element (org-element-at-point)) + (entry (if (not (equal (car current-element) 'heading)) + (progn (org-up-heading-safe) + (org-element-at-point)) + current-element)) + (parsed (print (org-element-parse-buffer))) + (props (org-element--get-node-properties)) + (non-coorgi-props (cl-loop for (key value) on props by #'cddr + 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)))) + `( type entry + headline ,(plist-get (cadr entry) :title) + version ,(string-to-number (plist-get props :COORGI-VERSION)) + last-modified-by ,(plist-get props :COORGI-LAST-MODIFIED-BY) + last-modified ,(plist-get props :COORGI-LAST-MODIFIED) + key ,(plist-get props :COORGI-KEY) + properties ,non-coorgi-props + contents ,(buffer-substring-no-properties (car content-bounds) (cdr content-bounds)))))) + +;;; coorgi-client.el ends here -- cgit v1.2.3