home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.editors
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis
- From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
- Subject: rot13.sl for JED
- Message-ID: <DAVIS.92Nov21165702@pacific.mps.ohio-state.edu>
- Sender: news@pacific.mps.ohio-state.edu
- Nntp-Posting-Host: pacific.mps.ohio-state.edu
- Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis)
- Organization: "Dept. of Physics, The Ohio State University"
- Date: Sat, 21 Nov 1992 21:57:02 GMT
- Lines: 103
-
- Hi,
-
- Here is a rot13.sl file for encrypting/decrypting text via rotating chars
- a-z by 13. To use it, cut it out, call it rot13.sl and put it in JED_LIBRARY.
- Then put the following line in your .jedrc or site.sl:
-
- "rot13.sl" evalfile
-
- Then in JED set the mark and move the Point to define a region. Then enter
- ^[X (escape X) or whatever you have `evaluate_cmd' bound to and type: rot13
- at the JED> prompt, i.e.,
-
- Escape-X
-
- JED> rot13
-
- Or, instead of always loading it, even when you do not need it, simply do:
-
- Escape-X
-
- JED> "rot13.sl" evalfile rot13
-
- This loads it then evaluates the function which rotates the region.
-
- In a later release of JED, I will add autoloading so that something like:
-
- "rot13" "rot13.sl" autoload
-
- but that is later.
-
- Here is the file. Enjoy.
-
- ;;
- ;; rot13.sl
- ;;
- ( [ch delta] =ch
- 0 =delta
- ;; M is 77
- ;; A is 65, Z is 90
-
- ch 90 > { 32 =delta ch 32 - =ch} if
-
- {ch 65 <}{ch 90 >} orelse {1 right pop return} if
-
-
- ch 77 > {ch 13 - =ch}{ ch 13 + =ch} else
- del
- ch delta + char insert
- ) do_rot13
-
- (
- [n r1 c1 c2]
- markp { "Set mark!" error } !if
-
- push_spot
-
- what_column =c2
- whatline "exchange" call whatline =r1
- r1 - =n ;number of lines - 1
- what_column =c1
-
- {n 0 ==} {c1 c2 ==} andelse {"bad region!" error} if
-
- n 0 < { n chs =n
- r1 n - =r1
- c1 c2 =c1 =c2
- } if
-
- n 0 == { c1 c2 > { c1 c2 =c1 =c2 "hmm" message } if } if
-
- r1 goto_line c1 goto_column
-
- n {
- eolp 0 ==
- { pop
- what_char do_rot13
- eolp {0}{1} else
- } while
- 1 down pop bol
- } loop
-
- ;; take care of final line
-
- what_column c2 <
- { pop
- what_char do_rot13
- what_column c2 <
- } while
-
- pop_spot
- ) rot13
-
-
-
-
- --
- _____________
- #___/John E. Davis\_________________________________________________________
- #
- # internet: davis@amy.tch.harvard.edu
- # bitnet: davis@ohstpy
- # office: 617-735-6746
- #
-