|
|
1.1 ! root 1: ;; Copyright (C) 1985 Free Software Foundation ! 2: ;; Author Richard Mlynarik. ! 3: ! 4: ;; This file is part of GNU Emacs. ! 5: ! 6: ;; GNU Emacs is distributed in the hope that it will be useful, ! 7: ;; but WITHOUT ANY WARRANTY. No author or distributor ! 8: ;; accepts responsibility to anyone for the consequences of using it ! 9: ;; or for whether it serves any particular purpose or works at all, ! 10: ;; unless he says so in writing. Refer to the GNU Emacs General Public ! 11: ;; License for full details. ! 12: ! 13: ;; Everyone is granted permission to copy, modify and redistribute ! 14: ;; GNU Emacs, but only under the conditions described in the ! 15: ;; GNU Emacs General Public License. A copy of this license is ! 16: ;; supposed to have been given to you along with GNU Emacs so you ! 17: ;; can know your rights and responsibilities. It should be in a ! 18: ;; file named COPYING. Among other things, the copyright notice ! 19: ;; and this notice must be preserved on all copies. ! 20: ! 21: ; Randomize the seed in the random number generator. ! 22: (random t) ! 23: ! 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. ! 28: (defun yow (&optional n interactive) ! 29: "Return or display a Zippy quotation" ! 30: (interactive ! 31: (if current-prefix-arg ! 32: (list (prefix-numeric-value current-prefix-arg) t) ! 33: (list nil t))) ! 34: (if (null yow-vector) ! 35: (setq yow-vector (snarf-yows))) ! 36: (let ((yow (aref yow-vector ! 37: (if n ! 38: n ! 39: (% (logand 0777777 (random)) (length yow-vector)))))) ! 40: (cond ((not interactive) ! 41: yow) ! 42: ((not (string-match "\n" yow)) ! 43: (delete-windows-on (get-buffer-create "*Help*")) ! 44: (message yow)) ! 45: (t ! 46: (message "Yow!") ! 47: (with-output-to-temp-buffer "*Help*" ! 48: (princ yow)))))) ! 49: ! 50: (defvar yow-vector nil "Pertinent pinhead statements") ! 51: (defun snarf-yows () ! 52: (message "Am I CONSING yet?...") ! 53: (save-excursion ! 54: (let ((buf (generate-new-buffer " yow")) ! 55: (result '())) ! 56: (set-buffer buf) ! 57: (insert-file-contents (expand-file-name "yow.lines" exec-directory)) ! 58: (goto-char (scan-buffer (point-min) 1 000)) ! 59: (while (not (eobp)) ! 60: (or (setq end (scan-buffer (point) 1 000)) ! 61: (error "Invalid yow.lines file")) ! 62: (if (if (looking-at "[^ \t\n\r\f]") ! 63: (progn (forward-char 1) t) ! 64: (re-search-forward "[^ \t\n\r\f]" end t)) ! 65: (setq result (cons (buffer-substring (1- (point)) (1- end)) ! 66: result))) ! 67: (goto-char end)) ! 68: (kill-buffer buf) ! 69: (message "I have SEEN the CONSING!!" (length result)) ! 70: (apply 'vector (nreverse result))))) ! 71: ! 72: ; Yowza!! Feed zippy quotes to the doctor. Watch results. ! 73: ; fun, fun, fun. Entertainment for hours... ! 74: ; ! 75: ; written by Kayvan Aghaiepour ! 76: ! 77: (defun psychoanalyze-pinhead () ! 78: "Zippy goes to the analyst." ! 79: (interactive) ! 80: (doctor) ; start the psychotherapy ! 81: (if (null yow-vector) ! 82: (setq yow-vector (snarf-yows))) ! 83: (switch-to-buffer "*doctor*") ! 84: (sit-for 0) ! 85: (while t ! 86: (insert-string (yow)) ! 87: (sit-for 0) ! 88: (doctor-ret-or-read 1) ! 89: (doctor-ret-or-read 1))) ! 90:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.