diff options
author | Thanos Apollo <[email protected]> | 2024-01-04 08:13:04 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-01-04 08:13:04 +0200 |
commit | 06a83e2515778f10a75dd2a61691194f447244ae (patch) | |
tree | 160c024320ddd9048538f95b1d7694c62a2bf055 /gnosis.el | |
parent | 194f32fe89f0277670b1b298d3cbf0d0844ec5c4 (diff) |
Add gnosis-export-deck
"Export notes for deck in FILENAME."
FILENAME: The name of the file to save the exported deck.
This function prompts the user to provide a deck name and allows the
user to specify a filename for exporting notes belonging to that deck.
It then retrieves all the notes associated with the deck and exports
them.
The exported notes are formatted as an Emacs Lisp code block that can
be evaluated to recreate the deck with its associated notes. The
resulting code is saved to a file with the provided FILENAME and a
'.el' extension is added automatically.
Each note is exported using the `gnosis-export-note` function. The
generated code includes a call to `gnosis-define-deck` with the deck
name and all notes formatted as nested lists
Diffstat (limited to 'gnosis.el')
-rw-r--r-- | gnosis.el | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -1106,6 +1106,33 @@ to improve readability." (insert (format ":%s %s\n" field 'nil))) (t (insert (format ":%s \"%s\"\n" field value)) (indent-region (point-min) (point-max))))))) + +(defun gnosis-export-deck (filename) + "Export notes for deck in FILENAME. + +FILENAME: The name of the file to save the exported deck. + +This function prompts the user to provide a deck name and allows the +user to specify a filename for exporting notes belonging to that deck. +It then retrieves all the notes associated with the deck and exports +them. + +The exported notes are formatted as an Emacs Lisp code block that can +be evaluated to recreate the deck with its associated notes. The +resulting code is saved to a file with the provided FILENAME and a +'.el' extension is added automatically. + +Each note is exported using the `gnosis-export-note` function. The +generated code includes a call to `gnosis-define-deck` with the deck +name and all notes formatted as nested lists" + (interactive (list (read-string "Filename: "))) + (let ((notes (gnosis-get-notes-for-deck)) + (deck-name (read-string "Export deck as (name): "))) + (with-temp-file (concat filename ".el") + (insert "(gnosis-define-deck " "'" deck-name " '(") + (cl-loop for note in notes + do (progn (insert "(") (gnosis-export-note note) (insert ")" "\n")) + finally (insert "))"))))) ;;;###autoload (defun gnosis-review () "Start gnosis review session." |