]> code.delx.au - gnu-emacs/blobdiff - lisp/play/doctor.el
Update copyright year to 2015
[gnu-emacs] / lisp / play / doctor.el
index 600f67cedd60180bf51b29f44d3c98cb6fc94a27..3da7267ca8e12e053dc9cebe2d33673c950029bc 100644 (file)
@@ -1,9 +1,9 @@
 ;;; doctor.el --- psychological help for frustrated users
 
-;; Copyright (C) 1985, 1987, 1994, 1996, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2015 Free Software
+;; Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: games
 
 ;; This file is part of GNU Emacs.
 (defun doc// (x) x)
 
 (defmacro doc$ (what)
-  "quoted arg form of doctor-$"
+  "Quoted arg form of doctor-$."
   `(doctor-$ ',what))
 
 (defun doctor-$ (what)
-  "Return the car of a list, rotating the list each time"
+  "Return the car of a list, rotating the list each time."
   (let* ((vv (symbol-value what))
        (first (car vv))
        (ww (append (cdr vv) (list first))))
@@ -141,7 +141,7 @@ reads the sentence before point, and prints the Doctor's answer."
   (turn-on-auto-fill)
   (doctor-type '(i am the psychotherapist \.
                 (doc$ doctor--please) (doc$ doctor--describe) your (doc$ doctor--problems) \.
-                each time you are finished talking, type \R\E\T twice \.))
+                each time you are finished talking\, type \R\E\T twice \.))
   (insert "\n"))
 
 (defun make-doctor-variables ()
@@ -163,6 +163,7 @@ reads the sentence before point, and prints the Doctor's answer."
                 (you7re you\'re (i am))
                 (you7ve you\'ve (i have))
                 (you7ll you\'ll (i will)))))
+  (set (make-local-variable 'doctor-sent) nil)
   (set (make-local-variable 'doctor-found) nil)
   (set (make-local-variable 'doctor-owner) nil)
   (set (make-local-variable 'doctor--history) nil)
@@ -268,7 +269,7 @@ reads the sentence before point, and prints the Doctor's answer."
         (you seem to dwell on (doc// doctor-owner) family \.)
         ((doc$ doctor--areyou) hung up on (doc// doctor-owner) family \?)))
   (set (make-local-variable 'doctor--huhlst)
-       '(((doc$ doctor--whysay)(doc// doctor-sent) \?)
+       '(((doc$ doctor--whysay) (doc// doctor-sent) \?)
         (is it because of (doc$ doctor--things) that you say (doc// doctor-sent) \?)))
   (set (make-local-variable 'doctor--longhuhlst)
        '(((doc$ doctor--whysay) that \?)
@@ -371,8 +372,8 @@ reads the sentence before point, and prints the Doctor's answer."
         (did you watch a lot of crime and violence on television as a child \?)))
   (set (make-local-variable 'doctor--sexlst)
        '(((doc$ doctor--areyou) (doc$ doctor--afraidof) sex \?)
-        ((doc$ doctor--describe)(doc$ doctor--something) about your sexual history \.)
-        ((doc$ doctor--please)(doc$ doctor--describe) your sex life \.\.\.)
+        ((doc$ doctor--describe) (doc$ doctor--something) about your sexual history \.)
+        ((doc$ doctor--please) (doc$ doctor--describe) your sex life \.\.\.)
         ((doc$ doctor--describe) your (doc$ doctor--feelings-about) your sexual partner \.)
         ((doc$ doctor--describe) your most (doc$ doctor--random-adjective) sexual experience \.)
         ((doc$ doctor--areyou) satisfied with (doc// doctor--lover) \.\.\. \?)))
@@ -384,11 +385,11 @@ reads the sentence before point, and prints the Doctor's answer."
                                       ((doc$ doctor--bother) i ask that \?)))
   (set (make-local-variable 'doctor--beclst)
        '((is it because (doc// doctor-sent) that you came to me \?)
-        ((doc$ doctor--bother)(doc// doctor-sent) \?)
+        ((doc$ doctor--bother) (doc// doctor-sent) \?)
         (when did you first know that (doc// doctor-sent) \?)
         (is the fact that (doc// doctor-sent) the real reason \?)
         (does the fact that (doc// doctor-sent) explain anything else \?)
-        ((doc$ doctor--areyou)(doc$ doctor--sure)(doc// doctor-sent) \? )))
+        ((doc$ doctor--areyou) (doc$ doctor--sure) (doc// doctor-sent) \? )))
   (set (make-local-variable 'doctor--shortbeclst)
    '(((doc$ doctor--bother) i ask you that \?)
      (that\'s not much of an answer!)
@@ -398,15 +399,15 @@ reads the sentence before point, and prints the Doctor's answer."
      (don\'t be (doc$ doctor--afraidof) elaborating \.)
      ((doc$ doctor--please) go into more detail \.)))
   (set (make-local-variable 'doctor--thlst)
-       '(((doc$ doctor--maybe)(doc$ doctor--thing)(doc$ doctor--isrelated) this \.)
-        ((doc$ doctor--maybe)(doc$ doctor--things)(doc$ doctor--arerelated) this \.)
+       '(((doc$ doctor--maybe) (doc$ doctor--thing) (doc$ doctor--isrelated) this \.)
+        ((doc$ doctor--maybe) (doc$ doctor--things) (doc$ doctor--arerelated) this \.)
         (is it because of (doc$ doctor--things) that you are going through all this \?)
         (how do you reconcile (doc$ doctor--things) \? )
-        ((doc$ doctor--maybe) this (doc$ doctor--isrelated)(doc$ doctor--things) \?)))
+        ((doc$ doctor--maybe) this (doc$ doctor--isrelated) (doc$ doctor--things) \?)))
   (set (make-local-variable 'doctor--remlst)
        '((earlier you said (doc$ doctor--history) \?)
         (you mentioned that (doc$ doctor--history) \?)
-        ((doc$ doctor--whysay)(doc$ doctor--history) \? )))
+        ((doc$ doctor--whysay) (doc$ doctor--history) \? )))
   (set (make-local-variable 'doctor--toklst)
        '((is this how you relax \?)
         (how long have you been smoking        grass \?)
@@ -415,7 +416,7 @@ reads the sentence before point, and prints the Doctor's answer."
        '((do you get (doc// doctor-found) often \?)
         (do you enjoy being (doc// doctor-found) \?)
         (what makes you (doc// doctor-found) \?)
-        (how often (doc$ doctor--areyou)(doc// doctor-found) \?)
+        (how often (doc$ doctor--areyou) (doc// doctor-found) \?)
         (when were you last (doc// doctor-found) \?)))
   (set (make-local-variable 'doctor--replist) '((i . (you))
                                        (my . (your))
@@ -831,17 +832,17 @@ Otherwise call the Doctor to parse preceding sentence."
       (doctor-read-print)
     (newline arg)))
 
-(defun doctor-read-print nil
-  "top level loop"
+(defun doctor-read-print ()
+  "Top level loop."
   (interactive)
-  (let ((sent (doctor-readin)))
-    (insert "\n")
-    (setq doctor--lincount (1+ doctor--lincount))
-    (doctor-doc sent)
-    (insert "\n")
-    (setq doctor--bak sent)))
-
-(defun doctor-readin nil
+  (setq doctor-sent (doctor-readin))
+  (insert "\n")
+  (setq doctor--lincount (1+ doctor--lincount))
+  (doctor-doc)
+  (insert "\n")
+  (setq doctor--bak doctor-sent))
+
+(defun doctor-readin ()
   "Read a sentence.  Return it as a list of words."
   (let (sentence)
     (backward-sentence 1)
@@ -850,7 +851,7 @@ Otherwise call the Doctor to parse preceding sentence."
     sentence))
 
 (defun doctor-read-token ()
-  "read one word from buffer"
+  "Read one word from buffer."
   (prog1 (intern (downcase (buffer-substring (point)
                                             (progn
                                               (forward-word 1)
@@ -859,14 +860,14 @@ Otherwise call the Doctor to parse preceding sentence."
 \f
 ;; Main processing function for sentences that have been read.
 
-(defun doctor-doc (doctor-sent)
+(defun doctor-doc ()
   (cond
    ((equal doctor-sent '(foo))
-    (doctor-type '(bar! (doc$ doctor--please)(doc$ doctor--continue) \.)))
+    (doctor-type '(bar! (doc$ doctor--please) (doc$ doctor--continue) \.)))
    ((member doctor-sent doctor--howareyoulst)
     (doctor-type '(i\'m ok \.  (doc$ doctor--describe) yourself \.)))
    ((or (member doctor-sent '((good bye) (see you later) (i quit) (so long)
-                      (go away) (get lost)))
+                             (go away) (get lost)))
        (memq (car doctor-sent)
              '(bye halt break quit done exit goodbye
                    bye\, stop pause goodbye\, stop pause)))
@@ -891,15 +892,17 @@ Otherwise call the Doctor to parse preceding sentence."
                        '(doc// doctor--bak))))
    ((memq (car doctor-sent) '(are is do has have how when where who why))
     (doctor-type (doc$ doctor--qlist)))
-   ;;   ((eq (car doctor-sent) 'forget)
-   ;;    (set (cadr doctor-sent) nil)
-   ;;    (doctor-type '((doc$ doctor--isee)(doc$ doctor--please)
+   ;;   ((eq (car sent) 'forget)
+   ;;    (set (cadr sent) nil)
+   ;;    (doctor-type '((doc$ doctor--isee) (doc$ doctor--please)
    ;;     (doc$ doctor--continue)\.)))
    (t
     (if (doctor-defq doctor-sent) (doctor-define doctor-sent doctor-found))
-    (if (> (length doctor-sent) 12)(setq doctor-sent (doctor-shorten doctor-sent)))
-    (setq doctor-sent (doctor-correct-spelling (doctor-replace doctor-sent doctor--replist)))
-    (cond ((and (not (memq 'me doctor-sent))(not (memq 'i doctor-sent))
+    (if (> (length doctor-sent) 12)
+       (setq doctor-sent (doctor-shorten doctor-sent)))
+    (setq doctor-sent (doctor-correct-spelling
+                      (doctor-replace doctor-sent doctor--replist)))
+    (cond ((and (not (memq 'me doctor-sent)) (not (memq 'i doctor-sent))
                (memq 'am doctor-sent))
           (setq doctor-sent (doctor-replace doctor-sent '((am . (are)))))))
     (cond ((equal (car doctor-sent) 'yow) (doctor-zippy))
@@ -1020,7 +1023,7 @@ the subject noun, and return the portion of the sentence following it."
           nil))))
 
 (defun doctor-nounp (x)
-  "Returns t if the symbol argument is a noun."
+  "Return t if the symbol argument is a noun."
        (or (doctor-pronounp x)
            (not (or (doctor-verbp x)
                     (equal x 'not)
@@ -1028,7 +1031,7 @@ the subject noun, and return the portion of the sentence following it."
                     (doctor-modifierp x) )) ))
 
 (defun doctor-pronounp (x)
-  "Returns t if the symbol argument is a pronoun."
+  "Return t if the symbol argument is a pronoun."
   (memq x '(
        i me mine myself
        we us ours ourselves ourself
@@ -1130,8 +1133,8 @@ the subject noun, and return the portion of the sentence following it."
          (t 'something))))
 
 (defun doctor-getnoun (x)
-  (cond ((null x)(setq doctor-object 'something))
-       ((atom x)(setq doctor-object x))
+  (cond ((null x) (setq doctor-object 'something))
+       ((atom x) (setq doctor-object x))
        ((eq (length x) 1)
         (setq doctor-object (cond
                       ((doctor-nounp (setq doctor-object (car x))) doctor-object)
@@ -1304,7 +1307,7 @@ element pair in RLIST."
           sent)))
 
 (defun doctor-wherego (sent)
-  (cond ((null sent)(doc$ doctor--whereoutp))
+  (cond ((null sent) (doc$ doctor--whereoutp))
        ((null (doctor-meaning (car sent)))
         (doctor-wherego (cond ((zerop (random 2))
                                (reverse (cdr sent)))
@@ -1327,8 +1330,8 @@ and DOCTOR-OBJ."
       (setq foo (cdr foo)))
     (setq doctor-verb (car foo))
     (setq doctor-obj (doctor-getnoun (cdr foo)))
-    (cond ((eq doctor-object 'i)(setq doctor-object 'me))
-         ((eq doctor-subj 'me)(setq doctor-subj 'i)))
+    (cond ((eq doctor-object 'i) (setq doctor-object 'me))
+         ((eq doctor-subj 'me) (setq doctor-subj 'i)))
     (cond (mem (doctor-remember (list doctor-subj doctor-verb doctor-obj))))))
 
 (defun doctor-possess (sent key)
@@ -1414,7 +1417,7 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
 
 (defun doctor-rthing () (doctor-type (doc$ doctor--thlst)))
 
-(defun doctor-remem () (cond ((null doctor--history)(doctor-huh))
+(defun doctor-remem () (cond ((null doctor--history) (doctor-huh))
                             ((doctor-type (doc$ doctor--remlst)))))
 
 (defun doctor-howdy ()
@@ -1426,14 +1429,14 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
         (doctor-type '((doc$ doctor--please) (doc$ doctor--describe) (doc$ doctor--things) \.)))))
 
 (defun doctor-when ()
-  (cond ((< (length (memq doctor-found doctor-sent)) 3)(doctor-short))
+  (cond ((< (length (memq doctor-found doctor-sent)) 3) (doctor-short))
        (t
         (setq doctor-sent (cdr (memq doctor-found doctor-sent)))
         (setq doctor-sent (doctor-fixup doctor-sent))
-        (doctor-type '((doc$ doctor--whatwhen)(doc// doctor-sent) \?)))))
+        (doctor-type '((doc$ doctor--whatwhen) (doc// doctor-sent) \?)))))
 
 (defun doctor-conj ()
-  (cond ((< (length (memq doctor-found doctor-sent)) 4)(doctor-short))
+  (cond ((< (length (memq doctor-found doctor-sent)) 4) (doctor-short))
        (t
         (setq doctor-sent (cdr (memq doctor-found doctor-sent)))
         (setq doctor-sent (doctor-fixup doctor-sent))
@@ -1497,10 +1500,10 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
   (doctor-type (doc$ doctor--toklst)))
 
 (defun doctor-state ()
-  (doctor-type (doc$ doctor--states))(doctor-remember (list 'you 'were doctor-found)))
+  (doctor-type (doc$ doctor--states)) (doctor-remember (list 'you 'were doctor-found)))
 
 (defun doctor-mood ()
-  (doctor-type (doc$ doctor--moods))(doctor-remember (list 'you 'felt doctor-found)))
+  (doctor-type (doc$ doctor--moods)) (doctor-remember (list 'you 'felt doctor-found)))
 
 (defun doctor-fear ()
   (setq doctor--feared (doctor-setprep doctor-sent doctor-found))
@@ -1511,8 +1514,8 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
   (doctor-svo doctor-sent doctor-found 1 t)
   (cond ((memq 'not doctor-sent) (doctor-forget) (doctor-huh))
        ((equal doctor-subj 'you)
-        (doctor-type '(why do you (doc// doctor-verb)(doc// doctor-obj) \?)))
-       (t (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj))))))
+        (doctor-type '(why do you (doc// doctor-verb) (doc// doctor-obj) \?)))
+       (t (doctor-type '((doc$ doctor--whysay) (list doctor-subj doctor-verb doctor-obj))))))
 
 (defun doctor-symptoms ()
   (doctor-type '((doc$ doctor--maybe) you should consult a medical doctor\;
@@ -1523,14 +1526,14 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
   (doctor-hates1))
 
 (defun doctor-hates1 ()
-  (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj) \?)))
+  (doctor-type '((doc$ doctor--whysay) (list doctor-subj doctor-verb doctor-obj) \?)))
 
 (defun doctor-loves ()
   (doctor-svo doctor-sent doctor-found 1 t)
   (doctor-qloves))
 
 (defun doctor-qloves ()
-  (doctor-type '((doc$ doctor--bother)(list doctor-subj doctor-verb doctor-obj) \?)))
+  (doctor-type '((doc$ doctor--bother) (list doctor-subj doctor-verb doctor-obj) \?)))
 
 (defun doctor-love ()
   (doctor-svo doctor-sent doctor-found 1 t)
@@ -1564,7 +1567,7 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
 (defun doctor-sexnoun () (doctor-sexverb))
 
 (defun doctor-sexverb ()
-  (if (or (memq 'me doctor-sent)(memq 'myself doctor-sent)(memq 'i doctor-sent))
+  (if (or (memq 'me doctor-sent) (memq 'myself doctor-sent) (memq 'i doctor-sent))
       (doctor-foul)
     (doctor-type (doc$ doctor--sexlst))))
 
@@ -1575,9 +1578,9 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
                       (equal doctor-found 'killing))
                   (memq 'yourself doctor-sent)))
         (setq doctor--suicide-flag t)
-        (doctor-type '(If you are really suicidal, you might
+        (doctor-type '(If you are really suicidal\, you might
                           want to contact the Samaritans via
-                          E-mail: jo@samaritans.org or, at your option,
+                          E-mail: jo@samaritans.org or\, at your option\,
                           anonymous E-mail: samaritans@anon.twwells.com\ \.
                            or find a Befrienders crisis center at
                           http://www.befrienders.org/\ \.
@@ -1617,8 +1620,6 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
 
 (defun doctor-chat () (doctor-type (doc$ doctor--chatlst)))
 
-(random t)
-
 (provide 'doctor)
 
 ;;; doctor.el ends here