1 ;;; yow.el --- quote random zippyisms
3 ;; Copyright (C) 1993-1995, 2000-2012 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 3 of the License, or
14 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
26 ;; Important pinheadery for GNU Emacs.
28 ;; See cookie1.el for implementation. Note --- the `n' argument of yow
29 ;; from the 18.xx implementation is no longer; we only support *random*
37 "Quote random zippyisms."
41 (defcustom yow-file (concat data-directory "yow.lines")
42 "File containing pertinent pinhead phrases."
46 (defconst yow-load-message "Am I CONSING yet?...")
47 (defconst yow-after-load-message "I have SEEN the CONSING!!")
50 (defun yow (&optional insert display)
51 "Return or display a random Zippy quotation. With prefix arg, insert it."
53 (let ((yow (cookie yow-file yow-load-message yow-after-load-message)))
59 (message "%s" yow)))))
61 (defsubst read-zippyism (prompt &optional require-match)
62 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
63 If optional second arg is non-nil, require input to match a completion."
64 (read-cookie prompt yow-file yow-load-message yow-after-load-message
68 (defun insert-zippyism (&optional zippyism)
69 "Prompt with completion for a known Zippy quotation, and insert it at point."
70 (interactive (list (read-zippyism "Pinhead wisdom: " t)))
74 (defun apropos-zippy (regexp)
75 "Return a list of all Zippy quotes matching REGEXP.
76 If called interactively, display a list of matches."
77 (interactive "sApropos Zippy (regexp): ")
78 ;; Make sure yows are loaded
79 (cookie yow-file yow-load-message yow-after-load-message)
80 (let* ((case-fold-search t)
81 (cookie-table-symbol (intern yow-file cookie-cache))
82 (string-table (symbol-value cookie-table-symbol))
84 (len (length string-table))
88 (and (string-match regexp (aref string-table i))
89 (setq matches (cons (aref string-table i) matches)))
92 (setq matches (sort matches 'string-lessp)))
93 (and (called-interactively-p 'interactive)
95 (message "No matches found."))
98 (with-output-to-temp-buffer "*Zippy Apropos*"
102 (and l (princ "\n\n")))
103 (help-print-return-message))))))
107 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
108 ;; fun, fun, fun. Entertainment for hours...
110 ;; written by Kayvan Aghaiepour
112 (declare-function doctor-ret-or-read "doctor" (arg))
115 (defun psychoanalyze-pinhead ()
116 "Zippy goes to the analyst."
118 (doctor) ; start the psychotherapy
120 (switch-to-buffer "*doctor*")
122 (while (not (input-pending-p))
125 (doctor-ret-or-read 1)
126 (doctor-ret-or-read 1)))