Mercurial > emacs
annotate lisp/play/decipher.el @ 14573:3ae037e10c04
Doc changes.
(decipher-char): Added defvar (and also for following variables).
(decipher--prev-char): Renamed from decipher-prev-char.
(decipher--digram): Renamed from digram.
(decipher--digram-list): Renamed from digram-list.
(decipher--before): Renamed from before-array.
(decipher--after): Renamed from after-array.
(decipher--freqs): Renamed from freq-array.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 16 Feb 1996 00:36:52 +0000 |
parents | bd43252760b4 |
children | afb84c1d7750 |
rev | line source |
---|---|
14523 | 1 ;;; decipher.el --- Cryptanalyze monoalphabetic substitution ciphers |
2 ;; | |
14545
bd43252760b4
Load cl only when compiling.
Richard M. Stallman <rms@gnu.org>
parents:
14523
diff
changeset
|
3 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc. |
14523 | 4 ;; |
5 ;; Author: Christopher J. Madsen <ac608@yfn.ysu.edu> | |
6 ;; Keywords: games | |
7 ;; | |
8 ;; This file is part of GNU Emacs. | |
9 ;; | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 ;; | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 ;; | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Quick Start: | |
25 ;; | |
26 ;; To decipher a message, type or load it into a buffer and type | |
27 ;; `M-x decipher'. This will format the buffer and place it into | |
28 ;; Decipher mode. You can save your work to a file with the normal | |
29 ;; Emacs save commands; when you reload the file it will automatically | |
30 ;; enter Decipher mode. | |
31 ;; | |
32 ;; I'm not going to discuss how to go about breaking a cipher; try | |
33 ;; your local library for a book on cryptanalysis. One book you might | |
34 ;; find is: | |
35 ;; Cryptanalysis: A study of ciphers and their solution | |
36 ;; Helen Fouche Gaines | |
37 ;; ISBN 0-486-20097-3 | |
38 | |
39 ;;; Commentary: | |
40 ;; | |
41 ;; This package is designed to help you crack simple substitution | |
42 ;; ciphers where one letter stands for another. It works for ciphers | |
43 ;; with or without word divisions. (You must set the variable | |
44 ;; decipher-ignore-spaces for ciphers without word divisions.) | |
45 ;; | |
46 ;; First, some quick definitions: | |
47 ;; ciphertext The encrypted message (what you start with) | |
48 ;; plaintext The decrypted message (what you are trying to get) | |
49 ;; | |
50 ;; Decipher mode displays ciphertext in uppercase and plaintext in | |
51 ;; lowercase. You must enter the plaintext in lowercase; uppercase | |
52 ;; letters are interpreted as commands. The ciphertext may be entered | |
53 ;; in mixed case; `M-x decipher' will convert it to uppercase. | |
54 ;; | |
55 ;; Decipher mode depends on special characters in the first column of | |
56 ;; each line. The command `M-x decipher' inserts these characters for | |
57 ;; you. The characters and their meanings are: | |
58 ;; ( The plaintext & ciphertext alphabets on the first line | |
59 ;; ) The ciphertext & plaintext alphabets on the second line | |
60 ;; : A line of ciphertext (with plaintext below) | |
61 ;; > A line of plaintext (with ciphertext above) | |
62 ;; % A comment | |
63 ;; Each line in the buffer MUST begin with one of these characters (or | |
64 ;; be left blank). In addition, comments beginning with `%!' are reserved | |
65 ;; for checkpoints; see decipher-make-checkpoint & decipher-restore-checkpoint | |
66 ;; for more information. | |
67 ;; | |
68 ;; While the cipher message may contain digits or punctuation, Decipher | |
69 ;; mode will ignore these characters. | |
70 ;; | |
71 ;; The buffer is made read-only so it can't be modified by normal | |
72 ;; Emacs commands. | |
73 | |
74 ;;; Things To Do: | |
75 ;; | |
14573 | 76 ;; Email me if you have any suggestions or would like to help. |
77 ;; But be aware that I work on Decipher only sporadically. | |
78 ;; | |
79 ;; 1. The consonant-line shortcut | |
80 ;; 2. More functions for analyzing ciphertext | |
14523 | 81 |
82 ;;;=================================================================== | |
83 ;;; Variables: | |
84 ;;;=================================================================== | |
85 | |
14545
bd43252760b4
Load cl only when compiling.
Richard M. Stallman <rms@gnu.org>
parents:
14523
diff
changeset
|
86 (eval-when-compile |
bd43252760b4
Load cl only when compiling.
Richard M. Stallman <rms@gnu.org>
parents:
14523
diff
changeset
|
87 (require 'cl)) |
14523 | 88 |
89 (defvar decipher-force-uppercase t | |
90 "*Non-nil means to convert ciphertext to uppercase. | |
91 Nil means the case of the ciphertext is preserved. | |
92 This variable must be set before typing `\\[decipher]'.") | |
93 | |
94 (defvar decipher-ignore-spaces nil | |
95 "*Non-nil means to ignore spaces and punctuation when counting digrams. | |
96 You should set this to `nil' if the cipher message is divided into words, | |
97 or `t' if it is not. | |
98 This variable is buffer-local.") | |
99 (make-variable-buffer-local 'decipher-ignore-spaces) | |
100 | |
101 (defvar decipher-undo-limit 5000 | |
102 "The maximum number of entries in the undo list. | |
103 When the undo list exceeds this number, 100 entries are deleted from | |
104 the tail of the list.") | |
105 | |
106 ;; End of user modifiable variables | |
107 ;;-------------------------------------------------------------------- | |
108 | |
109 (defvar decipher-mode-map nil | |
110 "Keymap for Decipher mode.") | |
111 (if (not decipher-mode-map) | |
112 (progn | |
113 (setq decipher-mode-map (make-keymap)) | |
114 (suppress-keymap decipher-mode-map) | |
115 (define-key decipher-mode-map "A" 'decipher-show-alphabet) | |
116 (define-key decipher-mode-map "C" 'decipher-complete-alphabet) | |
117 (define-key decipher-mode-map "D" 'decipher-digram-list) | |
118 (define-key decipher-mode-map "F" 'decipher-frequency-count) | |
119 (define-key decipher-mode-map "M" 'decipher-make-checkpoint) | |
120 (define-key decipher-mode-map "N" 'decipher-adjacency-list) | |
121 (define-key decipher-mode-map "R" 'decipher-restore-checkpoint) | |
122 (define-key decipher-mode-map "U" 'decipher-undo) | |
123 (define-key decipher-mode-map " " 'decipher-keypress) | |
124 (substitute-key-definition 'undo 'decipher-undo | |
125 decipher-mode-map global-map) | |
126 (substitute-key-definition 'advertised-undo 'decipher-undo | |
127 decipher-mode-map global-map) | |
128 (let ((key ?a)) | |
129 (while (<= key ?z) | |
130 (define-key decipher-mode-map (vector key) 'decipher-keypress) | |
131 (incf key))))) | |
132 | |
133 (defvar decipher-stats-mode-map nil | |
134 "Keymap for Decipher-Stats mode.") | |
135 (if (not decipher-stats-mode-map) | |
136 (progn | |
137 (setq decipher-stats-mode-map (make-keymap)) | |
138 (suppress-keymap decipher-stats-mode-map) | |
139 (define-key decipher-stats-mode-map "D" 'decipher-digram-list) | |
140 (define-key decipher-stats-mode-map "F" 'decipher-frequency-count) | |
141 (define-key decipher-stats-mode-map "N" 'decipher-adjacency-list) | |
142 )) | |
143 | |
144 (defvar decipher-mode-syntax-table nil | |
145 "Decipher mode syntax table") | |
146 | |
147 (if decipher-mode-syntax-table | |
148 () | |
149 (let ((table (make-syntax-table)) | |
150 (c ?0)) | |
151 (while (<= c ?9) | |
152 (modify-syntax-entry c "_" table) ;Digits are not part of words | |
153 (incf c)) | |
154 (setq decipher-mode-syntax-table table))) | |
155 | |
156 (defvar decipher-alphabet nil) | |
157 ;; This is an alist containing entries (PLAIN-CHAR . CIPHER-CHAR), | |
158 ;; where PLAIN-CHAR runs from ?a to ?z and CIPHER-CHAR is an uppercase | |
159 ;; letter or space (which means no mapping is known for that letter). | |
160 ;; This *must* contain entries for all lowercase characters. | |
161 (make-variable-buffer-local 'decipher-alphabet) | |
162 | |
163 (defvar decipher-stats-buffer nil | |
164 "The buffer which displays statistics for this ciphertext. | |
165 Do not access this variable directly, use the function | |
166 `decipher-stats-buffer' instead.") | |
167 (make-variable-buffer-local 'decipher-stats-buffer) | |
168 | |
169 (defvar decipher-undo-list-size 0 | |
170 "The number of entries in the undo list.") | |
171 (make-variable-buffer-local 'decipher-undo-list-size) | |
172 | |
173 (defvar decipher-undo-list nil | |
174 "The undo list for this buffer. | |
175 Each element is either a cons cell (PLAIN-CHAR . CIPHER-CHAR) or a | |
176 list of such cons cells.") | |
177 (make-variable-buffer-local 'decipher-undo-list) | |
178 | |
179 (defvar decipher-pending-undo-list nil) | |
180 | |
14573 | 181 ;; The following variables are used by the analysis functions |
182 ;; and are defined here to avoid byte-compiler warnings. | |
183 ;; Don't mess with them unless you know what you're doing. | |
184 (defvar decipher-char nil | |
185 "See the functions decipher-loop-with-breaks and decipher-loop-no-breaks.") | |
186 (defvar decipher--prev-char) | |
187 (defvar decipher--digram) | |
188 (defvar decipher--digram-list) | |
189 (defvar decipher--before) | |
190 (defvar decipher--after) | |
191 (defvar decipher--freqs) | |
192 | |
14523 | 193 ;;;=================================================================== |
194 ;;; Code: | |
195 ;;;=================================================================== | |
196 ;; Main entry points: | |
197 ;;-------------------------------------------------------------------- | |
198 | |
199 ;;;###autoload | |
200 (defun decipher () | |
201 "Format a buffer of ciphertext for cryptanalysis and enter Decipher mode." | |
202 (interactive) | |
203 ;; Make sure the buffer ends in a newline: | |
204 (goto-char (point-max)) | |
205 (or (bolp) | |
206 (insert "\n")) | |
207 ;; See if it's already in decipher format: | |
208 (goto-char (point-min)) | |
209 (if (looking-at "^(abcdefghijklmnopqrstuvwxyz \ | |
210 ABCDEFGHIJKLMNOPQRSTUVWXYZ -\\*-decipher-\\*-\n)") | |
211 (message "Buffer is already formatted, entering Decipher mode...") | |
212 ;; Add the alphabet at the beginning of the file | |
213 (insert "(abcdefghijklmnopqrstuvwxyz \ | |
214 ABCDEFGHIJKLMNOPQRSTUVWXYZ -*-decipher-*-\n)\n\n") | |
215 ;; Add lines for the solution: | |
216 (let (begin) | |
217 (while (not (eobp)) | |
218 (if (looking-at "^%") | |
219 (forward-line) ;Leave comments alone | |
220 (delete-horizontal-space) | |
221 (if (eolp) | |
222 (forward-line) ;Just leave blank lines alone | |
223 (insert ":") ;Mark ciphertext line | |
224 (setq begin (point)) | |
225 (forward-line) | |
226 (if decipher-force-uppercase | |
227 (upcase-region begin (point))) ;Convert ciphertext to uppercase | |
228 (insert ">\n"))))) ;Mark plaintext line | |
229 (delete-blank-lines) ;Remove any blank lines | |
230 (delete-blank-lines)) ; at end of buffer | |
231 (goto-line 4) | |
232 (decipher-mode)) | |
233 | |
234 ;;;###autoload | |
235 (defun decipher-mode () | |
236 "Major mode for decrypting monoalphabetic substitution ciphers. | |
237 Lower-case letters enter plaintext. | |
238 Upper-case letters are commands. | |
239 | |
240 The buffer is made read-only so that normal Emacs commands cannot | |
241 modify it. | |
242 | |
243 The most useful commands are: | |
244 \\<decipher-mode-map> | |
245 \\[decipher-digram-list] Display a list of all digrams & their frequency | |
246 \\[decipher-frequency-count] Display the frequency of each ciphertext letter | |
247 \\[decipher-adjacency-list]\ | |
248 Show adjacency list for current letter (lists letters appearing next to it) | |
249 \\[decipher-make-checkpoint] Save the current cipher alphabet (checkpoint) | |
250 \\[decipher-restore-checkpoint] Restore a saved cipher alphabet (checkpoint)" | |
251 (interactive) | |
252 (kill-all-local-variables) | |
253 (setq buffer-undo-list t ;Disable undo | |
254 indent-tabs-mode nil ;Do not use tab characters | |
255 major-mode 'decipher-mode | |
256 mode-name "Decipher") | |
257 (if decipher-force-uppercase | |
258 (setq case-fold-search nil)) ;Case is significant when searching | |
259 (use-local-map decipher-mode-map) | |
260 (set-syntax-table decipher-mode-syntax-table) | |
261 (decipher-read-alphabet) | |
262 ;; Make the buffer writable when we exit Decipher mode: | |
263 (make-local-hook 'change-major-mode-hook) | |
264 (add-hook 'change-major-mode-hook | |
265 (lambda () (setq buffer-read-only nil | |
266 buffer-undo-list nil)) | |
267 nil t) | |
268 (run-hooks 'decipher-mode-hook) | |
269 (setq buffer-read-only t)) | |
270 (put 'decipher-mode 'mode-class 'special) | |
271 | |
272 ;;-------------------------------------------------------------------- | |
273 ;; Normal key handling: | |
274 ;;-------------------------------------------------------------------- | |
275 | |
276 (defmacro decipher-last-command-char () | |
277 ;; Return the char which ran this command (for compatibility with XEmacs) | |
278 (if (fboundp 'event-to-character) | |
279 '(event-to-character last-command-event) | |
280 'last-command-event)) | |
281 | |
282 (defun decipher-keypress () | |
283 "Enter a plaintext or ciphertext character." | |
284 (interactive) | |
285 (let ((decipher-function 'decipher-set-map) | |
286 buffer-read-only) ;Make buffer writable | |
287 (save-excursion | |
288 (or (save-excursion | |
289 (beginning-of-line) | |
290 (let ((first-char (following-char))) | |
291 (cond | |
292 ((= ?: first-char) | |
293 t) | |
294 ((= ?> first-char) | |
295 nil) | |
296 ((= ?\( first-char) | |
297 (setq decipher-function 'decipher-alphabet-keypress) | |
298 t) | |
299 ((= ?\) first-char) | |
300 (setq decipher-function 'decipher-alphabet-keypress) | |
301 nil) | |
302 (t | |
303 (error "Bad location"))))) | |
304 (let (goal-column) | |
305 (previous-line 1))) | |
306 (let ((char-a (following-char)) | |
307 (char-b (decipher-last-command-char))) | |
308 (or (and (not (= ?w (char-syntax char-a))) | |
309 (= char-b ?\ )) ;Spacebar just advances on non-letters | |
310 (funcall decipher-function char-a char-b))))) | |
311 (forward-char)) | |
312 | |
313 (defun decipher-alphabet-keypress (a b) | |
314 ;; Handle keypresses in the alphabet lines. | |
315 ;; A is the character in the alphabet row (which starts with '(') | |
316 ;; B is the character pressed | |
317 (cond ((and (>= a ?A) (<= a ?Z)) | |
318 ;; If A is uppercase, then it is in the ciphertext alphabet: | |
319 (decipher-set-map a b)) | |
320 ((and (>= a ?a) (<= a ?z)) | |
321 ;; If A is lowercase, then it is in the plaintext alphabet: | |
322 (if (= b ?\ ) | |
323 ;; We are clearing the association (if any): | |
324 (if (/= ?\ (setq b (cdr (assoc a decipher-alphabet)))) | |
325 (decipher-set-map b ?\ )) | |
326 ;; Associate the plaintext char with the char pressed: | |
327 (decipher-set-map b a))) | |
328 (t | |
329 ;; If A is not a letter, that's a problem: | |
330 (error "Bad character")))) | |
331 | |
332 ;;-------------------------------------------------------------------- | |
333 ;; Undo: | |
334 ;;-------------------------------------------------------------------- | |
335 | |
336 (defun decipher-undo () | |
337 "Undo a change in Decipher mode." | |
338 (interactive) | |
339 ;; If we don't get all the way thru, make last-command indicate that | |
340 ;; for the following command. | |
341 (setq this-command t) | |
342 (or (eq major-mode 'decipher-mode) | |
343 (error "This buffer is not in Decipher mode")) | |
344 (or (eq last-command 'decipher-undo) | |
345 (setq decipher-pending-undo-list decipher-undo-list)) | |
346 (or decipher-pending-undo-list | |
347 (error "No further undo information")) | |
348 (let ((undo-rec (pop decipher-pending-undo-list)) | |
349 buffer-read-only ;Make buffer writable | |
350 redo-map redo-rec undo-map) | |
351 (or (consp (car undo-rec)) | |
352 (setq undo-rec (list undo-rec))) | |
353 (while (setq undo-map (pop undo-rec)) | |
354 (setq redo-map (decipher-get-undo (cdr undo-map) (car undo-map))) | |
355 (if redo-map | |
356 (setq redo-rec | |
357 (if (consp (car redo-map)) | |
358 (append redo-map redo-rec) | |
359 (cons redo-map redo-rec)))) | |
360 (decipher-set-map (cdr undo-map) (car undo-map) t)) | |
361 (decipher-add-undo redo-rec)) | |
362 (setq this-command 'decipher-undo) | |
363 (message "Undo!")) | |
364 | |
365 (defun decipher-add-undo (undo-rec) | |
366 "Add UNDO-REC to the undo list." | |
367 (if undo-rec | |
368 (progn | |
369 (push undo-rec decipher-undo-list) | |
370 (incf decipher-undo-list-size) | |
371 (if (> decipher-undo-list-size decipher-undo-limit) | |
372 (let ((new-size (- decipher-undo-limit 100))) | |
373 ;; Truncate undo list to NEW-SIZE elements: | |
374 (setcdr (nthcdr (1- new-size) decipher-undo-list) nil) | |
375 (setq decipher-undo-list-size new-size)))))) | |
376 | |
377 (defun decipher-get-undo (cipher-char plain-char) | |
378 ;; Return an undo record that will undo the result of | |
379 ;; (decipher-set-map CIPHER-CHAR PLAIN-CHAR) | |
380 ;; We must use copy-list because the original cons cells will be | |
381 ;; modified using setcdr. | |
382 (let ((cipher-map (copy-list (rassoc cipher-char decipher-alphabet))) | |
383 (plain-map (copy-list (assoc plain-char decipher-alphabet)))) | |
384 (cond ((equal ?\ plain-char) | |
385 cipher-map) | |
386 ((equal cipher-char (cdr plain-map)) | |
387 nil) ;We aren't changing anything | |
388 ((equal ?\ (cdr plain-map)) | |
389 (or cipher-map (cons ?\ cipher-char))) | |
390 (cipher-map | |
391 (list plain-map cipher-map)) | |
392 (t | |
393 plain-map)))) | |
394 | |
395 ;;-------------------------------------------------------------------- | |
396 ;; Mapping ciphertext and plaintext: | |
397 ;;-------------------------------------------------------------------- | |
398 | |
399 (defun decipher-set-map (cipher-char plain-char &optional no-undo) | |
400 ;; Associate a ciphertext letter with a plaintext letter | |
401 ;; CIPHER-CHAR must be an uppercase or lowercase letter | |
402 ;; PLAIN-CHAR must be a lowercase letter (or a space) | |
403 ;; NO-UNDO if non-nil means do not record undo information | |
404 ;; Any existing associations for CIPHER-CHAR or PLAIN-CHAR will be erased. | |
405 (setq cipher-char (upcase cipher-char)) | |
406 (or (and (>= cipher-char ?A) (<= cipher-char ?Z)) | |
407 (error "Bad character")) ;Cipher char must be uppercase letter | |
408 (or no-undo | |
409 (decipher-add-undo (decipher-get-undo cipher-char plain-char))) | |
410 (let ((cipher-string (char-to-string cipher-char)) | |
411 (plain-string (char-to-string plain-char)) | |
412 case-fold-search ;Case is significant | |
413 mapping bound) | |
414 (save-excursion | |
415 (goto-char (point-min)) | |
416 (if (setq mapping (rassoc cipher-char decipher-alphabet)) | |
417 (progn | |
418 (setcdr mapping ?\ ) | |
419 (search-forward-regexp (concat "^([a-z]*" | |
420 (char-to-string (car mapping)))) | |
421 (decipher-insert ?\ ) | |
422 (beginning-of-line))) | |
423 (if (setq mapping (assoc plain-char decipher-alphabet)) | |
424 (progn | |
425 (if (/= ?\ (cdr mapping)) | |
426 (decipher-set-map (cdr mapping) ?\ t)) | |
427 (setcdr mapping cipher-char) | |
428 (search-forward-regexp (concat "^([a-z]*" plain-string)) | |
429 (decipher-insert cipher-char) | |
430 (beginning-of-line))) | |
431 (search-forward-regexp (concat "^([a-z]+ [A-Z]*" cipher-string)) | |
432 (decipher-insert plain-char) | |
433 (setq case-fold-search t ;Case is not significant | |
434 cipher-string (downcase cipher-string)) | |
435 (while (search-forward-regexp "^:" nil t) | |
436 (setq bound (save-excursion (end-of-line) (point))) | |
437 (while (search-forward cipher-string bound 'end) | |
438 (decipher-insert plain-char)))))) | |
439 | |
440 (defun decipher-insert (char) | |
441 ;; Insert CHAR in the row below point. It replaces any existing | |
442 ;; character in that position. | |
443 (let ((col (1- (current-column)))) | |
444 (save-excursion | |
445 (forward-line) | |
446 (or (= ?\> (following-char)) | |
447 (= ?\) (following-char)) | |
448 (error "Bad location")) | |
449 (move-to-column col t) | |
450 (or (eolp) | |
451 (delete-char 1)) | |
452 (insert char)))) | |
453 | |
454 ;;-------------------------------------------------------------------- | |
455 ;; Checkpoints: | |
456 ;;-------------------------------------------------------------------- | |
457 ;; A checkpoint is a comment of the form: | |
458 ;; %!ABCDEFGHIJKLMNOPQRSTUVWXYZ! Description | |
459 ;; Such comments are usually placed at the end of the buffer following | |
460 ;; this header (which is inserted by decipher-make-checkpoint): | |
461 ;; %--------------------------- | |
462 ;; % Checkpoints: | |
463 ;; % abcdefghijklmnopqrstuvwxyz | |
464 ;; but this is not required; checkpoints can be placed anywhere. | |
465 ;; | |
466 ;; The description is optional; all that is required is the alphabet. | |
467 | |
468 (defun decipher-make-checkpoint (desc) | |
469 "Checkpoint the current cipher alphabet. | |
470 This records the current alphabet so you can return to it later. | |
471 You may have any number of checkpoints. | |
472 Type `\\[decipher-restore-checkpoint]' to restore a checkpoint." | |
473 (interactive "sCheckpoint description: ") | |
474 (or (stringp desc) | |
475 (setq desc "")) | |
476 (let (alphabet | |
477 buffer-read-only ;Make buffer writable | |
478 mapping) | |
479 (goto-char (point-min)) | |
480 (re-search-forward "^)") | |
481 (move-to-column 27 t) | |
482 (setq alphabet (buffer-substring-no-properties (- (point) 26) (point))) | |
483 (if (re-search-forward "^%![A-Z ]+!" nil 'end) | |
484 nil ; Add new checkpoint with others | |
485 (if (re-search-backward "^% *Local Variables:" nil t) | |
486 ;; Add checkpoints before local variables list: | |
487 (progn (forward-line -1) | |
488 (or (looking-at "^ *$") | |
489 (progn (forward-line) (insert ?\n) (forward-line -1))))) | |
490 (insert "\n%" (make-string 69 ?\-) | |
491 "\n% Checkpoints:\n% abcdefghijklmnopqrstuvwxyz\n")) | |
492 (beginning-of-line) | |
493 (insert "%!" alphabet "! " desc ?\n))) | |
494 | |
495 (defun decipher-restore-checkpoint () | |
496 "Restore the cipher alphabet from a checkpoint. | |
497 If point is not on a checkpoint line, moves to the first checkpoint line. | |
498 If point is on a checkpoint, restores that checkpoint. | |
499 | |
500 Type `\\[decipher-make-checkpoint]' to make a checkpoint." | |
501 (interactive) | |
502 (beginning-of-line) | |
503 (if (looking-at "%!\\([A-Z ]+\\)!") | |
504 ;; Restore this checkpoint: | |
505 (let ((alphabet (match-string 1)) | |
506 buffer-read-only) ;Make buffer writable | |
507 (goto-char (point-min)) | |
508 (re-search-forward "^)") | |
509 (or (eolp) | |
510 (delete-region (point) (progn (end-of-line) (point)))) | |
511 (insert alphabet) | |
512 (decipher-resync)) | |
513 ;; Move to the first checkpoint: | |
514 (goto-char (point-min)) | |
515 (if (re-search-forward "^%![A-Z ]+!" nil t) | |
516 (message "Select the checkpoint to restore and type `%s'" | |
517 (substitute-command-keys "\\[decipher-restore-checkpoint]")) | |
518 (error "No checkpoints in this buffer")))) | |
519 | |
520 ;;-------------------------------------------------------------------- | |
521 ;; Miscellaneous commands: | |
522 ;;-------------------------------------------------------------------- | |
523 | |
524 (defun decipher-complete-alphabet () | |
525 "Complete the cipher alphabet. | |
526 This fills any blanks in the cipher alphabet with the unused letters | |
527 in alphabetical order. Use this when you have a keyword cipher and | |
528 you have determined the keyword." | |
529 (interactive) | |
530 (let ((cipher-char ?A) | |
531 (ptr decipher-alphabet) | |
532 buffer-read-only ;Make buffer writable | |
533 plain-map undo-rec) | |
534 (while (setq plain-map (pop ptr)) | |
535 (if (equal ?\ (cdr plain-map)) | |
536 (progn | |
537 (while (rassoc cipher-char decipher-alphabet) | |
538 ;; Find the next unused letter | |
539 (incf cipher-char)) | |
540 (push (cons ?\ cipher-char) undo-rec) | |
541 (decipher-set-map cipher-char (car plain-map) t)))) | |
542 (decipher-add-undo undo-rec))) | |
543 | |
544 (defun decipher-show-alphabet () | |
545 "Display the current cipher alphabet in the message line." | |
546 (interactive) | |
547 (message | |
548 (mapconcat (lambda (a) | |
549 (concat | |
550 (char-to-string (car a)) | |
551 (char-to-string (cdr a)))) | |
552 decipher-alphabet | |
553 ""))) | |
554 | |
555 (defun decipher-resync () | |
556 "Reprocess the buffer using the alphabet from the top. | |
557 This regenerates all deciphered plaintext and clears the undo list. | |
558 You should use this if you edit the ciphertext." | |
559 (interactive) | |
560 (message "Reprocessing buffer...") | |
561 (let (alphabet | |
562 buffer-read-only ;Make buffer writable | |
563 mapping) | |
564 (save-excursion | |
565 (decipher-read-alphabet) | |
566 (setq alphabet decipher-alphabet) | |
567 (goto-char (point-min)) | |
568 (and (re-search-forward "^).+$" nil t) | |
569 (replace-match ")" nil nil)) | |
570 (while (re-search-forward "^>.+$" nil t) | |
571 (replace-match ">" nil nil)) | |
572 (decipher-read-alphabet) | |
573 (while (setq mapping (pop alphabet)) | |
574 (or (equal ?\ (cdr mapping)) | |
575 (decipher-set-map (cdr mapping) (car mapping)))))) | |
576 (setq decipher-undo-list nil | |
577 decipher-undo-list-size 0) | |
578 (message "Reprocessing buffer...done")) | |
579 | |
580 ;;-------------------------------------------------------------------- | |
581 ;; Miscellaneous functions: | |
582 ;;-------------------------------------------------------------------- | |
583 | |
584 (defun decipher-read-alphabet () | |
585 "Build the decipher-alphabet from the alphabet line in the buffer." | |
586 (save-excursion | |
587 (goto-char (point-min)) | |
588 (search-forward-regexp "^)") | |
589 (move-to-column 27 t) | |
590 (setq decipher-alphabet nil) | |
591 (let ((plain-char ?z)) | |
592 (while (>= plain-char ?a) | |
593 (backward-char) | |
594 (push (cons plain-char (following-char)) decipher-alphabet) | |
595 (decf plain-char))))) | |
596 | |
597 ;;;=================================================================== | |
598 ;;; Analyzing ciphertext: | |
599 ;;;=================================================================== | |
600 | |
601 (defun decipher-frequency-count () | |
602 "Display the frequency count in the statistics buffer." | |
603 (interactive) | |
604 (decipher-analyze) | |
605 (decipher-display-regexp "^A" "^[A-Z][A-Z]")) | |
606 | |
607 (defun decipher-digram-list () | |
608 "Display the list of digrams in the statistics buffer." | |
609 (interactive) | |
610 (decipher-analyze) | |
611 (decipher-display-regexp "[A-Z][A-Z] +[0-9]" "^$")) | |
612 | |
613 (defun decipher-adjacency-list (cipher-char) | |
614 "Display the adjacency list for the letter at point. | |
615 The adjacency list shows all letters which come next to CIPHER-CHAR. | |
616 | |
617 An adjacency list (for the letter X) looks like this: | |
618 1 1 1 1 1 3 2 1 3 8 | |
619 X: 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 * 11 14 9% | |
620 1 1 1 2 1 1 2 5 7 | |
621 This says that X comes before D once, and after B once. X begins 5 | |
622 words, and ends 3 words (`*' represents a space). X comes before 8 | |
623 different letters, after 7 differerent letters, and is next to a total | |
624 of 11 different letters. It occurs 14 times, making up 9% of the | |
625 ciphertext." | |
626 (interactive (list (upcase (following-char)))) | |
627 (decipher-analyze) | |
628 (let (start end) | |
629 (save-excursion | |
630 (set-buffer (decipher-stats-buffer)) | |
631 (goto-char (point-min)) | |
632 (or (re-search-forward (format "^%c: " cipher-char) nil t) | |
633 (error "Character `%c' is not used in ciphertext." cipher-char)) | |
634 (forward-line -1) | |
635 (setq start (point)) | |
636 (forward-line 3) | |
637 (setq end (point))) | |
638 (decipher-display-range start end))) | |
639 | |
640 ;;-------------------------------------------------------------------- | |
641 (defun decipher-analyze () | |
642 "Perform frequency analysis on the current buffer if necessary." | |
643 (cond | |
644 ;; If this is the statistics buffer, do nothing: | |
645 ((eq major-mode 'decipher-stats-mode)) | |
646 ;; If this is the Decipher buffer, see if the stats buffer exists: | |
647 ((eq major-mode 'decipher-mode) | |
648 (or (and (bufferp decipher-stats-buffer) | |
649 (buffer-name decipher-stats-buffer)) | |
650 (decipher-analyze-buffer))) | |
651 ;; Otherwise: | |
652 (t (error "This buffer is not in Decipher mode")))) | |
653 | |
654 ;;-------------------------------------------------------------------- | |
655 (defun decipher-display-range (start end) | |
656 "Display text between START and END in the statistics buffer. | |
657 START and END are positions in the statistics buffer. Makes the | |
658 statistics buffer visible and sizes the window to just fit the | |
659 displayed text, but leaves the current window selected." | |
660 (let ((stats-buffer (decipher-stats-buffer)) | |
661 (current-window (selected-window)) | |
662 (pop-up-windows t)) | |
663 (or (eq (current-buffer) stats-buffer) | |
664 (pop-to-buffer stats-buffer)) | |
665 (goto-char start) | |
666 (or (one-window-p t) | |
667 (enlarge-window (- (1+ (count-lines start end)) (window-height)))) | |
668 (recenter 0) | |
669 (select-window current-window))) | |
670 | |
671 (defun decipher-display-regexp (start-regexp end-regexp) | |
672 "Display text between two regexps in the statistics buffer. | |
673 | |
674 START-REGEXP matches the first line to display. | |
675 END-REGEXP matches the line after that which ends the display. | |
676 The ending line is included in the display unless it is blank." | |
677 (let (start end) | |
678 (save-excursion | |
679 (set-buffer (decipher-stats-buffer)) | |
680 (goto-char (point-min)) | |
681 (re-search-forward start-regexp) | |
682 (beginning-of-line) | |
683 (setq start (point)) | |
684 (re-search-forward end-regexp) | |
685 (beginning-of-line) | |
686 (or (looking-at "^ *$") | |
687 (forward-line 1)) | |
688 (setq end (point))) | |
689 (decipher-display-range start end))) | |
690 | |
691 ;;-------------------------------------------------------------------- | |
692 (defun decipher-loop-with-breaks (func) | |
693 "Loop through ciphertext, calling FUNC once for each letter & word division. | |
694 | |
695 FUNC is called with no arguments, and its return value is unimportant. | |
696 It may examine `decipher-char' to see the current ciphertext | |
697 character. `decipher-char' contains either an uppercase letter or a space. | |
698 | |
699 FUNC is called exactly once between words, with `decipher-char' set to | |
700 a space. | |
701 | |
702 See `decipher-loop-no-breaks' if you do not care about word divisions." | |
703 (let ((decipher-char ?\ ) | |
704 (decipher--loop-prev-char ?\ )) | |
705 (save-excursion | |
706 (goto-char (point-min)) | |
707 (funcall func) ;Space marks beginning of first word | |
708 (while (search-forward-regexp "^:" nil t) | |
709 (while (not (eolp)) | |
710 (setq decipher-char (upcase (following-char))) | |
711 (or (and (>= decipher-char ?A) (<= decipher-char ?Z)) | |
712 (setq decipher-char ?\ )) | |
713 (or (and (equal decipher-char ?\ ) | |
714 (equal decipher--loop-prev-char ?\ )) | |
715 (funcall func)) | |
716 (setq decipher--loop-prev-char decipher-char) | |
717 (forward-char)) | |
718 (or (equal decipher-char ?\ ) | |
719 (progn | |
720 (setq decipher-char ?\ ; | |
721 decipher--loop-prev-char ?\ ) | |
722 (funcall func))))))) | |
723 | |
724 (defun decipher-loop-no-breaks (func) | |
725 "Loop through ciphertext, calling FUNC once for each letter. | |
726 | |
727 FUNC is called with no arguments, and its return value is unimportant. | |
728 It may examine `decipher-char' to see the current ciphertext letter. | |
729 `decipher-char' contains an uppercase letter. | |
730 | |
731 Punctuation and spacing in the ciphertext are ignored. | |
732 See `decipher-loop-with-breaks' if you care about word divisions." | |
733 (let (decipher-char) | |
734 (save-excursion | |
735 (goto-char (point-min)) | |
736 (while (search-forward-regexp "^:" nil t) | |
737 (while (not (eolp)) | |
738 (setq decipher-char (upcase (following-char))) | |
739 (and (>= decipher-char ?A) | |
740 (<= decipher-char ?Z) | |
741 (funcall func)) | |
742 (forward-char)))))) | |
743 | |
744 ;;-------------------------------------------------------------------- | |
745 ;; Perform the analysis: | |
746 ;;-------------------------------------------------------------------- | |
747 | |
748 (defun decipher-insert-frequency-counts (freq-list total) | |
749 "Insert frequency counts in current buffer. | |
750 Each element of FREQ-LIST is a list (LETTER FREQ ...). | |
751 TOTAL is the total number of letters in the ciphertext." | |
752 (let ((i 4) temp-list) | |
753 (while (> i 0) | |
754 (setq temp-list freq-list) | |
755 (while temp-list | |
756 (insert (caar temp-list) | |
757 (format "%4d%3d%% " | |
758 (cadar temp-list) | |
759 (/ (* 100 (cadar temp-list)) total))) | |
760 (setq temp-list (nthcdr 4 temp-list))) | |
761 (insert ?\n) | |
762 (setq freq-list (cdr freq-list) | |
763 i (1- i))))) | |
764 | |
765 (defun decipher--analyze () | |
766 ;; Perform frequency analysis on ciphertext. | |
767 ;; | |
768 ;; This function is called repeatedly with decipher-char set to each | |
14573 | 769 ;; character of ciphertext. It uses decipher--prev-char to remember |
14523 | 770 ;; the previous ciphertext character. |
771 ;; | |
772 ;; It builds several data structures, which must be initialized | |
773 ;; before the first call to decipher--analyze. The arrays are | |
774 ;; indexed with A = 0, B = 1, ..., Z = 25, SPC = 26 (if used). | |
14573 | 775 ;; decipher--after: (initialize to zeros) |
14523 | 776 ;; A vector of 26 vectors of 27 integers. The first vector |
777 ;; represents the number of times A follows each character, the | |
778 ;; second vector represents B, and so on. | |
14573 | 779 ;; decipher--before: (initialize to zeros) |
780 ;; The same as decipher--after, but representing the number of | |
781 ;; times the character precedes each other character. | |
782 ;; decipher--digram-list: (initialize to nil) | |
14523 | 783 ;; An alist with an entry for each digram (2-character sequence) |
784 ;; encountered. Each element is a cons cell (DIGRAM . FREQ), | |
785 ;; where DIGRAM is a 2 character string and FREQ is the number | |
786 ;; of times it occurs. | |
14573 | 787 ;; decipher--freqs: (initialize to zeros) |
14523 | 788 ;; A vector of 26 integers, counting the number of occurrences |
789 ;; of the corresponding characters. | |
14573 | 790 (setq decipher--digram (format "%c%c" decipher--prev-char decipher-char)) |
791 (incf (cdr (or (assoc decipher--digram decipher--digram-list) | |
792 (car (push (cons decipher--digram 0) | |
793 decipher--digram-list))))) | |
794 (and (>= decipher--prev-char ?A) | |
795 (incf (aref (aref decipher--before (- decipher--prev-char ?A)) | |
14523 | 796 (if (equal decipher-char ?\ ) |
797 26 | |
798 (- decipher-char ?A))))) | |
799 (and (>= decipher-char ?A) | |
14573 | 800 (incf (aref decipher--freqs (- decipher-char ?A))) |
801 (incf (aref (aref decipher--after (- decipher-char ?A)) | |
802 (if (equal decipher--prev-char ?\ ) | |
14523 | 803 26 |
14573 | 804 (- decipher--prev-char ?A))))) |
805 (setq decipher--prev-char decipher-char)) | |
14523 | 806 |
807 (defun decipher--digram-counts (counts) | |
808 "Generate the counts for an adjacency list." | |
809 (let ((total 0)) | |
810 (concat | |
811 (mapconcat (lambda (x) | |
812 (cond ((> x 99) (incf total) "XX") | |
813 ((> x 0) (incf total) (format "%2d" x)) | |
814 (t " "))) | |
815 counts | |
816 "") | |
817 (format "%4d" (if (> (aref counts 26) 0) | |
818 (1- total) ;Don't count space | |
819 total))))) | |
820 | |
821 (defun decipher--digram-total (before-count after-count) | |
822 "Count the number of different letters a letter appears next to." | |
823 ;; We do not include spaces (word divisions) in this count. | |
824 (let ((total 0) | |
825 (i 26)) | |
826 (while (>= (decf i) 0) | |
827 (if (or (> (aref before-count i) 0) | |
828 (> (aref after-count i) 0)) | |
829 (incf total))) | |
830 total)) | |
831 | |
832 (defun decipher-analyze-buffer () | |
833 "Perform frequency analysis and store results in statistics buffer. | |
834 Creates the statistics buffer if it doesn't exist." | |
14573 | 835 (let ((decipher--prev-char (if decipher-ignore-spaces ?\ ?\*)) |
836 (decipher--before (make-vector 26 nil)) | |
837 (decipher--after (make-vector 26 nil)) | |
838 (decipher--freqs (make-vector 26 0)) | |
14523 | 839 (total-chars 0) |
14573 | 840 decipher--digram decipher--digram-list freq-list) |
14523 | 841 (message "Scanning buffer...") |
842 (let ((i 26)) | |
843 (while (>= (decf i) 0) | |
14573 | 844 (aset decipher--before i (make-vector 27 0)) |
845 (aset decipher--after i (make-vector 27 0)))) | |
14523 | 846 (if decipher-ignore-spaces |
847 (progn | |
848 (decipher-loop-no-breaks 'decipher--analyze) | |
849 ;; The first character of ciphertext was marked as following a space: | |
850 (let ((i 26)) | |
851 (while (>= (decf i) 0) | |
14573 | 852 (aset (aref decipher--after i) 26 0)))) |
14523 | 853 (decipher-loop-with-breaks 'decipher--analyze)) |
854 (message "Processing results...") | |
14573 | 855 (setcdr (last decipher--digram-list 2) nil) ;Delete the phony "* " digram |
14523 | 856 ;; Sort the digram list by frequency and alphabetical order: |
14573 | 857 (setq decipher--digram-list (sort (sort decipher--digram-list |
14523 | 858 (lambda (a b) (string< (car a) (car b)))) |
859 (lambda (a b) (> (cdr a) (cdr b))))) | |
860 ;; Generate the frequency list: | |
861 ;; Each element is a list of 3 elements (LETTER FREQ DIFFERENT), | |
862 ;; where LETTER is the ciphertext character, FREQ is the number | |
863 ;; of times it occurs, and DIFFERENT is the number of different | |
864 ;; letters it appears next to. | |
865 (let ((i 26)) | |
866 (while (>= (decf i) 0) | |
867 (setq freq-list | |
868 (cons (list (+ i ?A) | |
14573 | 869 (aref decipher--freqs i) |
870 (decipher--digram-total (aref decipher--before i) | |
871 (aref decipher--after i))) | |
14523 | 872 freq-list) |
14573 | 873 total-chars (+ total-chars (aref decipher--freqs i))))) |
14523 | 874 (save-excursion |
875 ;; Switch to statistics buffer, creating it if necessary: | |
876 (set-buffer (decipher-stats-buffer t)) | |
877 ;; This can't happen, but it never hurts to double-check: | |
878 (or (eq major-mode 'decipher-stats-mode) | |
879 (error "Buffer %s is not in Decipher-Stats mode" (buffer-name))) | |
880 (setq buffer-read-only nil) | |
881 (erase-buffer) | |
882 ;; Display frequency counts for letters A-Z: | |
883 (decipher-insert-frequency-counts freq-list total-chars) | |
884 (insert ?\n) | |
885 ;; Display frequency counts for letters in order of frequency: | |
886 (setq freq-list (sort freq-list | |
887 (lambda (a b) (> (second a) (second b))))) | |
888 (decipher-insert-frequency-counts freq-list total-chars) | |
889 ;; Display letters in order of frequency: | |
890 (insert ?\n (mapconcat (lambda (a) (char-to-string (car a))) | |
891 freq-list nil) | |
892 "\n\n") | |
893 ;; Display list of digrams in order of frequency: | |
14573 | 894 (let* ((rows (floor (+ (length decipher--digram-list) 9) 10)) |
14523 | 895 (i rows) |
896 temp-list) | |
897 (while (> i 0) | |
14573 | 898 (setq temp-list decipher--digram-list) |
14523 | 899 (while temp-list |
900 (insert (caar temp-list) | |
901 (format "%3d " | |
902 (cdar temp-list))) | |
903 (setq temp-list (nthcdr rows temp-list))) | |
904 (delete-horizontal-space) | |
905 (insert ?\n) | |
14573 | 906 (setq decipher--digram-list (cdr decipher--digram-list) |
14523 | 907 i (1- i)))) |
908 ;; Display adjacency list for each letter, sorted in descending | |
909 ;; order of the number of adjacent letters: | |
910 (setq freq-list (sort freq-list | |
911 (lambda (a b) (> (third a) (third b))))) | |
912 (let ((temp-list freq-list) | |
913 entry i) | |
914 (while (setq entry (pop temp-list)) | |
915 (if (equal 0 (second entry)) | |
916 nil ;This letter was not used | |
917 (setq i (- (car entry) ?A)) | |
918 (insert ?\n " " | |
14573 | 919 (decipher--digram-counts (aref decipher--before i)) ?\n |
14523 | 920 (car entry) |
921 ": 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 *" | |
922 (format "%4d %4d %3d%%\n " | |
923 (third entry) (second entry) | |
924 (/ (* 100 (second entry)) total-chars)) | |
14573 | 925 (decipher--digram-counts (aref decipher--after i)) ?\n)))) |
14523 | 926 (setq buffer-read-only t) |
927 (set-buffer-modified-p nil) | |
928 )) | |
929 (message nil)) | |
930 | |
931 ;;==================================================================== | |
932 ;; Statistics Buffer: | |
933 ;;==================================================================== | |
934 | |
935 (defun decipher-stats-mode () | |
936 "Major mode for displaying ciphertext statistics." | |
937 (interactive) | |
938 (kill-all-local-variables) | |
939 (setq buffer-read-only t | |
940 buffer-undo-list t ;Disable undo | |
941 case-fold-search nil ;Case is significant when searching | |
942 indent-tabs-mode nil ;Do not use tab characters | |
943 major-mode 'decipher-stats-mode | |
944 mode-name "Decipher-Stats") | |
945 (use-local-map decipher-stats-mode-map) | |
946 (run-hooks 'decipher-stats-mode-hook)) | |
947 (put 'decipher-stats-mode 'mode-class 'special) | |
948 | |
949 ;;-------------------------------------------------------------------- | |
950 | |
951 (defun decipher-display-stats-buffer () | |
952 "Make the statistics buffer visible, but do not select it." | |
953 (let ((stats-buffer (decipher-stats-buffer)) | |
954 (current-window (selected-window))) | |
955 (or (eq (current-buffer) stats-buffer) | |
956 (progn | |
957 (pop-to-buffer stats-buffer) | |
958 (select-window current-window))))) | |
959 | |
960 (defun decipher-stats-buffer (&optional create) | |
961 "Return the buffer used for decipher statistics. | |
962 If CREATE is non-nil, create the buffer if it doesn't exist. | |
963 This is guaranteed to return a buffer in Decipher-Stats mode; | |
964 if it can't, it signals an error." | |
965 (cond | |
966 ;; We may already be in the statistics buffer: | |
967 ((eq major-mode 'decipher-stats-mode) | |
968 (current-buffer)) | |
969 ;; See if decipher-stats-buffer exists: | |
970 ((and (bufferp decipher-stats-buffer) | |
971 (buffer-name decipher-stats-buffer)) | |
972 (or (save-excursion | |
973 (set-buffer decipher-stats-buffer) | |
974 (eq major-mode 'decipher-stats-mode)) | |
975 (error "Buffer %s is not in Decipher-Stats mode" | |
976 (buffer-name decipher-stats-buffer))) | |
977 decipher-stats-buffer) | |
978 ;; Create a new buffer if requested: | |
979 (create | |
980 (let ((stats-name (concat "*" (buffer-name) "*"))) | |
981 (setq decipher-stats-buffer | |
982 (if (eq 'decipher-stats-mode | |
983 (cdr-safe (assoc 'major-mode | |
984 (buffer-local-variables | |
985 (get-buffer stats-name))))) | |
986 ;; We just lost track of the statistics buffer: | |
987 (get-buffer stats-name) | |
988 (generate-new-buffer stats-name)))) | |
989 (save-excursion | |
990 (set-buffer decipher-stats-buffer) | |
991 (decipher-stats-mode)) | |
992 decipher-stats-buffer) | |
993 ;; Give up: | |
994 (t (error "No statistics buffer")))) | |
995 | |
996 ;;==================================================================== | |
997 | |
998 (provide 'decipher) | |
999 | |
1000 ;;;(defun decipher-show-undo-list () | |
1001 ;;; "Display the undo list (for debugging purposes)." | |
1002 ;;; (interactive) | |
1003 ;;; (with-output-to-temp-buffer "*Decipher Undo*" | |
1004 ;;; (let ((undo-list decipher-undo-list) | |
1005 ;;; undo-rec undo-map) | |
1006 ;;; (save-excursion | |
1007 ;;; (set-buffer "*Decipher Undo*") | |
1008 ;;; (while (setq undo-rec (pop undo-list)) | |
1009 ;;; (or (consp (car undo-rec)) | |
1010 ;;; (setq undo-rec (list undo-rec))) | |
1011 ;;; (insert ?\() | |
1012 ;;; (while (setq undo-map (pop undo-rec)) | |
1013 ;;; (insert (cdr undo-map) (car undo-map) ?\ )) | |
1014 ;;; (delete-backward-char 1) | |
1015 ;;; (insert ")\n")))))) | |
1016 | |
1017 ;;; decipher.el ends here |