1 ;;; yow.el --- quote random zippyisms
3 ;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
7 ;; Author: Richard Mlynarik
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; Important pinheadery for GNU Emacs.
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*
38 "Quote random zippyisms."
42 (defcustom yow-file
(concat data-directory
"yow.lines")
43 "File containing pertinent pinhead phrases."
47 (defconst yow-load-message
"Am I CONSING yet?...")
48 (defconst yow-after-load-message
"I have SEEN the CONSING!!")
51 (defun yow (&optional insert display
)
52 "Return or display a random Zippy quotation. With prefix arg, insert it."
54 (let ((yow (cookie yow-file yow-load-message yow-after-load-message
)))
60 (message "%s" yow
)))))
62 (defsubst read-zippyism
(prompt &optional require-match
)
63 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
64 If optional second arg is non-nil, require input to match a completion."
65 (read-cookie prompt yow-file yow-load-message yow-after-load-message
69 (defun insert-zippyism (&optional zippyism
)
70 "Prompt with completion for a known Zippy quotation, and insert it at point."
71 (interactive (list (read-zippyism "Pinhead wisdom: " t
)))
75 (defun apropos-zippy (regexp)
76 "Return a list of all Zippy quotes matching REGEXP.
77 If called interactively, display a list of matches."
78 (interactive "sApropos Zippy (regexp): ")
79 ;; Make sure yows are loaded
80 (cookie yow-file yow-load-message yow-after-load-message
)
81 (let* ((case-fold-search t
)
82 (cookie-table-symbol (intern yow-file cookie-cache
))
83 (string-table (symbol-value cookie-table-symbol
))
85 (len (length string-table
))
89 (and (string-match regexp
(aref string-table i
))
90 (setq matches
(cons (aref string-table i
) matches
)))
93 (setq matches
(sort matches
'string-lessp
)))
94 (and (called-interactively-p 'interactive
)
96 (message "No matches found."))
99 (with-output-to-temp-buffer "*Zippy Apropos*"
103 (and l
(princ "\n\n")))
104 (help-print-return-message))))))
108 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
109 ;; fun, fun, fun. Entertainment for hours...
111 ;; written by Kayvan Aghaiepour
113 (declare-function doctor-ret-or-read
"doctor" (arg))
116 (defun psychoanalyze-pinhead ()
117 "Zippy goes to the analyst."
119 (doctor) ; start the psychotherapy
121 (switch-to-buffer "*doctor*")
123 (while (not (input-pending-p))
126 (doctor-ret-or-read 1)
127 (doctor-ret-or-read 1)))
131 ;; arch-tag: d13db89b-84f1-4141-a5ce-261d1733a65c