-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtarot.el
252 lines (227 loc) · 14.4 KB
/
tarot.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
;;; tarot.el -- draw a random tarot card
;; Copyright (C) 2007, 2011 Joseph Corneli <holtzermann17@...>
;; Copyright (C) 2011 Jokim Verona <[email protected]>
;; Notice: Copyright transfered to public domain wherever applicable.
;; Time-stamp: <2011-02-07 01:03:35 joe>
;;; Commentary:
;; Latest version now includes a simple four-card spread
;; and "alt-text" from Alliete and Crowley (where
;; applicable).
;;; Code:
(defvar tarot-decks '( ("Tarot" [["Fool" "La Follie ou l'Alchemiste"]
["Magician" "Le Magicien ou le Bateleur"]
["High Priestess" "Repos"]
["Empress" "Les Astres"]
["Emperor" "Les Ouiseaux et les Poissons"]
["Hierophant" "Le Grand pretre"]
["Lovers" "Le Chaos"]
["Chariot" "Le Despote africain"]
["Strength" "La Force"]
["Hermit" "Le Capucin"]
["Wheel of Fortune" "La Roue de Fortune"]
["Justice" "La Justice"]
["Hanged Man" "La Prudence"]
["Death" "La Mort"]
["Temperance" "La Temperance"]
["Devil" "Le Diable"]
["Tower" "Le Temple Foudroye"]
["Star" "La Ciel"]
["Moon" "Les Plantes"]
["Sun" "La Lumiere"]
["Judgement" "Le Jugement Dernier"]
["World" "L'homme et les Quadrupedes"]
["Ace of Wands" "The Root of the Powers of Fire"]
["2 of Wands" "Dominion"]
["3 of Wands" "Virtue"]
["4 of Wands" "Completion"]
["5 of Wands" "Strife"]
["6 of Wands" "Victory"]
["7 of Wands" "Valour"]
["8 of Wands" "Swiftness"]
["9 of Wands" "Strength"]
["10 of Wands" "Oppression"]
["Page of Wands"]
["Knight of Wands"]
["Queen of Wands"]
["King of Wands"]
["Ace of Cups" "The Root of the Powers of Water"]
["2 of Cups" "Love"]
["3 of Cups" "Abundance"]
["4 of Cups" "Luxury"]
["5 of Cups" "Disappointment"]
["6 of Cups" "Pleasure"]
["7 of Cups" "Debauch"]
["8 of Cups" "Indolence"]
["9 of Cups" "Happiness"]
["10 of Cups" "Satiety"]
["Page of Cups"]
["Knight of Cups"]
["Queen of Cups"]
["King of Cups"]
["Ace of Swords" "The Root of the Powers of Air"]
["2 of Swords" "Peace"]
["3 of Swords" "Sorrow"]
["4 of Swords" "Truce"]
["5 of Swords" "Defeat"]
["6 of Swords" "Science"]
["7 of Swords" "Futility"]
["8 of Swords" "Interference"]
["9 of Swords" "Cruelty"]
["10 of Swords" "Ruin"]
["Page of Swords"]
["Knight of Swords"]
["Queen of Swords"]
["King of Swords"]
["Ace of Pentacles" "The Root of the Powers of Earth"]
["2 of Pentacles" "Change"]
["3 of Pentacles" "Work"]
["4 of Pentacles" "Power"]
["5 of Pentacles" "Worry"]
["6 of Pentacles" "Success"]
["7 of Pentacles" "Failure"]
["8 of Pentacles" "Prudence"]
["9 of Pentacles" "Gain"]
["10 of Pentacles" "Wealth"]
["Page of Pentacles"]
["Knight of Pentacles"]
["Queen of Pentacles"]
["King of Pentacles"]])
("major arcana" [["Fool" "La Follie ou l'Alchemiste" "http://en.wikipedia.org/wiki/The_Fool_(Tarot_card)"]
["Magician" "Le Magicien ou le Bateleur" "http://en.wikipedia.org/wiki/The_Magician_(Tarot_card)"]
["High Priestess" "Repos" "http://en.wikipedia.org/wiki/The_High_Priestess_(Tarot_card)"]
["Empress" "Les Astres" "http://en.wikipedia.org/wiki/The_Empress_(Tarot_card)"]
["Emperor" "Les Ouiseaux et les Poissons" "http://en.wikipedia.org/wiki/The_Emperor_(Tarot_card)"]
["Hierophant" "Le Grand pretre" "http://en.wikipedia.org/wiki/The_Hierophant_(Tarot_card)"]
["Lovers" "Le Chaos" "http://en.wikipedia.org/wiki/The_Lovers_(Tarot_card)"]
["Chariot" "Le Despote africain" "http://en.wikipedia.org/wiki/The_Chariot_(Tarot_card)"]
["Strength" "La Force" "http://en.wikipedia.org/wiki/The_Chariot_(Tarot_card)"]
["Hermit" "Le Capucin" "http://en.wikipedia.org/wiki/The_Hermit_(Tarot_card)"]
["Wheel of Fortune" "La Roue de Fortune" "http://en.wikipedia.org/wiki/Wheel_of_Fortune_(Tarot_card)"]
["Justice" "La Justice" "http://en.wikipedia.org/wiki/Strength_(Tarot_card)"]
["Hanged Man" "La Prudence" "http://en.wikipedia.org/wiki/The_Hanged_Man_(Tarot_card)"]
["Death" "La Mort" "http://en.wikipedia.org/wiki/The_Hanged_Man_(Tarot_card)"]
["Temperance" "La Temperance" "http://en.wikipedia.org/wiki/Temperance_(Tarot_card)"]
["Devil" "Le Diable" "http://en.wikipedia.org/wiki/The_Devil_(Tarot_card)"]
["Tower" "Le Temple Foudroye" "http://en.wikipedia.org/wiki/The_Tower_(Tarot_card)"]
["Star" "La Ciel" "http://en.wikipedia.org/wiki/The_Star_(Tarot_card)"]
["Moon" "Les Plantes" "http://en.wikipedia.org/wiki/The_Moon_(Tarot_card)"]
["Sun" "La Lumiere" "http://en.wikipedia.org/wiki/The_Sun_(Tarot_card)"]
["Judgement" "Le Jugement Dernier" "http://en.wikipedia.org/wiki/Judgment_(Tarot_card)"]
["World" "L'homme et les Quadrupedes" "http://en.wikipedia.org/wiki/The_World_(Tarot_card)"]
])
;;separate just because the deck is WIP
("javetarot" [["Fool" "La Follie ou l'Alchemiste" "http://en.wikipedia.org/wiki/The_Fool_(Tarot_card)"]
["Magician" "Le Magicien ou le Bateleur" "http://en.wikipedia.org/wiki/The_Magician_(Tarot_card)"]
["High Priestess" "Repos" "http://en.wikipedia.org/wiki/The_High_Priestess_(Tarot_card)"]
["Empress" "Les Astres" "http://en.wikipedia.org/wiki/The_Empress_(Tarot_card)"]
["Emperor" "Les Ouiseaux et les Poissons" "http://en.wikipedia.org/wiki/The_Emperor_(Tarot_card)"]
["Hierophant" "Le Grand pretre" "http://en.wikipedia.org/wiki/The_Hierophant_(Tarot_card)"]
["Lovers" "Le Chaos" "http://en.wikipedia.org/wiki/The_Lovers_(Tarot_card)"]
["Chariot" "Le Despote africain" "http://en.wikipedia.org/wiki/The_Chariot_(Tarot_card)"]
["Strength" "La Force" "http://en.wikipedia.org/wiki/The_Chariot_(Tarot_card)"]
["Hermit" "Le Capucin" "http://en.wikipedia.org/wiki/The_Hermit_(Tarot_card)"]
["Wheel of Fortune" "La Roue de Fortune" "http://en.wikipedia.org/wiki/Wheel_of_Fortune_(Tarot_card)"]
["Justice" "La Justice" "http://en.wikipedia.org/wiki/Strength_(Tarot_card)"]
["Hanged Man" "La Prudence" "http://en.wikipedia.org/wiki/The_Hanged_Man_(Tarot_card)"]
["Death" "La Mort" "http://en.wikipedia.org/wiki/The_Hanged_Man_(Tarot_card)"]
["Temperance" "La Temperance" "http://en.wikipedia.org/wiki/Temperance_(Tarot_card)"]
["Devil" "Le Diable" "http://en.wikipedia.org/wiki/The_Devil_(Tarot_card)"]
["Tower" "Le Temple Foudroye" "http://en.wikipedia.org/wiki/The_Tower_(Tarot_card)"]
["Star" "La Ciel" "http://en.wikipedia.org/wiki/The_Star_(Tarot_card)"]
["Moon" "Les Plantes" "http://en.wikipedia.org/wiki/The_Moon_(Tarot_card)"]
["Sun" "La Lumiere" "http://en.wikipedia.org/wiki/The_Sun_(Tarot_card)"]
["Judgement" "Le Jugement Dernier" "http://en.wikipedia.org/wiki/Judgment_(Tarot_card)"]
["World" "L'homme et les Quadrupedes" "http://en.wikipedia.org/wiki/The_World_(Tarot_card)"]
])
))
(defun random-aref (array)
(let ((index (random (length array))))
(values (aref array index) index)))
(defun read-tarot-card (card)
(let ((len (length card)))
(if (>= len 2)
(concat (aref card 0) " (" (aref card 1) ") "
(if (>= len 3) (org-make-link-string (aref card 2) "wikipedia") ) )
(aref card 0))))
(defun tarot-card ()
(multiple-value-bind
(card index) (random-aref tarot-deck)
(read-tarot-card card)))
(defun tarot-draw-card ()
(interactive)
(message "%s" (tarot-card)))
(defun tarot-cards (n)
(let ((pack tarot-deck)
stack)
(dotimes (i n)
(multiple-value-bind
(card index) (random-aref pack)
(setq stack (cons card stack))
(setq pack (delete (aref pack index) pack))))
stack))
(defun tarot-choose-deck (deck)
(interactive (list (completing-read "deck:" (mapcar 'car tarot-decks) )))
;;todo
(setq tarot-deck (cadr (assoc deck tarot-decks))))
(tarot-choose-deck "Tarot") ;;default deck
(defvar tarot-spreads
'(( "simple"
( "Past"
"Present"
"Future"
"Outcome"))
( "celtic"
("Present"
"Immediate Challenge"
"Distant Past"
"Recent Past"
"Best Outcome"
"Immediate Future"
"Factors"
"External Influences"
"Hopes and Fears"
"Final Outcome"
)))
)
(defun tarot-formatted-spread-texts ( spread-name)
(let* ( (maxlen (apply 'max (mapcar 'length (cadr (assoc spread-name tarot-spreads))))))
(mapcar (lambda (x) (format (concat "%-" (number-to-string maxlen) "s :") x)) (cadr (assoc spread-name tarot-spreads))))
)
(defun tarot-spread (spread-name)
(interactive (list (completing-read "spread:" (mapcar 'car tarot-spreads) ))) ;;TODO completion TODO handle deck selection
(random t);;shuffling the deck is important TODO
(pop-to-buffer (get-buffer-create "*Spread*"))
(org-mode)
(erase-buffer)
(let* (
(import (tarot-formatted-spread-texts spread-name))
(stack (tarot-cards (length import)))
)
(dolist (card stack)
(insert (car import) " ")
(setq import (cdr import))
(insert (read-tarot-card card) )
;; (insert (format " [[file:tarot_of_marseilles/%s.jpg]]" (aref card 0) ))
(insert (format " [[file:jave_tarot/%s.svg]]" (aref card 0) ))
(insert "\n")
))
)
;;;;
(defun tarot-get-images ()
(interactive)
(loop for cardno from 1 to 21 by 1 do
(with-current-buffer (skip-http-headers
(url-retrieve-synchronously (format "http://upload.wikimedia.org/wikipedia/commons/1/1d/Jean_Dodal_Tarot_trump_%s.jpg" cardno))
)
(write-file (format "/tmp/t%s.jpg" cardno))))
)
(defun skip-http-headers (buffer)
"Remove HTTP headers from BUFFER, and return it.
Assumes headers are indeed present!"
(with-current-buffer buffer
(widen)
(goto-char (point-min))
(search-forward "\n\n")
(delete-region (point-min) (point))
buffer))
;;; tarot.el ends here