2374
c00b3b357392
(psychoanalyze-pinhead) Needed a prefrontal lobotomy. I gave it one.
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1 ;;; yow.el --- quote random zippyisms
|
772
|
2
|
32092
b0a117b99837
(yow): Don't display multi-line quotations in a *Help* buffer, since the
Miles Bader <miles@gnu.org>
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 2000 Free Software Foundation, Inc.
|
841
|
4
|
772
|
5 ;; Maintainer: FSF
|
7127
|
6 ;; Author: Richard Mlynarik
|
812
|
7 ;; Keywords: games
|
656
|
8
|
46
|
9 ;; This file is part of GNU Emacs.
|
|
10
|
|
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
|
807
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
46
|
14 ;; any later version.
|
|
15
|
|
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.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
14169
|
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.
|
46
|
25
|
772
|
26 ;;; Commentary:
|
|
27
|
3591
|
28 ;; Important pinheadery for GNU Emacs.
|
2320
|
29 ;;
|
3384
|
30 ;; See cookie1.el for implementation. Note --- the `n' argument of yow
|
2320
|
31 ;; from the 18.xx implementation is no longer; we only support *random*
|
|
32 ;; random access now.
|
772
|
33
|
|
34 ;;; Code:
|
|
35
|
3384
|
36 (require 'cookie1)
|
2320
|
37
|
21363
|
38 (defgroup yow nil
|
|
39 "Quote random zippyisms."
|
|
40 :prefix "yow-"
|
|
41 :group 'games)
|
|
42
|
|
43 (defcustom yow-file (concat data-directory "yow.lines")
|
|
44 "File containing pertinent pinhead phrases."
|
|
45 :type 'file
|
|
46 :group 'yow)
|
46
|
47
|
13753
|
48 (defconst yow-load-message "Am I CONSING yet?...")
|
|
49 (defconst yow-after-load-message "I have SEEN the CONSING!!")
|
|
50
|
256
|
51 ;;;###autoload
|
42283
c04b89996164
(yow): Use an arg to distinguish interactive calls, not interactive-p.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
52 (defun yow (&optional insert display)
|
5622
|
53 "Return or display a random Zippy quotation. With prefix arg, insert it."
|
42283
c04b89996164
(yow): Use an arg to distinguish interactive calls, not interactive-p.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
54 (interactive "P\np")
|
13753
|
55 (let ((yow (cookie yow-file yow-load-message yow-after-load-message)))
|
5622
|
56 (cond (insert
|
|
57 (insert yow))
|
42283
c04b89996164
(yow): Use an arg to distinguish interactive calls, not interactive-p.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
58 ((not display)
|
46
|
59 yow)
|
|
60 (t
|
32092
b0a117b99837
(yow): Don't display multi-line quotations in a *Help* buffer, since the
Miles Bader <miles@gnu.org>
diff
changeset
|
61 (message "%s" yow)))))
|
46
|
62
|
4737
|
63 (defsubst read-zippyism (prompt &optional require-match)
|
|
64 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
|
|
65 If optional second arg is non-nil, require input to match a completion."
|
13753
|
66 (read-cookie prompt yow-file yow-load-message yow-after-load-message
|
4737
|
67 require-match))
|
5622
|
68
|
|
69 ;;;###autoload
|
|
70 (defun insert-zippyism (&optional zippyism)
|
|
71 "Prompt with completion for a known Zippy quotation, and insert it at point."
|
|
72 (interactive (list (read-zippyism "Pinhead wisdom: " t)))
|
|
73 (insert zippyism))
|
13753
|
74
|
|
75 ;;;###autoload
|
|
76 (defun apropos-zippy (regexp)
|
|
77 "Return a list of all Zippy quotes matching REGEXP.
|
|
78 If called interactively, display a list of matches."
|
|
79 (interactive "sApropos Zippy (regexp): ")
|
|
80 ;; Make sure yows are loaded
|
|
81 (cookie yow-file yow-load-message yow-after-load-message)
|
|
82 (let* ((case-fold-search t)
|
|
83 (cookie-table-symbol (intern yow-file cookie-cache))
|
|
84 (string-table (symbol-value cookie-table-symbol))
|
|
85 (matches nil)
|
|
86 (len (length string-table))
|
|
87 (i 0))
|
|
88 (save-match-data
|
|
89 (while (< i len)
|
|
90 (and (string-match regexp (aref string-table i))
|
|
91 (setq matches (cons (aref string-table i) matches)))
|
|
92 (setq i (1+ i))))
|
|
93 (and matches
|
|
94 (setq matches (sort matches 'string-lessp)))
|
|
95 (and (interactive-p)
|
|
96 (cond ((null matches)
|
|
97 (message "No matches found."))
|
|
98 (t
|
|
99 (let ((l matches))
|
|
100 (with-output-to-temp-buffer "*Zippy Apropos*"
|
|
101 (while l
|
|
102 (princ (car l))
|
|
103 (setq l (cdr l))
|
|
104 (and l (princ "\n\n"))))))))
|
|
105 matches))
|
|
106
|
46
|
107
|
13753
|
108 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
|
|
109 ;; fun, fun, fun. Entertainment for hours...
|
|
110 ;;
|
|
111 ;; written by Kayvan Aghaiepour
|
46
|
112
|
256
|
113 ;;;###autoload
|
46
|
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))
|
41559
|
122 (insert (yow))
|
46
|
123 (sit-for 0)
|
|
124 (doctor-ret-or-read 1)
|
|
125 (doctor-ret-or-read 1)))
|
|
126
|
584
|
127 (provide 'yow)
|
|
128
|
656
|
129 ;;; yow.el ends here
|