]> code.delx.au - gnu-emacs/blobdiff - lisp/play/doctor.el
Add a new function `svg-embed'
[gnu-emacs] / lisp / play / doctor.el
index 54a5a4ef6c96cf3cc091f66172b5133d654e8783..f575928dda6eeab0f5f993d257a01d3ebb031e01 100644 (file)
@@ -1,9 +1,9 @@
 ;;; doctor.el --- psychological help for frustrated users
 
-;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2011
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2016 Free Software
+;; Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: games
 
 ;; This file is part of GNU Emacs.
@@ -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)
@@ -831,17 +832,17 @@ Otherwise call the Doctor to parse preceding sentence."
       (doctor-read-print)
     (newline arg)))
 
-(defun doctor-read-print nil
+(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)
@@ -859,25 +860,25 @@ Otherwise call the Doctor to parse preceding sentence."
 \f
 ;; Main processing function for sentences that have been read.
 
-(defun doctor-doc (sent)
+(defun doctor-doc ()
   (cond
-   ((equal sent '(foo))
+   ((equal doctor-sent '(foo))
     (doctor-type '(bar! (doc$ doctor--please) (doc$ doctor--continue) \.)))
-   ((member sent doctor--howareyoulst)
+   ((member doctor-sent doctor--howareyoulst)
     (doctor-type '(i\'m ok \.  (doc$ doctor--describe) yourself \.)))
-   ((or (member sent '((good bye) (see you later) (i quit) (so long)
-                      (go away) (get lost)))
-       (memq (car sent)
+   ((or (member doctor-sent '((good bye) (see you later) (i quit) (so long)
+                             (go away) (get lost)))
+       (memq (car doctor-sent)
              '(bye halt break quit done exit goodbye
                    bye\, stop pause goodbye\, stop pause)))
     (doctor-type (doc$ doctor--bye)))
-   ((and (eq (car sent) 'you)
-        (memq (cadr sent) doctor--abusewords))
-    (setq doctor-found (cadr sent))
+   ((and (eq (car doctor-sent) 'you)
+        (memq (cadr doctor-sent) doctor--abusewords))
+    (setq doctor-found (cadr doctor-sent))
     (doctor-type (doc$ doctor--abuselst)))
-   ((eq (car sent) 'whatmeans)
-    (doctor-def (cadr sent)))
-   ((equal sent '(parse))
+   ((eq (car doctor-sent) 'whatmeans)
+    (doctor-def (cadr doctor-sent)))
+   ((equal doctor-sent '(parse))
     (doctor-type (list  'subj '= doctor-subj ",  "
                        'verb '= doctor-verb "\n"
                        'object 'phrase '= doctor-obj ","
@@ -889,29 +890,31 @@ Otherwise call the Doctor to parse preceding sentence."
                        'sentence 'used 'was
                        "..."
                        '(doc// doctor--bak))))
-   ((memq (car sent) '(are is do has have how when where who why))
+   ((memq (car doctor-sent) '(are is do has have how when where who why))
     (doctor-type (doc$ doctor--qlist)))
    ;;   ((eq (car sent) 'forget)
    ;;    (set (cadr sent) nil)
    ;;    (doctor-type '((doc$ doctor--isee) (doc$ doctor--please)
    ;;     (doc$ doctor--continue)\.)))
    (t
-    (if (doctor-defq sent) (doctor-define sent doctor-found))
-    (if (> (length sent) 12) (setq sent (doctor-shorten sent)))
-    (setq sent (doctor-correct-spelling (doctor-replace sent doctor--replist)))
-    (cond ((and (not (memq 'me sent)) (not (memq 'i sent))
-               (memq 'am sent))
-          (setq sent (doctor-replace sent '((am . (are)))))))
-    (cond ((equal (car sent) 'yow) (doctor-zippy))
-         ((< (length sent) 2)
-          (cond ((eq (doctor-meaning (car sent)) 'howdy)
+    (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))
+               (memq 'am doctor-sent))
+          (setq doctor-sent (doctor-replace doctor-sent '((am . (are)))))))
+    (cond ((equal (car doctor-sent) 'yow) (doctor-zippy))
+         ((< (length doctor-sent) 2)
+          (cond ((eq (doctor-meaning (car doctor-sent)) 'howdy)
                  (doctor-howdy))
                 (t (doctor-short))))
          (t
-          (if (memq 'am sent)
-              (setq sent (doctor-replace sent '((me . (i))))))
-          (setq sent (doctor-fixup sent))
-          (if (and (eq (car sent) 'do) (eq (cadr sent) 'not))
+          (if (memq 'am doctor-sent)
+              (setq doctor-sent (doctor-replace doctor-sent '((me . (i))))))
+          (setq doctor-sent (doctor-fixup doctor-sent))
+          (if (and (eq (car doctor-sent) 'do) (eq (cadr doctor-sent) 'not))
               (cond ((zerop (random 3))
                      (doctor-type '(are you (doc$ doctor--afraidof) that \?)))
                     ((zerop (random 2))
@@ -920,9 +923,9 @@ Otherwise call the Doctor to parse preceding sentence."
                      (doctor-rthing))
                     (t
                      (doctor-type '((doc$ doctor--whysay) that i shouldn\'t
-                                    (cddr sent)
+                                    (cddr doctor-sent)
                                     \?))))
-            (doctor-go (doctor-wherego sent))))))))
+            (doctor-go (doctor-wherego doctor-sent))))))))
 \f
 ;; Things done to process sentences once read.
 
@@ -986,7 +989,7 @@ Otherwise call the Doctor to parse preceding sentence."
 Put dialogue in buffer."
   (let (a
        (prompt (concat (doctor-make-string x)
-                       " what \?  "))
+                       " what ?  "))
        retval)
     (while (not retval)
           (while (not a)
@@ -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