1 yow.el --- generate random zippyisms
3 ;; Copyright (C) 1985, 1987 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 ; Randomize the seed in the random number generator.
24 ; Important pinheaddery for GNU Emacs.
25 ; Expects file emacs/etc/yow.lines to be in ITS-style LINS format
26 ; (ie strings terminated by ascii 0 characters. Leading whitespace ignored)
27 ; Everything up to the first \000 is a comment.
29 (defun yow (&optional n interactive
)
30 "Return or display a Zippy quotation."
33 (setq yow-vector
(snarf-yows)))
34 (cond (n (setq n
(prefix-numeric-value n
)))
35 ((>= (setq n
(random (length yow-vector
))) 0))
37 (let ((yow (aref yow-vector n
)))
38 (cond ((not interactive
)
40 ((not (string-match "\n" yow
))
41 (delete-windows-on (get-buffer-create "*Help*"))
45 (with-output-to-temp-buffer "*Help*"
48 (defvar yow-vector nil
"Pertinent pinhead statements")
49 (defun snarf-yows (&optional file
)
51 (let ((buf (generate-new-buffer " yow"))
53 (cursor-in-echo-area t
))
54 (message "Am I CONSING yet?...")
56 (insert-file-contents (or file
57 (expand-file-name "yow.lines" data-directory
)))
59 (while (progn (skip-chars-forward " \t\n\r\f") (not (eobp)))
62 (setq result
(cons (buffer-substring beg
(1- (point)))
65 (message "I have SEEN the CONSING!!" (length result
))
66 (apply 'vector
(nreverse result
)))))
68 ; Yowza!! Feed zippy quotes to the doctor. Watch results.
69 ; fun, fun, fun. Entertainment for hours...
71 ; written by Kayvan Aghaiepour
74 (defun psychoanalyze-pinhead ()
75 "Zippy goes to the analyst."
77 (doctor) ; start the psychotherapy
79 (setq yow-vector
(snarf-yows)))
81 (switch-to-buffer "*doctor*")
83 (while (not (input-pending-p))
86 (doctor-ret-or-read 1)
87 (doctor-ret-or-read 1)))