diff options
| author | Richard M. Stallman | 1996-08-21 20:36:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-08-21 20:36:30 +0000 |
| commit | 8bed5e3d10addb9df5abfd6b9195afb36c54c365 (patch) | |
| tree | 901c9ce7fd8d73835e8640d4274c153e21b3b2ea | |
| parent | d7b43eaa00c71f48a19134bf89751820f1ccf17b (diff) | |
| download | emacs-8bed5e3d10addb9df5abfd6b9195afb36c54c365.tar.gz emacs-8bed5e3d10addb9df5abfd6b9195afb36c54c365.zip | |
(keyboard-translate): Use a char-table.
(keyboard-translate-table): Add char-table-extra-slots property.
| -rw-r--r-- | lisp/subr.el | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 102e60eba49..b68876b66da 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -213,22 +213,15 @@ a string or vector of length 1." | |||
| 213 | (setq inserted t))) | 213 | (setq inserted t))) |
| 214 | (setq tail (cdr tail))))) | 214 | (setq tail (cdr tail))))) |
| 215 | 215 | ||
| 216 | (put 'keyboard-translate-table 'char-table-extra-slots 0) | ||
| 217 | |||
| 216 | (defun keyboard-translate (from to) | 218 | (defun keyboard-translate (from to) |
| 217 | "Translate character FROM to TO at a low level. | 219 | "Translate character FROM to TO at a low level. |
| 218 | This function creates a `keyboard-translate-table' if necessary | 220 | This function creates a `keyboard-translate-table' if necessary |
| 219 | and then modifies one entry in it." | 221 | and then modifies one entry in it." |
| 220 | (or (arrayp keyboard-translate-table) | 222 | (or (char-table-p keyboard-translate-table) |
| 221 | (setq keyboard-translate-table "")) | 223 | (setq keyboard-translate-table |
| 222 | (if (or (> from (length keyboard-translate-table)) | 224 | (make-char-table 'keyboard-translate-table nil))) |
| 223 | (> to (length keyboard-translate-table))) | ||
| 224 | (progn | ||
| 225 | (let* ((i (length keyboard-translate-table)) | ||
| 226 | (table (concat keyboard-translate-table | ||
| 227 | (make-string (- 256 i) 0)))) | ||
| 228 | (while (< i 256) | ||
| 229 | (aset table i i) | ||
| 230 | (setq i (1+ i))) | ||
| 231 | (setq keyboard-translate-table table)))) | ||
| 232 | (aset keyboard-translate-table from to)) | 225 | (aset keyboard-translate-table from to)) |
| 233 | 226 | ||
| 234 | 227 | ||