aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/play
diff options
context:
space:
mode:
authorRichard M. Stallman1996-08-17 03:12:18 +0000
committerRichard M. Stallman1996-08-17 03:12:18 +0000
commit4f2c8fbb604c5de3d9863d549253bb03a64b085e (patch)
treea26bb8f161faee3910a79cc8fa674d9ba5316160 /lisp/play
parentf2b3cdc312e6be03691b7a5940a1125a6fc949bf (diff)
downloademacs-4f2c8fbb604c5de3d9863d549253bb03a64b085e.tar.gz
emacs-4f2c8fbb604c5de3d9863d549253bb03a64b085e.zip
(decipher-get-undo-copy): New function.
(decipher-get-undo): Use it.
Diffstat (limited to 'lisp/play')
-rw-r--r--lisp/play/decipher.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/play/decipher.el b/lisp/play/decipher.el
index 9a1dfae2adc..3e487ff3232 100644
--- a/lisp/play/decipher.el
+++ b/lisp/play/decipher.el
@@ -125,11 +125,13 @@ the tail of the list.")
125 (1 font-lock-keyword-face) 125 (1 font-lock-keyword-face)
126 (2 font-lock-string-face))) 126 (2 font-lock-string-face)))
127 "Expressions to fontify in Decipher mode. 127 "Expressions to fontify in Decipher mode.
128
128Ciphertext uses `font-lock-keyword-face', plaintext uses 129Ciphertext uses `font-lock-keyword-face', plaintext uses
129`font-lock-string-face', comments use `font-lock-comment-face', and 130`font-lock-string-face', comments use `font-lock-comment-face', and
130checkpoints use `font-lock-reference-face'. You can customize the 131checkpoints use `font-lock-reference-face'. You can customize the
131display by changing these variables. For best results, I recommend 132display by changing these variables. For best results, I recommend
132that all faces use the same background color. 133that all faces use the same background color.
134
133For example, to display ciphertext in the `bold' face, use 135For example, to display ciphertext in the `bold' face, use
134 (add-hook 'decipher-mode-hook 136 (add-hook 'decipher-mode-hook
135 (lambda () (set (make-local-variable 'font-lock-keyword-face) 137 (lambda () (set (make-local-variable 'font-lock-keyword-face)
@@ -406,13 +408,17 @@ The most useful commands are:
406 (setcdr (nthcdr (1- new-size) decipher-undo-list) nil) 408 (setcdr (nthcdr (1- new-size) decipher-undo-list) nil)
407 (setq decipher-undo-list-size new-size)))))) 409 (setq decipher-undo-list-size new-size))))))
408 410
411(defun decipher-get-undo-copy (cons)
412 (if cons
413 (cons (car cons) (cdr cons))))
414
409(defun decipher-get-undo (cipher-char plain-char) 415(defun decipher-get-undo (cipher-char plain-char)
410 ;; Return an undo record that will undo the result of 416 ;; Return an undo record that will undo the result of
411 ;; (decipher-set-map CIPHER-CHAR PLAIN-CHAR) 417 ;; (decipher-set-map CIPHER-CHAR PLAIN-CHAR)
412 ;; We must use copy-list because the original cons cells will be 418 ;; We must copy the cons cell because the original cons cells will be
413 ;; modified using setcdr. 419 ;; modified using setcdr.
414 (let ((cipher-map (copy-list (rassoc cipher-char decipher-alphabet))) 420 (let ((cipher-map (decipher-get-undo-copy (rassoc cipher-char decipher-alphabet)))
415 (plain-map (copy-list (assoc plain-char decipher-alphabet)))) 421 (plain-map (decipher-get-undo-copy (assoc plain-char decipher-alphabet))))
416 (cond ((equal ?\ plain-char) 422 (cond ((equal ?\ plain-char)
417 cipher-map) 423 cipher-map)
418 ((equal cipher-char (cdr plain-map)) 424 ((equal cipher-char (cdr plain-map))