xref: /386bsd/usr/local/lib/emacs/19.25/lisp/yow.el (revision a2142627)
1;;; yow.el --- quote random zippyisms
2
3;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4
5;; Maintainer: FSF
6;; Author: Richard Mlynarik
7;; Keywords: games
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING.  If not, write to
23;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24
25;;; Commentary:
26
27;; Important pinheadery for GNU Emacs.
28;;
29;; See cookie1.el for implementation.  Note --- the `n' argument of yow
30;; from the 18.xx implementation is no longer; we only support *random*
31;; random access now.
32
33;;; Code:
34
35(require 'cookie1)
36
37(defvar yow-file (concat data-directory "yow.lines")
38   "File containing pertinent pinhead phrases.")
39
40;;;###autoload
41(defun yow (&optional insert)
42  "Return or display a random Zippy quotation.  With prefix arg, insert it."
43  (interactive "P")
44  (let ((yow (cookie yow-file
45		     "Am I CONSING yet?..." "I have SEEN the CONSING!!")))
46    (cond (insert
47	   (insert yow))
48	  ((not (interactive-p))
49	   yow)
50	  ((not (string-match "\n" yow))
51	   (delete-windows-on (get-buffer-create "*Help*"))
52	   (message "%s" yow))
53	  (t
54	   (message "Yow!")
55	   (with-output-to-temp-buffer "*Help*"
56	     (princ yow))))))
57
58(defsubst read-zippyism (prompt &optional require-match)
59  "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
60If optional second arg is non-nil, require input to match a completion."
61  (read-cookie prompt yow-file
62	       "Am I CONSING yet?..." "I have SEEN the CONSING!!"
63	       require-match))
64
65;;;###autoload
66(defun insert-zippyism (&optional zippyism)
67  "Prompt with completion for a known Zippy quotation, and insert it at point."
68  (interactive (list (read-zippyism "Pinhead wisdom: " t)))
69  (insert zippyism))
70
71; Yowza!! Feed zippy quotes to the doctor. Watch results.
72; fun, fun, fun. Entertainment for hours...
73;
74; written by Kayvan Aghaiepour
75
76;;;###autoload
77(defun psychoanalyze-pinhead ()
78  "Zippy goes to the analyst."
79  (interactive)
80  (doctor)				; start the psychotherapy
81  (message "")
82  (switch-to-buffer "*doctor*")
83  (sit-for 0)
84  (while (not (input-pending-p))
85    (insert-string (yow))
86    (sit-for 0)
87    (doctor-ret-or-read 1)
88    (doctor-ret-or-read 1)))
89
90(provide 'yow)
91
92;;; yow.el ends here
93