-
Notifications
You must be signed in to change notification settings - Fork 5
/
rigpa-types.el
69 lines (54 loc) · 2.36 KB
/
rigpa-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
;;; rigpa-types.el --- Self-reflective editing modes -*- lexical-binding: t -*-
;; URL: https://github.com/countvajhula/rigpa
;; This program is "part of the world," in the sense described at
;; http://drym.org. From your perspective, this is no different than
;; MIT or BSD or other such "liberal" licenses that you may be
;; familiar with, that is to say, you are free to do whatever you like
;; with this program. It is much more than BSD or MIT, however, in
;; that it isn't a license at all but an idea about the world and how
;; economic systems could be set up so that everyone wins. Learn more
;; at drym.org.
;;
;; This work transcends traditional legal and economic systems, but
;; for the purposes of any such systems within which you may need to
;; operate:
;;
;; This is free and unencumbered software released into the public domain.
;; The authors relinquish any copyright claims on this work.
;;
;;; Commentary:
;;
;; Types and interfaces
;;
;;; Code:
(require 'cl-lib)
(require 'chimera)
(cl-defstruct editing-ensemble
"Specification for an editing ensemble."
name
;; TODO: members should be structs implementing an "entity" interface
(members nil :documentation "A list of members of the editing ensemble.")
(default nil :documentation "The canonical member of the tower."))
(cl-defgeneric rigpa-editing-entity-name (entity)
"A generic function to access the name of any editing
entity, such as modes, towers or complexes.")
(cl-defmethod rigpa-editing-entity-name ((entity chimera-mode))
(chimera-mode-name entity))
(cl-defmethod rigpa-editing-entity-name ((entity editing-ensemble))
(editing-ensemble-name entity))
(defun rigpa-ensemble-member-position-by-name (ensemble name)
"The position of a member in an ensemble, by name."
(seq-position (seq-map #'rigpa-editing-entity-name
(editing-ensemble-members ensemble))
name))
(defun rigpa-ensemble-size (ensemble)
"Size of ensemble (e.g. height of a tower)."
(length (editing-ensemble-members ensemble)))
(defun rigpa-ensemble-member-at-position (tower position)
"Mode at LEVEL in the TOWER."
(nth position (editing-ensemble-members tower)))
(defun rigpa--member-of-ensemble-p (entity ensemble)
"A predicate asserting whether ENTITY is a member of ENSEMBLE."
(memq entity (editing-ensemble-members ensemble)))
(provide 'rigpa-types)
;;; rigpa-types.el ends here