From 56ed928045f20bb7e9a6840774d852599489a585 Mon Sep 17 00:00:00 2001
From: Thanos Apollo <public@thanosapollo.org>
Date: Tue, 27 Aug 2024 02:24:21 +0300
Subject: export-deck: Add demo export.

---
 gnosis.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gnosis.el b/gnosis.el
index 5476d52..2e8af51 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -50,6 +50,8 @@
 (require 'gnosis-string-edit)
 (require 'gnosis-dashboard)
 
+(require 'gnosis-org)
+
 (require 'animate)
 
 (defgroup gnosis nil
@@ -2509,6 +2511,19 @@ If STRING-SECTION is nil, apply FACE to the entire STRING."
 					:tags note-tags))
       (error "Demo deck already exists"))))
 
+;; Export
+;; This is a demo!
+(defun gnosis-export-deck (&optional deck)
+  "Export contents of DECK."
+  (interactive (list (gnosis--get-deck-id)))
+  (with-current-buffer (get-buffer-create "*test*")
+    (insert (format "#+GNOSIS_DECK: %s\n\n" (gnosis--get-deck-name deck)))
+    (cl-loop for note in (gnosis-select '[main answer id type] 'notes `(= deck-id ,deck))
+	     do (gnosis-org-insert-heading :main (car note)
+					   :answer (cadr note)
+					   :id (number-to-string (caddr note))
+					   :type (cadddr note)))))
+
 ;; Gnosis mode ;;
 ;;;;;;;;;;;;;;;;;
 
-- 
cgit v1.2.3