0
|
1 ;;; yow.el --- quote random zippyisms
|
|
2
|
4
|
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
|
0
|
4
|
|
5 ;; Maintainer: FSF
|
|
6 ;; Author: Richard Mlynarik
|
|
7 ;; Keywords: games
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; 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 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
16
|
22 ;; along with XEmacs; 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.
|
0
|
25
|
4
|
26 ;;; Synched up with: FSF 19.34.
|
0
|
27
|
|
28 ;;; Commentary:
|
|
29
|
|
30 ;; Important pinheadery for GNU Emacs.
|
|
31 ;;
|
|
32 ;; See cookie1.el for implementation. Note --- the `n' argument of yow
|
|
33 ;; from the 18.xx implementation is no longer; we only support *random*
|
|
34 ;; random access now.
|
|
35
|
|
36 ;;; Code:
|
|
37
|
|
38 (require 'cookie1)
|
|
39
|
|
40 (defvar yow-file (concat data-directory "yow.lines")
|
4
|
41 "File containing pertinent Pinhead Phrases.")
|
|
42
|
|
43 (defconst yow-load-message "Am I CONSING yet?...")
|
|
44 (defconst yow-after-load-message "I have SEEN the CONSING!!")
|
0
|
45
|
|
46 ;;;###autoload
|
|
47 (defun yow (&optional insert)
|
|
48 "Return or display a random Zippy quotation. With prefix arg, insert it."
|
|
49 (interactive "P")
|
4
|
50 (let ((yow (cookie yow-file yow-load-message yow-after-load-message)))
|
0
|
51 (cond (insert
|
|
52 (insert yow))
|
|
53 ((not (interactive-p))
|
|
54 yow)
|
|
55 ((not (string-match "\n" yow))
|
|
56 (delete-windows-on (get-buffer-create "*Help*"))
|
|
57 (message "%s" yow))
|
|
58 (t
|
|
59 (message "Yow!")
|
|
60 (with-output-to-temp-buffer "*Help*"
|
|
61 (princ yow)
|
|
62 (save-excursion
|
|
63 (set-buffer standard-output)
|
|
64 (help-mode)))))))
|
|
65
|
|
66 (defun read-zippyism (prompt &optional require-match)
|
|
67 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
|
|
68 If optional second arg is non-nil, require input to match a completion."
|
4
|
69 (read-cookie prompt yow-file yow-load-message yow-after-load-message
|
0
|
70 require-match))
|
4
|
71
|
0
|
72 ;;;###autoload
|
|
73 (defun insert-zippyism (&optional zippyism)
|
|
74 "Prompt with completion for a known Zippy quotation, and insert it at point."
|
|
75 (interactive (list (read-zippyism "Pinhead wisdom: " t)))
|
|
76 (insert zippyism))
|
4
|
77
|
|
78 ;;;###autoload
|
|
79 (defun apropos-zippy (regexp)
|
|
80 "Return a list of all Zippy quotes matching REGEXP.
|
|
81 If called interactively, display a list of matches."
|
|
82 (interactive "sApropos Zippy (regexp): ")
|
|
83 ;; Make sure yows are loaded
|
|
84 (cookie yow-file yow-load-message yow-after-load-message)
|
|
85 (let* ((case-fold-search t)
|
|
86 (cookie-table-symbol (intern yow-file cookie-cache))
|
|
87 (string-table (symbol-value cookie-table-symbol))
|
|
88 (matches nil)
|
|
89 (len (length string-table))
|
|
90 (i 0))
|
|
91 (save-match-data
|
|
92 (while (< i len)
|
|
93 (and (string-match regexp (aref string-table i))
|
|
94 (setq matches (cons (aref string-table i) matches)))
|
|
95 (setq i (1+ i))))
|
|
96 (and matches
|
|
97 (setq matches (sort matches 'string-lessp)))
|
|
98 (and (interactive-p)
|
|
99 (cond ((null matches)
|
|
100 (message "No matches found."))
|
|
101 (t
|
|
102 (let ((l matches))
|
|
103 (with-output-to-temp-buffer "*Zippy Apropos*"
|
|
104 (while l
|
|
105 (princ (car l))
|
|
106 (setq l (cdr l))
|
|
107 (and l (princ "\n\n"))))))))
|
|
108 matches))
|
|
109
|
0
|
110
|
4
|
111 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
|
|
112 ;; fun, fun, fun. Entertainment for hours...
|
|
113 ;;
|
|
114 ;; written by Kayvan Aghaiepour
|
0
|
115
|
|
116 ;;;###autoload
|
|
117 (defun psychoanalyze-pinhead ()
|
|
118 "Zippy goes to the analyst."
|
|
119 (interactive)
|
|
120 (doctor) ; start the psychotherapy
|
4
|
121 (message "")
|
0
|
122 (switch-to-buffer "*doctor*")
|
|
123 (sit-for 0)
|
|
124 (while (not (input-pending-p))
|
4
|
125 (insert-string (yow))
|
0
|
126 (sit-for 0)
|
|
127 (doctor-ret-or-read 1)
|
|
128 (doctor-ret-or-read 1)))
|
|
129
|
|
130 (provide 'yow)
|
|
131
|
|
132 ;;; yow.el ends here
|