comparison lisp/play/doctor.el @ 68248:3a3f5ed673b0

Move defvars out of eval-when-compile. Use dolist. (doc-mode-map): Define explicitly. (doctor-txtype): Use mapc.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 18 Jan 2006 16:49:53 +0000
parents a4fe475f3c8b
children 79697c70111b d88caeac70d7
comparison
equal deleted inserted replaced
68247:b96fcf6e016c 68248:3a3f5ed673b0
1 ;;; doctor.el --- psychological help for frustrated users 1 ;;; doctor.el --- psychological help for frustrated users
2 2
3 ;; Copyright (C) 1985, 1987, 1994, 1996, 2000, 2002, 2003, 2004, 3 ;; Copyright (C) 1985, 1987, 1994, 1996, 2000, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc. 4 ;; 2005, 2006 Free Software Foundation, Inc.
5 5
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Keywords: games 7 ;; Keywords: games
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
44 ;; for a discussion of why and how this file was censored, and the 44 ;; for a discussion of why and how this file was censored, and the
45 ;; political implications of the issue. 45 ;; political implications of the issue.
46 46
47 ;;; Code: 47 ;;; Code:
48 48
49 (eval-when-compile 49 (defvar **mad**) (defvar *debug*) (defvar *print-space*)
50 (defvar **mad**) (defvar *debug*) (defvar *print-space*) 50 (defvar *print-upcase*) (defvar abuselst) (defvar abusewords)
51 (defvar *print-upcase*) (defvar abuselst) (defvar abusewords) 51 (defvar account) (defvar afraidof) (defvar arerelated)
52 (defvar account) (defvar afraidof) (defvar arerelated) 52 (defvar areyou) (defvar bak) (defvar beclst)
53 (defvar areyou) (defvar bak) (defvar beclst) 53 (defvar bother) (defvar bye) (defvar canyou)
54 (defvar bother) (defvar bye) (defvar canyou) 54 (defvar chatlst) (defvar continue) (defvar deathlst)
55 (defvar chatlst) (defvar continue) (defvar deathlst) 55 (defvar describe) (defvar drnk) (defvar drugs)
56 (defvar describe) (defvar drnk) (defvar drugs) 56 (defvar eliza-flag) (defvar elizalst) (defvar famlst)
57 (defvar eliza-flag) (defvar elizalst) (defvar famlst) 57 (defvar feared) (defvar fears) (defvar feelings-about)
58 (defvar feared) (defvar fears) (defvar feelings-about) 58 (defvar foullst) (defvar found) (defvar hello)
59 (defvar foullst) (defvar found) (defvar hello) 59 (defvar history) (defvar howareyoulst) (defvar howdyflag)
60 (defvar history) (defvar howareyoulst) (defvar howdyflag) 60 (defvar huhlst) (defvar ibelieve) (defvar improve)
61 (defvar huhlst) (defvar ibelieve) (defvar improve) 61 (defvar inter) (defvar isee) (defvar isrelated)
62 (defvar inter) (defvar isee) (defvar isrelated) 62 (defvar lincount) (defvar longhuhlst) (defvar lover)
63 (defvar lincount) (defvar longhuhlst) (defvar lover) 63 (defvar machlst) (defvar mathlst) (defvar maybe)
64 (defvar machlst) (defvar mathlst) (defvar maybe) 64 (defvar moods) (defvar neglst) (defvar obj)
65 (defvar moods) (defvar neglst) (defvar obj) 65 (defvar object) (defvar owner) (defvar please)
66 (defvar object) (defvar owner) (defvar please) 66 (defvar problems) (defvar qlist) (defvar random-adjective)
67 (defvar problems) (defvar qlist) (defvar random-adjective) 67 (defvar relation) (defvar remlst) (defvar repetitive-shortness)
68 (defvar relation) (defvar remlst) (defvar repetitive-shortness) 68 (defvar replist) (defvar rms-flag) (defvar schoollst)
69 (defvar replist) (defvar rms-flag) (defvar schoollst) 69 (defvar sent) (defvar sexlst) (defvar shortbeclst)
70 (defvar sent) (defvar sexlst) (defvar shortbeclst) 70 (defvar shortlst) (defvar something) (defvar sportslst)
71 (defvar shortlst) (defvar something) (defvar sportslst) 71 (defvar stallmanlst) (defvar states) (defvar subj)
72 (defvar stallmanlst) (defvar states) (defvar subj) 72 (defvar suicide-flag) (defvar sure) (defvar things)
73 (defvar suicide-flag) (defvar sure) (defvar things) 73 (defvar thlst) (defvar toklst) (defvar typos)
74 (defvar thlst) (defvar toklst) (defvar typos) 74 (defvar verb) (defvar want) (defvar whatwhen)
75 (defvar verb) (defvar want) (defvar whatwhen) 75 (defvar whereoutp) (defvar whysay) (defvar whywant)
76 (defvar whereoutp) (defvar whysay) (defvar whywant) 76 (defvar zippy-flag) (defvar zippylst)
77 (defvar zippy-flag) (defvar zippylst))
78 77
79 (defun doc// (x) x) 78 (defun doc// (x) x)
80 79
81 (defmacro doc$ (what) 80 (defmacro doc$ (what)
82 "quoted arg form of doctor-$" 81 "quoted arg form of doctor-$"
88 (first (car vv)) 87 (first (car vv))
89 (ww (append (cdr vv) (list first)))) 88 (ww (append (cdr vv) (list first))))
90 (set what ww) 89 (set what ww)
91 first)) 90 first))
92 91
92 (defvar doc-mode-map
93 (let ((map (make-sparse-keymap)))
94 (define-key map "\n" 'doctor-read-print)
95 (define-key map "\r" 'doctor-ret-or-read)
96 map))
97
93 (define-derived-mode doctor-mode text-mode "Doctor" 98 (define-derived-mode doctor-mode text-mode "Doctor"
94 "Major mode for running the Doctor (Eliza) program. 99 "Major mode for running the Doctor (Eliza) program.
95 Like Text mode with Auto Fill mode 100 Like Text mode with Auto Fill mode
96 except that RET when point is after a newline, or LFD at any time, 101 except that RET when point is after a newline, or LFD at any time,
97 reads the sentence before point, and prints the Doctor's answer." 102 reads the sentence before point, and prints the Doctor's answer."
99 (turn-on-auto-fill) 104 (turn-on-auto-fill)
100 (doctor-type '(i am the psychotherapist \. 105 (doctor-type '(i am the psychotherapist \.
101 (doc$ please) (doc$ describe) your (doc$ problems) \. 106 (doc$ please) (doc$ describe) your (doc$ problems) \.
102 each time you are finished talking, type \R\E\T twice \.)) 107 each time you are finished talking, type \R\E\T twice \.))
103 (insert "\n")) 108 (insert "\n"))
104
105 (define-key doctor-mode-map "\n" 'doctor-read-print)
106 (define-key doctor-mode-map "\r" 'doctor-ret-or-read)
107 109
108 (defun make-doctor-variables () 110 (defun make-doctor-variables ()
109 (make-local-variable 'typos) 111 (make-local-variable 'typos)
110 (setq typos 112 (setq typos
111 (mapcar (function (lambda (x) 113 (mapcar (function (lambda (x)
1076 they them themselves theirs 1078 they them themselves theirs
1077 anybody everybody somebody 1079 anybody everybody somebody
1078 anyone everyone someone 1080 anyone everyone someone
1079 anything something everything))) 1081 anything something everything)))
1080 1082
1081 (mapcar (function (lambda (x) (put x 'doctor-sentence-type 'verb))) 1083 (dolist (x
1082 '(abort aborted aborts ask asked asks am 1084 '(abort aborted aborts ask asked asks am
1083 applied applies apply are associate 1085 applied applies apply are associate
1084 associated ate 1086 associated ate
1085 be became become becomes becoming 1087 be became become becomes becoming
1086 been being believe believed believes 1088 been being believe believed believes
1087 bit bite bites bore bored bores boring bought buy buys buying 1089 bit bite bites bore bored bores boring bought buy buys buying
1088 call called calling calls came can caught catch come 1090 call called calling calls came can caught catch come
1089 contract contracted contracts control controlled controls 1091 contract contracted contracts control controlled controls
1090 could croak croaks croaked cut cuts 1092 could croak croaks croaked cut cuts
1091 dare dared define defines dial dialed dials did die died dies 1093 dare dared define defines dial dialed dials did die died dies
1092 dislike disliked 1094 dislike disliked
1093 dislikes do does drank drink drinks drinking 1095 dislikes do does drank drink drinks drinking
1094 drive drives driving drove dying 1096 drive drives driving drove dying
1095 eat eating eats expand expanded expands 1097 eat eating eats expand expanded expands
1096 expect expected expects expel expels expelled 1098 expect expected expects expel expels expelled
1097 explain explained explains 1099 explain explained explains
1098 fart farts feel feels felt fight fights find finds finding 1100 fart farts feel feels felt fight fights find finds finding
1099 forget forgets forgot fought found 1101 forget forgets forgot fought found
1100 fuck fucked fucking fucks 1102 fuck fucked fucking fucks
1101 gave get gets getting give gives go goes going gone got gotten 1103 gave get gets getting give gives go goes going gone got gotten
1102 had harm harms has hate hated hates have having 1104 had harm harms has hate hated hates have having
1103 hear heard hears hearing help helped helping helps 1105 hear heard hears hearing help helped helping helps
1104 hit hits hope hoped hopes hurt hurts 1106 hit hits hope hoped hopes hurt hurts
1105 implies imply is 1107 implies imply is
1106 join joined joins jump jumped jumps 1108 join joined joins jump jumped jumps
1107 keep keeping keeps kept 1109 keep keeping keeps kept
1108 kill killed killing kills kiss kissed kisses kissing 1110 kill killed killing kills kiss kissed kisses kissing
1109 knew know knows 1111 knew know knows
1110 laid lay lays let lets lie lied lies like liked likes 1112 laid lay lays let lets lie lied lies like liked likes
1111 liking listen listens 1113 liking listen listens
1112 login look looked looking looks 1114 login look looked looking looks
1113 lose losing lost 1115 lose losing lost
1114 love loved loves loving 1116 love loved loves loving
1115 luse lusing lust lusts 1117 luse lusing lust lusts
1116 made make makes making may mean means meant might 1118 made make makes making may mean means meant might
1117 move moved moves moving must 1119 move moved moves moving must
1118 need needed needs 1120 need needed needs
1119 order ordered orders ought 1121 order ordered orders ought
1120 paid pay pays pick picked picking picks 1122 paid pay pays pick picked picking picks
1121 placed placing prefer prefers put puts 1123 placed placing prefer prefers put puts
1122 ran rape raped rapes 1124 ran rape raped rapes
1123 read reading reads recall receive received receives 1125 read reading reads recall receive received receives
1124 refer refered referred refers 1126 refer refered referred refers
1125 relate related relates remember remembered remembers 1127 relate related relates remember remembered remembers
1126 romp romped romps run running runs 1128 romp romped romps run running runs
1127 said sang sat saw say says 1129 said sang sat saw say says
1128 screw screwed screwing screws scrod see sees seem seemed 1130 screw screwed screwing screws scrod see sees seem seemed
1129 seems seen sell selling sells 1131 seems seen sell selling sells
1130 send sendind sends sent shall shoot shot should 1132 send sendind sends sent shall shoot shot should
1131 sing sings sit sits sitting sold studied study 1133 sing sings sit sits sitting sold studied study
1132 take takes taking talk talked talking talks tell tells telling 1134 take takes taking talk talked talking talks tell tells telling
1133 think thinks 1135 think thinks
1134 thought told took tooled touch touched touches touching 1136 thought told took tooled touch touched touches touching
1135 transfer transferred transfers transmit transmits transmitted 1137 transfer transferred transfers transmit transmits transmitted
1136 type types types typing 1138 type types types typing
1137 walk walked walking walks want wanted wants was watch 1139 walk walked walking walks want wanted wants was watch
1138 watched watching went were will wish would work worked works 1140 watched watching went were will wish would work worked works
1139 write writes writing wrote use used uses using)) 1141 write writes writing wrote use used uses using))
1142 (put x 'doctor-sentence-type 'verb))
1140 1143
1141 (defun doctor-verbp (x) (if (symbolp x) 1144 (defun doctor-verbp (x) (if (symbolp x)
1142 (eq (get x 'doctor-sentence-type) 'verb))) 1145 (eq (get x 'doctor-sentence-type) 'verb)))
1143 1146
1144 (defun doctor-plural (x) 1147 (defun doctor-plural (x)
1383 ;; Output of replies. 1386 ;; Output of replies.
1384 1387
1385 (defun doctor-txtype (ans) 1388 (defun doctor-txtype (ans)
1386 "Output to buffer a list of symbols or strings as a sentence." 1389 "Output to buffer a list of symbols or strings as a sentence."
1387 (setq *print-upcase* t *print-space* nil) 1390 (setq *print-upcase* t *print-space* nil)
1388 (mapcar 'doctor-type-symbol ans) 1391 (mapc 'doctor-type-symbol ans)
1389 (insert "\n")) 1392 (insert "\n"))
1390 1393
1391 (defun doctor-type-symbol (word) 1394 (defun doctor-type-symbol (word)
1392 "Output a symbol to the buffer with some fancy case and spacing hacks." 1395 "Output a symbol to the buffer with some fancy case and spacing hacks."
1393 (setq word (doctor-make-string word)) 1396 (setq word (doctor-make-string word))
1654 1657
1655 (defun doctor-chat () (doctor-type (doc$ chatlst))) 1658 (defun doctor-chat () (doctor-type (doc$ chatlst)))
1656 1659
1657 (provide 'doctor) 1660 (provide 'doctor)
1658 1661
1659 ;;; arch-tag: 579380f6-4902-4ea5-bccb-6339e30e1257 1662 ;; arch-tag: 579380f6-4902-4ea5-bccb-6339e30e1257
1660 ;;; doctor.el ends here 1663 ;;; doctor.el ends here