Anonymous avatar Anonymous committed 63d6ac0

Created

Comments (0)

Files changed (8)

+1998-01-02  SL Baur  <steve@altair.xemacs.org>
+
+	* yow.el (yow-file): Move yow.lines up a directory.
+
+	* spook.el (spook-phrases-file): Move spook.lines up a directory.
+
+	* Makefile: Update to new package interface.
+
+1997-12-30  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile: Fix typos.
+
+1997-12-28  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile (srckit): Delete target before recreating.
+
+1997-12-24  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile: Created.
+
+# Makefile for Cookies lisp code
+
+# This file is part of XEmacs.
+
+# XEmacs is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+
+# XEmacs is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with XEmacs; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+VERSION = 1.03
+PACKAGE = cookie
+PKG_TYPE = regular
+REQUIRES = xemacs-base
+CATEGORY = games
+
+ELCS = cookie1.elc spook.elc yow.elc
+
+include ../../XEmacs.rules
+
+all:: $(ELCS) auto-autoloads.elc
+
+srckit: srckit-std
+
+binkit: all
+	-rm -rf $(STAGING)/lisp/$(PACKAGE)
+	-mkdir -p $(STAGING)/lisp/$(PACKAGE)
+	-rm -f $(STAGING)/etc/yow.lines $(STAGING)/etc/spook.lines
+	cp -a ChangeLog *.el* $(STAGING)/lisp/$(PACKAGE)
+	cp -a *.lines $(STAGING)/etc
+	(cd $(STAGING); \
+	rm -f $(PACKAGE)-$(VERSION)-pkg.tar*; \
+	tar cf $(PACKAGE)-$(VERSION)-pkg.tar lisp/$(PACKAGE) \
+		etc/spook.lines etc/yow.lines; \
+	gzip -v9 $(PACKAGE)-$(VERSION)-pkg.tar)
+;;; cookie1.el --- retrieve random phrases from fortune cookie files
+
+;; Copyright (C) 1993 Free Software Foundation, Inc.
+
+;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
+;; Maintainer: FSF
+;; Keywords: games
+;; Created: Mon Mar 22 17:06:26 1993
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;;; Synched up with: FSF 19.34.
+
+;;; Commentary:
+
+;; Support for random cookie fetches from phrase files, used for such
+;; critical applications as emulating Zippy the Pinhead and confounding
+;; the NSA Trunk Trawler.
+;;
+;; The two entry points are `cookie' and `cookie-insert'.  The helper
+;; function `shuffle-vector' may be of interest to programmers.
+;;
+;; The code expects phrase files to be in one of two formats:
+;;
+;; * ITS-style LINS format (strings terminated by ASCII 0 characters,
+;; leading whitespace ignored).
+;;
+;; * UNIX fortune file format (quotes terminated by %% on a line by itself).
+;;
+;; Everything up to the first delimiter is treated as a comment.  Other
+;; formats could be supported by adding alternates to the regexp
+;; `cookie-delimiter'.
+;;
+;; This code derives from Steve Strassman's 1987 spook.el package, but
+;; has been generalized so that it supports multiple simultaneous
+;; cookie databases and fortune files.  It is intended to be called
+;; from other packages such as yow.el and spook.el.
+;;
+;; TO DO: teach cookie-snarf to auto-detect ITS PINS or UNIX fortune(6)
+;; format and do the right thing.
+
+;;; Code:
+
+; Randomize the seed in the random number generator.
+(random t)
+
+(defconst cookie-delimiter "\n%%\n\\|\0"
+  "Delimiter used to separate cookie file entries.")
+
+(defvar cookie-cache (make-vector 511 0)
+  "Cache of cookie files that have already been snarfed.")
+
+;;;###autoload
+(defun cookie (phrase-file startmsg endmsg)
+  "Return a random phrase from PHRASE-FILE.  When the phrase file
+is read in, display STARTMSG at beginning of load, ENDMSG at end."
+  (let ((cookie-vector (cookie-snarf phrase-file startmsg endmsg)))
+    (shuffle-vector cookie-vector)
+    (aref cookie-vector 1)))
+
+;;;###autoload
+(defun cookie-insert (phrase-file &optional count startmsg endmsg)
+  "Insert random phrases from PHRASE-FILE; COUNT of them.  When the phrase file
+is read in, display STARTMSG at beginning of load, ENDMSG at end."
+  (let ((cookie-vector (cookie-snarf phrase-file startmsg endmsg)))
+    (shuffle-vector cookie-vector)
+    (let ((start (point)))
+      (insert ?\n)
+      (cookie1 (min (- (length cookie-vector) 1) (or count 1)) cookie-vector)
+      (insert ?\n)
+      (fill-region-as-paragraph start (point) nil))))
+
+(defun cookie1 (arg cookie-vec)
+  "Inserts a cookie phrase ARG times."
+  (cond ((zerop arg) t)
+	(t (insert (aref cookie-vec arg))
+	   (insert " ")
+	   (cookie1 (1- arg) cookie-vec))))
+
+;;;###autoload
+(defun cookie-snarf (phrase-file startmsg endmsg)
+  "Reads in the PHRASE-FILE, returns it as a vector of strings.
+Emit STARTMSG and ENDMSG before and after.  Caches the result; second
+and subsequent calls on the same file won't go to disk."
+  (let ((sym (intern-soft phrase-file cookie-cache)))
+    (and sym (not (equal (symbol-function sym)
+			 (nth 5 (file-attributes phrase-file))))
+	 (yes-or-no-p (concat phrase-file
+			      " has changed.  Read new contents? "))
+	 (setq sym nil))
+    (if sym
+	(symbol-value sym)
+      (setq sym (intern phrase-file cookie-cache))
+      (message "%s" startmsg)
+      (save-excursion
+	(let ((buf (generate-new-buffer "*cookie*"))
+	      (result nil))
+	  (set-buffer buf)
+	  (fset sym (nth 5 (file-attributes phrase-file)))
+	  (insert-file-contents (expand-file-name phrase-file))
+	  (re-search-forward cookie-delimiter)
+	  (while (progn (skip-chars-forward " \t\n\r\f") (not (eobp)))
+	    (let ((beg (point)))
+	      (re-search-forward cookie-delimiter)
+	      ;; XEmacs change
+	      ;; DBC --- here's the change
+	      ;; This used to be (buffer-substring beg (1- (point))),
+	      ;; which only worked if the regexp matched was one
+	      ;; character long
+	      (setq result (cons (buffer-substring beg
+						   (match-beginning 0))
+				 result))))
+	  (kill-buffer buf)
+	  (message "%s" endmsg)
+	  (set sym (apply 'vector result)))))))
+
+(defun read-cookie (prompt phrase-file startmsg endmsg &optional require-match)
+  "Prompt with PROMPT and read with completion among cookies in PHRASE-FILE.
+STARTMSG and ENDMSG are passed along to `cookie-snarf'.
+Optional fifth arg REQUIRE-MATCH non-nil forces a matching cookie."
+  ;; Make sure the cookies are in the cache.
+  (or (intern-soft phrase-file cookie-cache)
+      (cookie-snarf phrase-file startmsg endmsg))
+  (completing-read prompt
+		   (let ((sym (intern phrase-file cookie-cache)))
+		     ;; We cache the alist form of the cookie in a property.
+		     (or (get sym 'completion-alist)
+			 (let* ((alist nil)
+				(vec (cookie-snarf phrase-file
+						   startmsg endmsg))
+				(i (length vec)))
+			   (while (> (setq i (1- i)) 0)
+			     (setq alist (cons (list (aref vec i)) alist)))
+			   (put sym 'completion-alist alist))))
+		   nil require-match nil nil))
+
+; Thanks to Ian G Batten <BattenIG@CS.BHAM.AC.UK>
+; [of the University of Birmingham Computer Science Department]
+; for the iterative version of this shuffle.
+;
+;;;###autoload
+(defun shuffle-vector (vector)
+  "Randomly permute the elements of VECTOR (all permutations equally likely)"
+  (let ((i 0)
+	j
+	temp
+	(len (length vector)))
+    (while (< i len)
+      (setq j (+ i (random (- len i))))
+      (setq temp (aref vector i))
+      (aset vector i (aref vector j))
+      (aset vector j temp)
+      (setq i (1+ i))))
+  vector)
+
+(provide 'cookie1)
+
+;;; cookie1.el ends here
+(cookie
+  (version VERSION
+   description "Spook and Yow (Zippy quotes)."
+   filename FILENAME
+   md5sum MD5SUM
+   size SIZE
+   provides (cookie1 yow)
+   requires (REQUIRES)
+   type regular
+))
+;;; spook.el --- spook phrase utility for overloading the NSA line eater
+
+;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
+
+;; Maintainer: FSF
+;; Keywords: games
+;; Created: May 1987
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the Free
+;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Synched up with: FSF 19.34.
+
+;;; Commentary:
+
+;; Steve Strassmann <straz@media-lab.media.mit.edu> didn't write
+;; this, and even if he did, he really didn't mean for you to use it
+;; in an anarchistic way.
+;;
+;; To use this:
+;;  Just before sending mail, do M-x spook.
+;;  A number of phrases will be inserted into your buffer, to help
+;;  give your message that extra bit of attractiveness for automated
+;;  keyword scanners.
+
+;;; Code:
+
+(require 'cookie1)
+
+; Variables
+(defvar spook-phrases-file (locate-data-file "spook.lines")
+   "Keep your favorite phrases here.")
+
+(defvar spook-phrase-default-count 15
+   "Default number of phrases to insert")
+
+;;;###autoload
+(defun spook ()
+  "Adds that special touch of class to your outgoing mail."
+  (interactive)
+  (cookie-insert spook-phrases-file
+		 spook-phrase-default-count
+		 "Checking authorization..."
+		 "Checking authorization...Approved"))
+
+;;;###autoload
+(defun snarf-spooks ()
+  "Return a vector containing the lines from `spook-phrases-file'."
+  (cookie-snarf spook-phrases-file
+		"Checking authorization..."
+		"Checking authorization...Approved"))
+
+;; Note: the implementation that used to take up most of this file has been
+;; cleaned up, generalized, gratuitously broken by esr, and now resides in
+;; cookie1.el.
+
+;;; spook.el ends here

Binary file added.

+;;; yow.el --- quote random zippyisms
+
+;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+
+;; Maintainer: FSF
+;; Author: Richard Mlynarik
+;; Keywords: games
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the Free
+;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Synched up with: FSF 19.34.
+
+;;; Commentary:
+
+;; Important pinheadery for GNU Emacs.
+;;
+;; See cookie1.el for implementation.  Note --- the `n' argument of yow
+;; from the 18.xx implementation is no longer; we only support *random*
+;; random access now.
+
+;;; Code:
+
+(require 'cookie1)
+
+(defvar yow-file (locate-data-file "yow.lines")
+   "File containing pertinent Pinhead Phrases.")
+
+(defconst yow-load-message "Am I CONSING yet?...")
+(defconst yow-after-load-message "I have SEEN the CONSING!!")
+
+;;;###autoload
+(defun yow (&optional insert)
+  "Return or display a random Zippy quotation.  With prefix arg, insert it."
+  (interactive "P")
+  (let ((yow (cookie yow-file yow-load-message yow-after-load-message)))
+    (cond (insert
+	   (insert yow))
+	  ((not (interactive-p))
+           yow)
+          ((not (string-match "\n" yow))
+	   (delete-windows-on (get-buffer-create "*Help*"))
+	   (message "%s" yow))
+	  (t
+	   (message "Yow!")
+	   (with-output-to-temp-buffer "*Help*"
+	     (princ yow)
+	     (save-excursion
+	       (set-buffer standard-output)
+	       (help-mode)))))))
+
+(defun read-zippyism (prompt &optional require-match)
+  "Read a Zippyism from the minibuffer with completion, prompting with PROMPT.
+If optional second arg is non-nil, require input to match a completion."
+  (read-cookie prompt yow-file yow-load-message yow-after-load-message
+	       require-match))
+
+;;;###autoload
+(defun insert-zippyism (&optional zippyism)
+  "Prompt with completion for a known Zippy quotation, and insert it at point."
+  (interactive (list (read-zippyism "Pinhead wisdom: " t)))
+  (insert zippyism))
+
+;;;###autoload
+(defun apropos-zippy (regexp)
+  "Return a list of all Zippy quotes matching REGEXP.
+If called interactively, display a list of matches."
+  (interactive "sApropos Zippy (regexp): ")
+  ;; Make sure yows are loaded
+  (cookie yow-file yow-load-message yow-after-load-message)
+  (let* ((case-fold-search t)
+	 (cookie-table-symbol (intern yow-file cookie-cache))
+	 (string-table (symbol-value cookie-table-symbol))
+	 (matches nil)
+	 (len (length string-table))
+	 (i 0))
+    (save-match-data
+      (while (< i len)
+	(and (string-match regexp (aref string-table i))
+	     (setq matches (cons (aref string-table i) matches)))
+	(setq i (1+ i))))
+    (and matches
+	 (setq matches (sort matches 'string-lessp)))
+    (and (interactive-p)
+	 (cond ((null matches)
+		(message "No matches found."))
+	       (t
+		(let ((l matches))
+		  (with-output-to-temp-buffer "*Zippy Apropos*"
+		    (while l
+		      (princ (car l))
+		      (setq l (cdr l))
+		      (and l (princ "\n\n"))))))))
+    matches))
+
+
+;; Yowza!! Feed zippy quotes to the doctor. Watch results.
+;; fun, fun, fun. Entertainment for hours...
+;;
+;; written by Kayvan Aghaiepour
+
+;;;###autoload
+(defun psychoanalyze-pinhead ()
+  "Zippy goes to the analyst."
+  (interactive)
+  (doctor)				; start the psychotherapy
+  (message "")
+  (switch-to-buffer "*doctor*")
+  (sit-for 0)
+  (while (not (input-pending-p))
+    (insert-string (yow))
+    (sit-for 0)
+    (doctor-ret-or-read 1)
+    (doctor-ret-or-read 1)))
+
+(provide 'yow)
+
+;;; yow.el ends here

Binary file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.