-
Notifications
You must be signed in to change notification settings - Fork 2
/
horoscope.el
406 lines (348 loc) · 14.7 KB
/
horoscope.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
;;; horoscope.el --- generate horoscopes -*- lexical-binding:t -*-
;; Author: Bob Manson <manson@cygnus.com>
;; Maintainer: Noah Friedman <friedman@prep.ai.mit.edu>
;; Keywords: extensions
;; Created: 1995-08-02
;; $Id: horoscope.el,v 1.2 1998/12/11 20:12:16 friedman Exp $
;; Bozoup(P) 1995 The Bozo(tic) Softwar(e) Founda(t)ion, Inc.
;; See the BOZO Antipasto for further information.
;; If this is useful to you, may you forever be blessed by the Holy Lord
;; Patty. AT&T you will.
;;; Commentary:
;; Bob Manson originally wrote this program in ksh,
;; then later converted it to emacs lisp.
;; Noah Friedman rewrote parts of the engine.
;;; Code:
(defconst horoscope-paragraph
'(("*sentence." "*sentence2." "*sentence." "*sentence2."
"You'll" "*when" "be" "*state." "*luckynum.")
("*sentence." "*sentence2." "*sentence2." "You'll" "*when" "be" "*state.")
("*sentence2." "*sentence." "*sentence." "*sentence2."
"You'll" "*when" "be" "*state.")))
(defconst horoscope-sentence
'(("!person" "will" "*personverb" "*attime")
("!attime" "is not a good time for" "*action")
("Your" "*noun" "will" "*verb" "soon")
("!thing" "is in the air")
("You will discover that" "*discovery")
("!attime" "will be a good time for" "*action")
("Be sure to" "*verb" "before you find out that" "*discovery")
("Your programs will start" "*action")
("Look for" "*person" "with one eye")
("Don't let" "*person" "*dothing" "with your" "*noun")
("Listen to your" "*noun" "*attime")
("Your" "*noun" "will be" "*change" "in the next" "*vaguenumber" "*time")
("!thingstodo")
("You might want to consider" "*action")
("!time" "from now" "*action" "may seem" "*likevalue")
("Do not" "*verb" "*attime")
("!person" "will be a" "*adjective" "*relationship")
("!attime" "*person" "will" "*thingstodo")
("Don't" "*thingstodo" "*attime")
("Put your" "*noun" "on hold" "*attime")
("Loaning money to your" "*relationship" "will bring dividends")
("*bullshit")))
(defconst horoscope-sentence2
'(("!person" "will eventually reveal itself to be" "*person")
("Your efforts at" "*action" "turn out to be" "*value")
("Many people will ask you for advice about" "*action")
("!person" "will think of you as" "*person")
("Beware of" "*person" "bearing" "*thing")
("Loving your" "*noun" "now will turn out to be"
"*value" "after a few" "*time")
("Don't forget to" "*thingstodo")
("!thingstodo" "with the help of" "*person")
("Never" "*thingstodo" "without" "*action" "first")
("Do something nice for" "*person" "*attime")
("You will meet" "*person" "this week")
("Your" "*noun" "will need to be" "*thingverb" "*attime")
("!evilpeople" "will" "*verb" "*attime")
("!attime" "*thing" "would be a good thing to" "*consider")
("Stealing a" "*noun" "should not be" "*try")
("Your finances will become" "*moneystates"
"in the next several" "*time")
("*bullshit")))
(defconst horoscope-personverb
'(("sit next to you on the bus")
("give you good advice")
("become pregnant")
("kiss you")
("make you feel warm and fuzzy")
("eat your mail")
("lift weights")
("hit you")
("give you pennies")
("share intimate feelings")
("throw up") ("splode")))
(defconst horoscope-thingverb
'(("replaced") ("repaired") ("opened up") ("rewired")
("burped") ("kicked") ("bathed") ("kissed") ("petted")
("scrubbed") ("rubbed") ("massaged") ("fondled")
("excommunicated") ("removed") ("destroyed")
("eaten") ("turned")))
(defconst horoscope-bullshit
'(("As" "*planet" "moves into" "*zodplace,"
"be careful of your relationship with your" "*relationship")
("You will be in conflict with" "*zodiac"
"since" "*planet" "has moved into" "*zodiac")))
(defconst horoscope-planet
'(("Mercury") ("Venus") ("Mars") ("Jupiter") ("Saturn")
("Uranus") ("Neptune") ("Pluto") ("the Moon")))
(defconst horoscope-zodplace
'(("*zodiac") ("the" "*number" "house of" "*zodiac")
("the" "*side" "of" "*zodiac")))
(defconst horoscope-number
'(("first") ("second") ("third") ("11th") ("392nd")))
(defconst horoscope-side
'(("left-hand quadrant") ("right-hand quadrant")
("upper half") ("lower half") ("middle")))
(defconst horoscope-zodiac
'(("Pisces") ("Sagitarius") ("Cancer") ("Leo") ("Gemini")
("Taurus") ("Scorpio") ("Aquarius") ("Capricorn") ("Virgo")))
(defconst horoscope-luckynum
'(("Your lucky number today is 29842924728. Look for it everywhere")
("12 is your lucky number")
("Your lucky numbers are 20, 30, and 40")
("Don't forget, it's only 366 days at most until Christmas")))
(defconst horoscope-person
'(("a stranger") ("a friend") ("your" "*relationship")
("someone you" "*greeted" "*times" "at" "*event")
("your" "*animal") ("your teddy bear")
("your mom") ("the mailman") ("the man")
("your wonderful pet" "*animal") ("your child")
("your spouse") ("God") ("a wallflower") ("a lout")
("a warmonger") ("two other people put together")
("someone you know")))
(defconst horoscope-animal
'(("dog") ("cat") ("horse") ("elephant") ("piglet")
("mouse") ("rat") ("cheetah") ("giraffe") ("mutant shrimp")
("talking fish") ("crustacean") ("moose") ("algae") ("amoeba")))
(defconst horoscope-action
'(("moving") ("thinking") ("making love")
("straining in the toilet")
("washing clothes") ("becoming pregnant")
("doing something") ("asking for a raise")
("starting a revolution") ("becoming paranoid")
("reading mail") ("talking with piglet3")
("balancing a checkbook") ("talking")
("gossiping") ("stealing from the company")
("buying a new computer") ("sleeping")
("using a Torx #9 wrench") ("telephoning")
("not answering the phone")
("staying where you are") ("cleaning the fridge")
("wearing clothes")))
(defconst horoscope-thingstodo
'(("set your clock") ("get married" "*attime")
("dye your hair") ("move away") ("exercise")
("have your" "*noun" "spayed or neutered")
("watch Dr. Who") ("watch Wheel of Fortune")
("see your psychologist") ("talk to your plants")
("pet piglet") ("clean your apartment")
("think about financial concerns")
("discuss life with RMS") ("marry the milkperson")
("adjust your girdle") ("tune your stereo")
("tune your car") ("lift weights") ("paint") ("draw")
("play Sam and Max Hit the Road")
("play Car Bomb")))
(defconst horoscope-time
'(("months") ("days") ("years") ("seconds") ("minutes") ("hours")))
(defconst horoscope-attime
'(("today") ("tomorrow") ("this week") ("this month")))
(defconst horoscope-try
'(("attempted lightly")
("tried without the advice of a doctor")
("considered unusual")
("done under the influence of alcohol")
("achieved with the help of ZenIRC")
("done while wearing a girdle") ("stared at")
("questioned by" "*person")
("performed by a" "*relationship")
("shown on TV") ("demonstrated")
("shown to small children")))
(defconst horoscope-value
'(("worthless") ("futile") ("mysterious") ("quite worthwhile")
("costly") ("a good idea") ("unhealthy")
("a positive step in the right direction")))
(defconst horoscope-likevalue
'(("worthless") ("futile") ("mysterious")
("quite worthwhile") ("expensive")
("like a good idea") ("unhealthy")
("like a positive step in the right direction")))
(defconst horoscope-noun
'(("dog") ("cat") ("anteater") ("chicken") ("television")
("computer") ("telephone") ("abode") ("vehicle") ("sister")
("rhinocerous") ("piglet") ("alien") ("tetrodotoxin")
("dinoflagellate") ("endothermic therapsid")
("life insurance") ("child")))
(defconst horoscope-dothing
'(("brush its teeth") ("take a bath") ("make love")
("mow the lawn") ("go shopping") ("dig")
("rotate the TV antenna") ("eat worms")
("genetically engineer your plants")
("drink a bath")
("get life insurance from a TV ad")))
(defconst horoscope-verb
'(("become pregnant") ("eat holes in your carpet")
("piss on the bed") ("eat watermelon")
("sell your house")
("give away your" "*relationship" "to" "*evilpeople")
("talk to piglet") ("get a" "*noun")
("have financial problems")
("adjust your girdle") ("sit quietly") ("sleep")
("drive") ("put money in the bank") ("play games")))
(defconst horoscope-evilpeople
'(("Iranians") ("Iraquis") ("Americans")
("god-fearing Crustaceans") ("aliens") ("\"Bob\"")
("the Doctor") ("Frenchmen") ("Germans")
("piglet-haters") ("aliens from Mars")))
(defconst horoscope-evilperson
'(("Iranian") ("Iraqui") ("American")
("god-fearing Crustacean") ("alien") ("bobbie")
("loon") ("Frenchman") ("Germans") ("piglet-haters")
("alien from Mars") ("Republican") ("Democrat")
("Communist") ("Socialist") ("idiot") ("artist")))
(defconst horoscope-thing
'(("romance") ("nasty body odor")
("fortune (good or bad)") ("a gift")
("a small bomb") ("a flight recorder")
("a large dog") ("a piglet") ("a steering wheel")
("a toaster oven with a built-in clock radio")
("an egg") ("food") ("ice") ("bad weather")
("good weather") ("milk") ("a deadly disease")))
(defconst horoscope-discovery
'(("you are married") ("you have two left feet")
("Nazi Germany is your country of birth")
("you do not have a pet")
("several Conspiracy members are following you")
("the wives are catching colds")
("your" "*relationship" "is confused")
("your spouse is an alien")
("you lost your piglet")
("someone thinks of you as Liza Minelli")
("you are Murphy Brown's child")
("your long-lost brother is lost")
("Michael Jackson is abusing your" "*noun")
("*relationship" "was responsible for the overthrow of Communist Russia")
("your" "*relationship" "is a" "*evilperson")
("you're originally from" "*planet")
("using a" "*noun" "as a sex toy is" "*value")))
(defconst horoscope-state
'(("happy") ("unhappy") ("confused") ("sad")
("enlightened") ("a Borg") ("fulfilled") ("gay") ("tall")
("ill") ("shrunk") ("abused") ("tired") ("broke")))
(defconst horoscope-statenoun
'(("happiness") ("unhappiness") ("confusion") ("sadness")
("enlightenment") ("bogosity") ("fulfillment") ("gaiety") ("tallness")
("illness") ("lossage") ("bozosity") ("weariness")))
(defconst horoscope-change
'(("fluctuating") ("changing")
("turning" "*color")
("turning") ("*color")))
(defconst horoscope-color
'(("green") ("red") ("blue") ("black") ("brown")
("yellow") ("orange") ("fuscia") ("mauve") ("plaid")))
(defconst horoscope-when
'(("soon") ("eventually") ("later") ("never") ("someday") ("often")
("fall into a state of" "*statenoun," "but eventually")
("sometimes") ("perhaps in a few" "*time")
("once in a while")))
(defconst horoscope-adjective
'(("good") ("bad") ("indifferent") ("valuable")
("expensive") ("sick") ("unhappy")))
(defconst horoscope-relationship
'(("friend") ("enemy") ("relative") ("coworker")
("slave") ("mother") ("sister") ("spouse") ("owner")
("parent") ("child")))
(defconst horoscope-moneystates
'(("unstable") ("positive") ("financial") ("good")
("bad") ("important") ("unimportant") ("exposed")
("significant")))
(defconst horoscope-vaguenumber
'(("few") ("several") ("4 or 9") ("1 or 7")))
(defconst horoscope-greeted
'(("said hello to") ("shook hands with") ("met")
("talked to") ("screwed") ("kissed") ("fondled gently")
("blessed") ("gave an organ to")))
(defconst horoscope-times
'(("once") ("twice") ("a few times") ("5 or 11 times")
("3 to 6 times") ("thrice") ("988,122 times")))
(defconst horoscope-event
'(("a party") ("a gathering of some sort")
("a social reception") ("an intimate office party")
("Maria Shriver's wedding") ("Michael Jackson's trial")
("a bad""frat party") ("Underwear City")))
(defconst horoscope-consider
'(("ponder") ("think about") ("consider") ("try")
("make a stab at") ("meditate upon")
("look at deeply")))
(defvar horoscope-random-state nil)
;;;###autoload
(defun horoscope (&optional insertp)
"Generate a random horoscope.
If called interactively, display the resulting horoscope in a buffer.
If called with a prefix argument or the lisp argument INSERTP non-nil,
isnert the resulting horoscope into the current buffer."
(interactive "P")
(let* ((horoscope-random-state
(cl-make-random-state (time-to-days (current-time))))
(s (horoscope-iterate-list
(horoscope-random-member horoscope-paragraph) "horoscope-")))
(and (or insertp (called-interactively-p 'interactive))
(horoscope-display s "*Horoscope*" insertp))
s))
(defun horoscope-display (string temp-buffer-name insertp)
(let ((temp-buffer-show-function temp-buffer-show-function)
(temp-buffer-show-hook
(lambda ()
(fill-paragraph nil))))
(if insertp
(save-restriction
(narrow-to-region (point) (point))
(insert string)
(fill-paragraph nil))
(with-output-to-temp-buffer temp-buffer-name
(princ string)))))
;; Return a random member of list A.
(defun horoscope-random-member (a)
(and a
(listp a)
(nth (cl-random (length a) horoscope-random-state) a)))
;; Process entries from list LISTNAME and from RESTOFLIST, handling periods
;; and commas at the end of LISTNAME as needed.
(defun horoscope-getlist (listname restoflist prefix)
(let* ((lastchar (aref listname (1- (length listname))))
(punct-char-p (memq lastchar '(?. ?,)))
(period-p (= lastchar ?.))
(suffix (if punct-char-p
(substring listname 0 -1)
listname)))
(concat (horoscope-iterate-list
(horoscope-random-member
(symbol-value (intern (concat prefix suffix))))
prefix)
(cond (period-p
(concat (char-to-string lastchar) " "))
(punct-char-p
(char-to-string lastchar))
(t ""))
(if restoflist " " "")
(horoscope-iterate-list restoflist prefix))))
;; Iterate over list A, replacing all strings beginning with a '*' or '!'
;; with a random selection from the appropriate list.
(defun horoscope-iterate-list (a prefix)
(cond ((null a) a)
((= (aref (car a) 0) ?*)
(horoscope-getlist (substring (car a) 1) (cdr a) prefix))
((= (aref (car a) 0) ?!)
(horoscope-capitalize
(horoscope-getlist (substring (car a) 1) (cdr a) prefix)))
(t
(concat (car a)
(if (cdr a) " " "")
(horoscope-iterate-list (cdr a) prefix)))))
(defun horoscope-capitalize (a)
(let ((new (copy-sequence a)))
(aset new 0 (upcase (aref new 0)))
new))
(provide 'horoscope)
;; horoscope.el ends here