Commits

Anonymous committed e26029b

Fix rot13.el

Comments (0)

Files changed (2)

+2000-09-18  Glenn Coombs <gcoombs@aslnet.co.uk>
+
+	* rot13.el (rot13-display-table): Use char-to-string, int-to-char instead
+	of vector.
+	(rot13-other-window): Use set-specifier instead of set-window-display-table.
+	(toggle-rot13-mode): Ditto.
+
 1999-03-05  Adrian Aichner  <aichner@ecf.teradyne.com>
 
 	* advocacy.el (xemacs-praise-sound-file): Don't use
 ;;; 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)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.