diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-10-22 16:57:54 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-10-22 16:57:54 +0000 |
commit | 8f21333af182a347d017bc73f362005f9cdc436d (patch) | |
tree | 52c4b0ea628b1f9affc92175f8e334235f4d2199 /lisp/flow-ctrl.el | |
parent | f3b0a4316981e6b1f6c2cec3731a228e10d6ae37 (diff) | |
download | emacs-8f21333af182a347d017bc73f362005f9cdc436d.tar.gz |
(enable-flow-control): Use a char-table.
Diffstat (limited to 'lisp/flow-ctrl.el')
-rw-r--r-- | lisp/flow-ctrl.el | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/lisp/flow-ctrl.el b/lisp/flow-ctrl.el index c853ae3a767..4bad32a0c11 100644 --- a/lisp/flow-ctrl.el +++ b/lisp/flow-ctrl.el @@ -48,6 +48,8 @@ (defvar flow-control-c-q-replacement ?\036 "Character that replaces C-q, when flow control handling is enabled.") +(put 'keyboard-translate-table 'char-table-extra-slots 0) + ;;;###autoload (defun enable-flow-control (&optional argument) "Toggle flow control handling. @@ -64,27 +66,28 @@ With arg, enable flow control mode if arg is positive, otherwise disable." (set-input-mode t nil (nth 2 (current-input-mode))) (if keyboard-translate-table (progn - (aset keyboard-translate-table flow-control-c-s-replacement - flow-control-c-s-replacement) - (aset keyboard-translate-table ?\^s ?\^s) - (aset keyboard-translate-table flow-control-c-q-replacement - flow-control-c-q-replacement) - (aset keyboard-translate-table ?\^q ?\^q)))) + (aset keyboard-translate-table flow-control-c-s-replacement nil) + (aset keyboard-translate-table ?\^s nil) + (aset keyboard-translate-table flow-control-c-q-replacement nil) + (aset keyboard-translate-table ?\^q nil)))) ;; Turn flow control on. ;; Tell emacs to pass C-s and C-q to OS. (set-input-mode nil t (nth 2 (current-input-mode))) ;; Initialize translate table, saving previous mappings, if any. - (let ((the-table (make-string (max 128 (length keyboard-translate-table)) - 0))) - (let ((i 0) - (j (length keyboard-translate-table))) - (while (< i j) - (aset the-table i (elt keyboard-translate-table i)) - (setq i (1+ i))) - (while (< i 128) - (aset the-table i i) - (setq i (1+ i)))) - (setq keyboard-translate-table the-table)) + (cond ((null keyboard-translate-table) + (setq keyboard-translate-table + (make-char-table 'keyboard-translate-table nil))) + ((char-table-p keyboard-translate-table) + (setq keyboard-translate-table + (copy-sequence keyboard-translate-table))) + (t + (let ((the-table (make-char-table 'keyboard-translate-table nil))) + (let ((i 0) + (j (length keyboard-translate-table))) + (while (< i j) + (aset the-table i (elt keyboard-translate-table i)) + (setq i (1+ i)))) + (setq keyboard-translate-table the-table)))) ;; Swap C-s and C-\ (aset keyboard-translate-table flow-control-c-s-replacement ?\^s) (aset keyboard-translate-table ?\^s flow-control-c-s-replacement) |