;;; broken-keyboard.el --- break your keyboard with elisp! ;; Copyright (C) 1999 B. W. Fitzpatrick ;; Author: Brian W. Fitzpatrick ;; Maintainer: Brian W. Fitzpatrick ;; Created: April, 1999 ;; Keywords: prank, fun, silly ;; This program 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. ;; This program 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 this program; if not, you can either send email to this ;; program's maintainer or write to: The Free Software Foundation, ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. ;;; Commentary: ;; broken-keyboard.el will bind itself to a key initially, and ;; randomly either double insert that key or pause for a wee bit after ;; the user types it. After broken-keyboard-repeat times, it will ;; unbind itself, return the key to self-insert-command, and choose ;; another key from broken-keys and bind itself to that key. If you ;; fire this up without the debug messages on, you're probably best ;; off to just kill emacs and start over to save yourself ;; for some real fun, load this file more than once. You can have more ;; than one of these critters roaming around your (or someone else's) ;; keyboard. ;; uncomment the (message) expressions to watch it at work. ;; ;; drop this file in someone's load-path, add the following line to ;; their .emacs file and see how long it takes for them to snap their ;; keyboard in half. ;; (load-file "broken-keyboard") should be enough ;; NOTE: Don't act surprised when the person that you pull this trick on ;; finds out that you did it and rips your lungs out with a spork. ;; Whether you crank this up or crank it down, you're in for pain (defvar broken-keyboard-repeat 10) ;; initially, these are unset (defvar broken-keyboard-iteration nil) (defvar broken-keyboard-char nil) ;; add anything you want to this sequence. or better yet, ;; remove all but the most frequently used keys! (defconst broken-keys '[ "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" " " ] "What to break on the keyboard.") (defun broken-keyboard () "Your keyboard is not working properly. Oddly enough, random keys occasionally rrepeaat and then seem to work fine...until another key breaks..." (interactive) (cond ;; If called with ACHAR, then bind ourselves to that char ;; and set our internal counter to zero ((not broken-keyboard-char) ;; gotta start somewhere (setq broken-keyboard-char (nth (random (1- (length broken-keys))) (append broken-keys ()))) (global-set-key broken-keyboard-char 'broken-keyboard) ;;(message "your keyboard is broken") (setq broken-keyboard-iteration 0)) ;; after we have been tapped broken-keyboard-repeat times, we ;; bind ourselves to a new, randomly chosen key. ((> broken-keyboard-iteration broken-keyboard-repeat) (insert broken-keyboard-char) (global-set-key broken-keyboard-char 'self-insert-command) ;; this append kind of yucky. (setq broken-keyboard-char (nth (random (1- (length broken-keys))) (append broken-keys ()))) (global-set-key broken-keyboard-char 'broken-keyboard) (setq broken-keyboard-iteration 0)) ;;(message "changed to: %s" broken-keyboard-char) ;; else, we randomly repeeat ourself ((< broken-keyboard-iteration broken-keyboard-repeat) (setq broken-keyboard-iteration (1+ broken-keyboard-iteration)) (insert broken-keyboard-char) (if (> (random 3) 0) ;; reppeat! (progn ;;(message "inserted: %s, iteration %i" broken-keyboard-char broken-keyboard-iteration) (insert broken-keyboard-char)) ;; or throw off their cadence. (progn ;;(message "paused: %s" broken-keyboard-char) (sleep-for .154)))))) ;; and let the fun begin! (broken-keyboard) (provide 'broken-keyboard)