Source

misc-games / rot13.el

Diff from to
 ;;; Code:
 
 (defvar rot13-display-table
-  (let ((table (make-display-table))
-	(i 0))
-    (while (< i 26)
-      (aset table (+ i ?a) (vector (+ (% (+ i 13) 26) ?a)))
-      (aset table (+ i ?A) (vector (+ (% (+ i 13) 26) ?A)))
-      (setq i (1+ i)))
+  (let ((i -1)
+        (a (char-to-int ?a))
+        (A (char-to-int ?A))
+        (table (make-display-table)))
+    (while (< (incf i) 26)
+      (aset table (+ i a) (char-to-string (int-to-char (+ (% (+ i 13) 26) a))))
+      (aset table (+ i A) (char-to-string (int-to-char (+ (% (+ i 13) 26) A)))))
     table)
   "Char table for rot 13 display.")
 
 To terminate the rot13 display, delete that window."
   (interactive)
   (let ((w (display-buffer (current-buffer) t)))
-    (set-window-display-table w rot13-display-table)))
+    (set-specifier current-display-table rot13-display-table w)))
 
 ;;;###autoload
 (defun toggle-rot13-mode ()
   "Toggle the use of rot 13 encoding for the current window."
   (interactive)
-  (if (eq (window-display-table (selected-window)) rot13-display-table)
-      (set-window-display-table (selected-window) nil)
-    (if (null (window-display-table (selected-window)))
-	(set-window-display-table (selected-window) rot13-display-table))))
+  (let ((w (selected-window)))
+    (if (equal (specifier-specs current-display-table w) rot13-display-table)
+        (set-specifier current-display-table nil w)
+      (set-specifier current-display-table rot13-display-table w))))
 
 (provide 'rot13)