1 ;;; yow.el --- quote random zippyisms
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
6 ;; Author: Richard Mlynarik
9 ;; This file is part of GNU Emacs.
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)
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.
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 the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Important pinheadery for GNU Emacs.
30 ;; See cookie1.el for implementation. Note --- the `n' argument of yow
31 ;; from the 18.xx implementation is no longer; we only support *random*
39 "Quote random zippyisms."
43 (defcustom yow-file
(concat data-directory
"yow.lines")
44 "File containing pertinent pinhead phrases."
48 (defconst yow-load-message
"Am I CONSING yet?...")
49 (defconst yow-after-load-message
"I have SEEN the CONSING!!")
52 (defun yow (&optional insert
)
53 "Return or display a random Zippy quotation. With prefix arg, insert it."
55 (let ((yow (cookie yow-file yow-load-message yow-after-load-message
)))
58 ((not (interactive-p))
60 ((not (string-match "\n" yow
))
61 (delete-windows-on (get-buffer-create "*Help*"))
65 (with-output-to-temp-buffer "*Help*"
68 (set-buffer standard-output
)
71 (defsubst read-zippyism
(prompt &optional require-match
)
72 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
73 If optional second arg is non-nil, require input to match a completion."
74 (read-cookie prompt yow-file yow-load-message yow-after-load-message
78 (defun insert-zippyism (&optional zippyism
)
79 "Prompt with completion for a known Zippy quotation, and insert it at point."
80 (interactive (list (read-zippyism "Pinhead wisdom: " t
)))
84 (defun apropos-zippy (regexp)
85 "Return a list of all Zippy quotes matching REGEXP.
86 If called interactively, display a list of matches."
87 (interactive "sApropos Zippy (regexp): ")
88 ;; Make sure yows are loaded
89 (cookie yow-file yow-load-message yow-after-load-message
)
90 (let* ((case-fold-search t
)
91 (cookie-table-symbol (intern yow-file cookie-cache
))
92 (string-table (symbol-value cookie-table-symbol
))
94 (len (length string-table
))
98 (and (string-match regexp
(aref string-table i
))
99 (setq matches
(cons (aref string-table i
) matches
)))
102 (setq matches
(sort matches
'string-lessp
)))
104 (cond ((null matches
)
105 (message "No matches found."))
108 (with-output-to-temp-buffer "*Zippy Apropos*"
112 (and l
(princ "\n\n"))))))))
116 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
117 ;; fun, fun, fun. Entertainment for hours...
119 ;; written by Kayvan Aghaiepour
122 (defun psychoanalyze-pinhead ()
123 "Zippy goes to the analyst."
125 (doctor) ; start the psychotherapy
127 (switch-to-buffer "*doctor*")
129 (while (not (input-pending-p))
130 (insert-string (yow))
132 (doctor-ret-or-read 1)
133 (doctor-ret-or-read 1)))