diff options
| author | Simon Josefsson | 2002-05-25 22:57:08 +0000 |
|---|---|---|
| committer | Simon Josefsson | 2002-05-25 22:57:08 +0000 |
| commit | 280b8e5990d077b6152965d9f180bdd8ff1c29c0 (patch) | |
| tree | 8d1ef679b388340769c74d12dad9a0e30e76824b | |
| parent | 3ce79cf5550fd9d616039dfe79ad8b07624f9a5a (diff) | |
| download | emacs-280b8e5990d077b6152965d9f180bdd8ff1c29c0.tar.gz emacs-280b8e5990d077b6152965d9f180bdd8ff1c29c0.zip | |
(rot13-translate-table): New variable.
(rot13, rot13-string, rot13-region): New functions.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/rot13.el | 44 |
2 files changed, 47 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 97e775e9867..4972523657a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2002-05-24 Simon Josefsson <jas@extundo.com> | ||
| 2 | |||
| 3 | * rot13.el (rot13-translate-table): New variable. | ||
| 4 | (rot13, rot13-string, rot13-region): New functions. | ||
| 5 | |||
| 1 | 2002-05-25 Martin Stjernholm <bug-cc-mode@gnu.org> | 6 | 2002-05-25 Martin Stjernholm <bug-cc-mode@gnu.org> |
| 2 | 7 | ||
| 3 | * progmodes/cc-engine.el (c-add-stmt-syntax): Fixed some cases | 8 | * progmodes/cc-engine.el (c-add-stmt-syntax): Fixed some cases |
diff --git a/lisp/rot13.el b/lisp/rot13.el index fcb349c03e5..2c82a82c226 100644 --- a/lisp/rot13.el +++ b/lisp/rot13.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; rot13.el --- display a buffer in rot13 | 1 | ;;; rot13.el --- display a buffer in rot13 |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1988 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1988,2002 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Howard Gayle | 5 | ;; Author: Howard Gayle |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;; The single entry point, `rot13-other-window', performs a Caesar cipher | 27 | ;; The entry point, `rot13-other-window', performs a Caesar cipher |
| 28 | ;; encrypt/decrypt on the current buffer and displays the result in another | 28 | ;; encrypt/decrypt on the current buffer and displays the result in another |
| 29 | ;; window. Rot13 encryption is sometimes used on USENET as a read-at-your- | 29 | ;; window. Rot13 encryption is sometimes used on USENET as a read-at-your- |
| 30 | ;; own-risk wrapper for material some might consider offensive, such as | 30 | ;; own-risk wrapper for material some might consider offensive, such as |
| @@ -32,6 +32,10 @@ | |||
| 32 | ;; | 32 | ;; |
| 33 | ;; Written by Howard Gayle. | 33 | ;; Written by Howard Gayle. |
| 34 | ;; This hack is mainly to show off the char table stuff. | 34 | ;; This hack is mainly to show off the char table stuff. |
| 35 | ;; | ||
| 36 | ;; New entry points, `rot13', `rot13-string', and `rot13-region' that | ||
| 37 | ;; performs Ceasar cipher encrypt/decrypt on buffers and strings, was | ||
| 38 | ;; added by Simon Josefsson. | ||
| 35 | 39 | ||
| 36 | ;;; Code: | 40 | ;;; Code: |
| 37 | 41 | ||
| @@ -45,6 +49,42 @@ | |||
| 45 | table) | 49 | table) |
| 46 | "Char table for rot 13 display.") | 50 | "Char table for rot 13 display.") |
| 47 | 51 | ||
| 52 | (defvar rot13-translate-table | ||
| 53 | (let ((str (make-string 127 0)) | ||
| 54 | (i 0)) | ||
| 55 | (while (< i 127) | ||
| 56 | (aset str i i) | ||
| 57 | (setq i (1+ i))) | ||
| 58 | (setq i 0) | ||
| 59 | (while (< i 26) | ||
| 60 | (aset str (+ i ?a) (+ (% (+ i 13) 26) ?a)) | ||
| 61 | (aset str (+ i ?A) (+ (% (+ i 13) 26) ?A)) | ||
| 62 | (setq i (1+ i))) | ||
| 63 | str) | ||
| 64 | "String table for rot 13 translation.") | ||
| 65 | |||
| 66 | ;;;###autoload | ||
| 67 | (defun rot13 (object &optional start end) | ||
| 68 | "Return Rot13 encryption of OBJECT, a buffer or string." | ||
| 69 | (if (bufferp object) | ||
| 70 | (with-current-buffer object | ||
| 71 | (rot13-region start end)) | ||
| 72 | (rot13-string object))) | ||
| 73 | |||
| 74 | ;;;###autoload | ||
| 75 | (defun rot13-string (string) | ||
| 76 | "Return Rot13 encryption of STRING." | ||
| 77 | (with-temp-buffer | ||
| 78 | (insert string) | ||
| 79 | (rot13-region (point-min) (point-max)) | ||
| 80 | (buffer-string))) | ||
| 81 | |||
| 82 | ;;;###autoload | ||
| 83 | (defun rot13-region (start end) | ||
| 84 | "Rot13 encrypt the region between START and END in current buffer." | ||
| 85 | (interactive "r") | ||
| 86 | (translate-region start end rot13-translate-table)) | ||
| 87 | |||
| 48 | ;;;###autoload | 88 | ;;;###autoload |
| 49 | (defun rot13-other-window () | 89 | (defun rot13-other-window () |
| 50 | "Display current buffer in rot 13 in another window. | 90 | "Display current buffer in rot 13 in another window. |