Mercurial > hg > xemacs-beta
comparison lisp/games/yow.el @ 72:b9518feda344 r20-0b31
Import from CVS: tag r20-0b31
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:03:46 +0200 |
parents | 131b0175ea99 |
children |
comparison
equal
deleted
inserted
replaced
71:bae944334fa4 | 72:b9518feda344 |
---|---|
1 ;;; yow.el --- quote random zippyisms | 1 ;;; yow.el --- quote random zippyisms |
2 | 2 |
3 ;; Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Maintainer: FSF | 5 ;; Maintainer: FSF |
6 ;; Author: Richard Mlynarik | 6 ;; Author: Richard Mlynarik |
7 ;; Keywords: games | 7 ;; Keywords: games |
8 | 8 |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 ;; General Public License for more details. | 19 ;; General Public License for more details. |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the | 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
24 ;; Boston, MA 02111-1307, USA. | |
25 | 24 |
26 ;;; Synched up with: FSF 19.30. | 25 ;;; Synched up with: FSF 19.34. |
27 | 26 |
28 ;;; Commentary: | 27 ;;; Commentary: |
29 | 28 |
30 ;; Important pinheadery for GNU Emacs. | 29 ;; Important pinheadery for GNU Emacs. |
31 ;; | 30 ;; |
36 ;;; Code: | 35 ;;; Code: |
37 | 36 |
38 (require 'cookie1) | 37 (require 'cookie1) |
39 | 38 |
40 (defvar yow-file (concat data-directory "yow.lines") | 39 (defvar yow-file (concat data-directory "yow.lines") |
41 "File containing Pertinent Pinhead Phrases.") | 40 "File containing pertinent Pinhead Phrases.") |
41 | |
42 (defconst yow-load-message "Am I CONSING yet?...") | |
43 (defconst yow-after-load-message "I have SEEN the CONSING!!") | |
42 | 44 |
43 ;;;###autoload | 45 ;;;###autoload |
44 (defun yow (&optional insert) | 46 (defun yow (&optional insert) |
45 "Return or display a random Zippy quotation. With prefix arg, insert it." | 47 "Return or display a random Zippy quotation. With prefix arg, insert it." |
46 (interactive "P") | 48 (interactive "P") |
47 (let ((yow (cookie | 49 (let ((yow (cookie yow-file yow-load-message yow-after-load-message))) |
48 yow-file | |
49 "Am I CONSING yet?..." "I have SEEN the CONSING!!"))) | |
50 (cond (insert | 50 (cond (insert |
51 (insert yow)) | 51 (insert yow)) |
52 ((not (interactive-p)) | 52 ((not (interactive-p)) |
53 yow) | 53 yow) |
54 ((not (string-match "\n" yow)) | 54 ((not (string-match "\n" yow)) |
63 (help-mode))))))) | 63 (help-mode))))))) |
64 | 64 |
65 (defun read-zippyism (prompt &optional require-match) | 65 (defun read-zippyism (prompt &optional require-match) |
66 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT. | 66 "Read a Zippyism from the minibuffer with completion, prompting with PROMPT. |
67 If optional second arg is non-nil, require input to match a completion." | 67 If optional second arg is non-nil, require input to match a completion." |
68 (read-cookie prompt yow-file | 68 (read-cookie prompt yow-file yow-load-message yow-after-load-message |
69 "Am I CONSING yet?..." "I have SEEN the CONSING!!" | |
70 require-match)) | 69 require-match)) |
70 | |
71 ;;;###autoload | 71 ;;;###autoload |
72 (defun insert-zippyism (&optional zippyism) | 72 (defun insert-zippyism (&optional zippyism) |
73 "Prompt with completion for a known Zippy quotation, and insert it at point." | 73 "Prompt with completion for a known Zippy quotation, and insert it at point." |
74 (interactive (list (read-zippyism "Pinhead wisdom: " t))) | 74 (interactive (list (read-zippyism "Pinhead wisdom: " t))) |
75 (insert zippyism)) | 75 (insert zippyism)) |
76 | |
77 ;;;###autoload | |
78 (defun apropos-zippy (regexp) | |
79 "Return a list of all Zippy quotes matching REGEXP. | |
80 If called interactively, display a list of matches." | |
81 (interactive "sApropos Zippy (regexp): ") | |
82 ;; Make sure yows are loaded | |
83 (cookie yow-file yow-load-message yow-after-load-message) | |
84 (let* ((case-fold-search t) | |
85 (cookie-table-symbol (intern yow-file cookie-cache)) | |
86 (string-table (symbol-value cookie-table-symbol)) | |
87 (matches nil) | |
88 (len (length string-table)) | |
89 (i 0)) | |
90 (save-match-data | |
91 (while (< i len) | |
92 (and (string-match regexp (aref string-table i)) | |
93 (setq matches (cons (aref string-table i) matches))) | |
94 (setq i (1+ i)))) | |
95 (and matches | |
96 (setq matches (sort matches 'string-lessp))) | |
97 (and (interactive-p) | |
98 (cond ((null matches) | |
99 (message "No matches found.")) | |
100 (t | |
101 (let ((l matches)) | |
102 (with-output-to-temp-buffer "*Zippy Apropos*" | |
103 (while l | |
104 (princ (car l)) | |
105 (setq l (cdr l)) | |
106 (and l (princ "\n\n")))))))) | |
107 matches)) | |
108 | |
76 | 109 |
77 ; Yowza!! Feed zippy quotes to the doctor. Watch results. | 110 ;; Yowza!! Feed zippy quotes to the doctor. Watch results. |
78 ; fun, fun, fun. Entertainment for hours... | 111 ;; fun, fun, fun. Entertainment for hours... |
79 ; | 112 ;; |
80 ; written by Kayvan Aghaiepour | 113 ;; written by Kayvan Aghaiepour |
81 | 114 |
82 ;;;###autoload | 115 ;;;###autoload |
83 (defun psychoanalyze-pinhead () | 116 (defun psychoanalyze-pinhead () |
84 "Zippy goes to the analyst." | 117 "Zippy goes to the analyst." |
85 (interactive) | 118 (interactive) |
86 (doctor) ; start the psychotherapy | 119 (doctor) ; start the psychotherapy |
87 (message nil) | 120 (message "") |
88 (switch-to-buffer "*doctor*") | 121 (switch-to-buffer "*doctor*") |
89 (sit-for 0) | 122 (sit-for 0) |
90 (while (not (input-pending-p)) | 123 (while (not (input-pending-p)) |
91 (insert (yow)) | 124 (insert-string (yow)) |
92 (sit-for 0) | 125 (sit-for 0) |
93 (doctor-ret-or-read 1) | 126 (doctor-ret-or-read 1) |
94 (doctor-ret-or-read 1))) | 127 (doctor-ret-or-read 1))) |
95 | 128 |
96 (provide 'yow) | 129 (provide 'yow) |