This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdelve-data-types.el
77 lines (59 loc) · 2.52 KB
/
delve-data-types.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; delve-data-types.el --- Data Types for the Delve Program -*- lexical-binding: t; -*-
;; Copyright (C) 2021-2023
;; Author: <[email protected]>
;; This program 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.
;; This program 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 program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Basic data types which are shared by many modules.
;;; Code:
(require 'cl-lib)
(require 'org-roam-node)
;;; * Data Types
;; Each list item has to be derived from this unspecific structure:
(cl-defstruct (delve--item
(:constructor delve--item-create))
"A generic single delve list item.")
(cl-defstruct (delve--note
(:include delve--item)
(:constructor delve--note-create))
"A note item for free text."
text)
(cl-defstruct (delve--heading
(:include delve--note)
(:constructor delve--heading-create))
"A heading.")
(cl-defstruct (delve--info
(:include delve--note)
(:constructor delve--info-create))
"A text item for information to the user.")
(cl-defstruct (delve--zettel
(:include delve--item)
(:constructor delve--zettel-create (node)))
"A Zettel item storing an Org Roam node."
node preview out-of-sync info)
;; Create shortcuts to the node element of a Zettel:
(dolist (slot (cdr (-map #'car (cl-struct-slot-info 'org-roam-node))))
(let ((name (intern (format "delve--zettel-%s" slot))))
(eval `(defun ,name (z)
,(format "Access slot `%s' of the Org Roam node stored in a Zettel object." slot)
(cl-struct-slot-value 'org-roam-node (quote ,slot) (delve--zettel-node z))))))
(cl-defstruct (delve--pile
(:include delve--item)
(:constructor delve--pile-create))
"A pile (list) of Zettels."
name zettels)
(cl-defstruct (delve--query
(:include delve--item)
(:constructor delve--query-create))
"A query returning Delve objects."
info fn)
(provide 'delve-data-types)
;;; delve-data-types.el ends here