]> code.delx.au - gnu-emacs/blob - lisp/obsolete/yow.el
auto upstream
[gnu-emacs] / lisp / obsolete / yow.el
1 ;;; yow.el --- quote random zippyisms
2
3 ;; Copyright (C) 1993-1995, 2000-2013 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Author: Richard Mlynarik
7 ;; Keywords: games
8 ;; Obsolete-since: 24.4
9
10 ;; This file is part of GNU Emacs.
11
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.
16
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.
21
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/>.
24
25 ;;; Commentary:
26
27 ;; Important pinheadery for GNU Emacs.
28 ;; This file is obsolete. For similar functionality, see
29 ;; fortune.el and cookie1.el.
30
31 ;;; Code:
32
33 (require 'cookie1)
34
35 (defgroup yow nil
36 "Quote random zippyisms."
37 :prefix "yow-"
38 :group 'games)
39
40 (defcustom yow-file (expand-file-name "yow.lines" data-directory)
41 "File containing pertinent pinhead phrases."
42 :type 'file
43 :group 'yow)
44
45 (defconst yow-load-message "Am I CONSING yet?...")
46 (defconst yow-after-load-message "I have SEEN the CONSING!!")
47
48 ;;;###autoload
49 (defun yow (&optional insert display)
50 "Return or display a random Zippy quotation. With prefix arg, insert it."
51 (interactive "P\np")
52 (let ((yow (cookie yow-file yow-load-message yow-after-load-message)))
53 (cond (insert
54 (insert yow))
55 ((not display)
56 yow)
57 (t
58 (message "%s" yow)))))
59
60 (defsubst read-zippyism (prompt &optional require-match)
61 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
62 If optional second arg is non-nil, require input to match a completion."
63 (read-cookie prompt yow-file yow-load-message yow-after-load-message
64 require-match))
65
66 ;;;###autoload
67 (defun insert-zippyism (&optional zippyism)
68 "Prompt with completion for a known Zippy quotation, and insert it at point."
69 (interactive (list (read-zippyism "Pinhead wisdom: " t)))
70 (insert zippyism))
71
72 ;;;###autoload
73 (defun apropos-zippy (regexp)
74 "Return a list of all Zippy quotes matching REGEXP.
75 If called interactively, display a list of matches."
76 (interactive "sApropos Zippy (regexp): ")
77 ;; Make sure yows are loaded
78 (cookie yow-file yow-load-message yow-after-load-message)
79 (let* ((case-fold-search t)
80 (cookie-table-symbol (intern yow-file cookie-cache))
81 (string-table (symbol-value cookie-table-symbol))
82 (matches nil)
83 (len (length string-table))
84 (i 0))
85 (save-match-data
86 (while (< i len)
87 (and (string-match regexp (aref string-table i))
88 (setq matches (cons (aref string-table i) matches)))
89 (setq i (1+ i))))
90 (and matches
91 (setq matches (sort matches 'string-lessp)))
92 (and (called-interactively-p 'interactive)
93 (cond ((null matches)
94 (message "No matches found."))
95 (t
96 (let ((l matches))
97 (with-output-to-temp-buffer "*Zippy Apropos*"
98 (while l
99 (princ (car l))
100 (setq l (cdr l))
101 (and l (princ "\n\n")))
102 (help-print-return-message))))))
103 matches))
104
105 \f
106 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
107 ;; fun, fun, fun. Entertainment for hours...
108 ;;
109 ;; written by Kayvan Aghaiepour
110
111 (declare-function doctor-ret-or-read "doctor" (arg))
112
113 ;;;###autoload
114 (defun psychoanalyze-pinhead ()
115 "Zippy goes to the analyst."
116 (interactive)
117 (doctor) ; start the psychotherapy
118 (message "")
119 (switch-to-buffer "*doctor*")
120 (sit-for 0)
121 (while (not (input-pending-p))
122 (insert (yow))
123 (sit-for 0)
124 (doctor-ret-or-read 1)
125 (doctor-ret-or-read 1)))
126
127 (provide 'yow)
128
129 ;;; yow.el ends here