Subject: lame filter
From: [email-masked] (Vadim Zaliva)
Date: 08 Jul 1995 12:34:18 GMT
Newsgroups: gnu.emacs.sources

Not |Ong ago in alt.Sources tiNy progRam |aMe.c was pUblished.
Here is mY sourCe. Style maY be not so good, b3cAuse this Is my 
fiRSt attempt in elisp. ;-)

-----------------------------CUT HERE-----------------------------------

;; $Header: /users/lord/lisp/lame.el,v 1.1 1995/07/08 12:19:25 lord Exp $

;;; Commentary:
;;
;; This is lame-region command.
;; The idea of LAME filter are taken from:
;;
;;  ***  Lame Filter               Version 2.8.lame.www
;;  ***  zorgo <[email-masked]>    07/1/95
;;  ***  This code is too lame to be Commercial,
;;  ***  too lame to be Shareware,
;;  ***  too lame to be Public Domain,
;;  ***  too lame to be GNU copylefted, 
;;  ***  it's Lameware!
;;
;;; Author:
;;
;; Vadim Zaliva
;; [email-masked]
;;
;;; Code:

(defvar lame_tbl
  '(
    ( " are"             "R"  2 4 )
    ( "you"              "U"  2 3 )
    ( "O|o"              "()" 6 1 )
    ( "O|o"              "0"  6 1 )
    ( "and"              "&"  2 3 )
    ( "i|I"              "1"  5 1 )
    ( "l"                "|"  3 1 )
    ( "s$"               "zz" 3 1 )
    ( "s "               "zz" 3 1 )
    ( "s\\\t"            "zz" 3 1 )
    ( "s\\\."            "zz" 3 1 )
    ( "s\\,"             "zz" 3 1 )
    ( "s\\-"             "zz" 3 1 )
    ( "s\\:"             "zz" 3 1 )
    ( "s\\;"             "zz" 3 1 )
    ( "E"                "3"  5 1 )
    )
  "lamer filter rules"
  )

;; 1/5 -> toupper

(defun lame-region (from to &optional ARGS) 
  "make lame text fro region"
  (interactive "r")
  (random t)
  (save-excursion
    (goto-char from)
    (while (< (point) to)
      (lamerize-under-cursor lame_tbl)
      )
    ))

(defun lamerize-under-cursor ( rules ) 
  "lamerize expression"
  (if (null rules) ; not found
      (progn 
     (if (lame-rnd 5)
         (upcase-char 1)
       )
     (forward-char 1)
     )
    (if
     (looking-at (car (car rules)))
     (progn
       (forward-char (car (cdr (cdr (cdr (car rules))))))
       (if 
           (lame-rnd (car (cdr (cdr (car rules)))))
           (progn ; replace
          (kill-backward-chars (car (cdr (cdr (cdr (car rules))))))
          (insert (car (cdr (car rules))))
          ))
       )
      (lamerize-under-cursor (cdr rules))
      )
    ))

(defun lame-rnd (limit)
  "Generate t with 1/limit probability"
  (zerop (random limit))
  )

;; this is from unused.el
(defun upcase-char (arg)
  "Uppercasify ARG chars starting from point.  Point doesn't move"
  (interactive "p")
  (save-excursion
    (upcase-region (point) (progn (forward-char arg) (point)))))

(provide 'lame)

-----------------------------AND HERE-----------------------------------

--
;;--------------------------------------+-------------------------------------+
;; Vadim Zaliva                         +   Those who do not understand Unix  +
;; Fido    : 2:463/[email-masked]       +   are condemned to reinvent it,     +
;; Home    : [email-masked]    +   poorly.                           +
;; Office  : [email-masked]         +                   (H. Spencer)      +
;;--------------------------------------+-------------------------------------+