diff options
| author | Richard M. Stallman | 1995-10-22 16:57:54 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-10-22 16:57:54 +0000 |
| commit | 8f21333af182a347d017bc73f362005f9cdc436d (patch) | |
| tree | 52c4b0ea628b1f9affc92175f8e334235f4d2199 /lisp/flow-ctrl.el | |
| parent | f3b0a4316981e6b1f6c2cec3731a228e10d6ae37 (diff) | |
| download | emacs-8f21333af182a347d017bc73f362005f9cdc436d.tar.gz emacs-8f21333af182a347d017bc73f362005f9cdc436d.zip | |
(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 @@ | |||
| 48 | (defvar flow-control-c-q-replacement ?\036 | 48 | (defvar flow-control-c-q-replacement ?\036 |
| 49 | "Character that replaces C-q, when flow control handling is enabled.") | 49 | "Character that replaces C-q, when flow control handling is enabled.") |
| 50 | 50 | ||
| 51 | (put 'keyboard-translate-table 'char-table-extra-slots 0) | ||
| 52 | |||
| 51 | ;;;###autoload | 53 | ;;;###autoload |
| 52 | (defun enable-flow-control (&optional argument) | 54 | (defun enable-flow-control (&optional argument) |
| 53 | "Toggle flow control handling. | 55 | "Toggle flow control handling. |
| @@ -64,27 +66,28 @@ With arg, enable flow control mode if arg is positive, otherwise disable." | |||
| 64 | (set-input-mode t nil (nth 2 (current-input-mode))) | 66 | (set-input-mode t nil (nth 2 (current-input-mode))) |
| 65 | (if keyboard-translate-table | 67 | (if keyboard-translate-table |
| 66 | (progn | 68 | (progn |
| 67 | (aset keyboard-translate-table flow-control-c-s-replacement | 69 | (aset keyboard-translate-table flow-control-c-s-replacement nil) |
| 68 | flow-control-c-s-replacement) | 70 | (aset keyboard-translate-table ?\^s nil) |
| 69 | (aset keyboard-translate-table ?\^s ?\^s) | 71 | (aset keyboard-translate-table flow-control-c-q-replacement nil) |
| 70 | (aset keyboard-translate-table flow-control-c-q-replacement | 72 | (aset keyboard-translate-table ?\^q nil)))) |
| 71 | flow-control-c-q-replacement) | ||
| 72 | (aset keyboard-translate-table ?\^q ?\^q)))) | ||
| 73 | ;; Turn flow control on. | 73 | ;; Turn flow control on. |
| 74 | ;; Tell emacs to pass C-s and C-q to OS. | 74 | ;; Tell emacs to pass C-s and C-q to OS. |
| 75 | (set-input-mode nil t (nth 2 (current-input-mode))) | 75 | (set-input-mode nil t (nth 2 (current-input-mode))) |
| 76 | ;; Initialize translate table, saving previous mappings, if any. | 76 | ;; Initialize translate table, saving previous mappings, if any. |
| 77 | (let ((the-table (make-string (max 128 (length keyboard-translate-table)) | 77 | (cond ((null keyboard-translate-table) |
| 78 | 0))) | 78 | (setq keyboard-translate-table |
| 79 | (let ((i 0) | 79 | (make-char-table 'keyboard-translate-table nil))) |
| 80 | (j (length keyboard-translate-table))) | 80 | ((char-table-p keyboard-translate-table) |
| 81 | (while (< i j) | 81 | (setq keyboard-translate-table |
| 82 | (aset the-table i (elt keyboard-translate-table i)) | 82 | (copy-sequence keyboard-translate-table))) |
| 83 | (setq i (1+ i))) | 83 | (t |
| 84 | (while (< i 128) | 84 | (let ((the-table (make-char-table 'keyboard-translate-table nil))) |
| 85 | (aset the-table i i) | 85 | (let ((i 0) |
| 86 | (setq i (1+ i)))) | 86 | (j (length keyboard-translate-table))) |
| 87 | (setq keyboard-translate-table the-table)) | 87 | (while (< i j) |
| 88 | (aset the-table i (elt keyboard-translate-table i)) | ||
| 89 | (setq i (1+ i)))) | ||
| 90 | (setq keyboard-translate-table the-table)))) | ||
| 88 | ;; Swap C-s and C-\ | 91 | ;; Swap C-s and C-\ |
| 89 | (aset keyboard-translate-table flow-control-c-s-replacement ?\^s) | 92 | (aset keyboard-translate-table flow-control-c-s-replacement ?\^s) |
| 90 | (aset keyboard-translate-table ?\^s flow-control-c-s-replacement) | 93 | (aset keyboard-translate-table ?\^s flow-control-c-s-replacement) |