aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-01-08 13:18:18 +0000
committerGerd Moellmann2001-01-08 13:18:18 +0000
commit90b6fe58c8a9a44f2d0dd09262875af901500312 (patch)
tree943fdc8577276322135fca8e41a00c9e2c068cf1
parent4f6e79152bb575013e4858e7d622fd50bbc08205 (diff)
downloademacs-90b6fe58c8a9a44f2d0dd09262875af901500312.tar.gz
emacs-90b6fe58c8a9a44f2d0dd09262875af901500312.zip
Update to version 4.0. Provide support
for detecting a keypress that generates an ASCII key sequence. (Previously, only a keypress that generates a vector was recognized.) Embed Window Manager name into name of the generated EDT Emulation initialization file since the initialization file is Window Manager specific. Add Commentary section to file header.
-rw-r--r--lisp/emulation/edt-mapper.el323
1 files changed, 221 insertions, 102 deletions
diff --git a/lisp/emulation/edt-mapper.el b/lisp/emulation/edt-mapper.el
index d07cc5c1729..9b60f9f1fd0 100644
--- a/lisp/emulation/edt-mapper.el
+++ b/lisp/emulation/edt-mapper.el
@@ -1,6 +1,6 @@
1;;; edt-mapper.el --- Create an EDT LK-201 Map File for X-Windows Emacs 1;;; edt-mapper.el --- Create an EDT LK-201 Map File for X-Windows Emacs
2 2
3;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
4 4
5;; Author: Kevin Gallagher <kevingal@onramp.net> 5;; Author: Kevin Gallagher <kevingal@onramp.net>
6;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 6;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
@@ -24,59 +24,90 @@
24;; Boston, MA 02111-1307, USA. 24;; Boston, MA 02111-1307, USA.
25 25
26;;; Commentary: 26;;; Commentary:
27;;
27 28
28;; This emacs lisp program can be used to create an emacs lisp file 29;; [Part of the GNU Emacs EDT Emulation.]
29;; that defines the mapping of the user's keyboard under X-Windows to
30;; the LK-201 keyboard function keys and keypad keys (around which
31;; EDT has been designed). Please read the "Usage" AND "Known
32;; Problems" sections before attempting to run this program. (The
33;; design of this file, edt-mapper.el, was heavily influenced by
34;; tpu-mapper.el.)
35
36;;; Usage:
37 30
38;; Simply load this file into the X-Windows version of emacs (version 19) 31;; This emacs lisp program can be used to create an emacs lisp file
32;; that defines the mapping of the user's keyboard to the LK-201
33;; keyboard function keys and keypad keys (around which EDT has been
34;; designed). Please read the "Usage" AND "Known Problems" sections
35;; below before attempting to run this program. (The design of this
36;; file, edt-mapper.el, was heavily influenced by tpu-mapper.el.)
37
38;; Version 4.0 contains the following enhancements:
39
40;; 1. If you access a workstation using an X Server, note that the
41;; initialization file generated by edt-mapper.el will now
42;; contain the name of the X Server vendor. This is a
43;; convenience for those who have access to their Unix account
44;; from more than one type of X Server. Since different X
45;; Servers typically require different EDT emulation
46;; initialization files, edt-mapper.el will now generate these
47;; different initialization files and save them with different
48;; names.
49
50;; 2. Also, edt-mapper.el is now capable of binding an ASCII key
51;; sequence, providing the ASCII key sequence prefix is already
52;; known by Emacs to be a prefix. As a result, some
53;; terminal/keyboard/window system configurations, which don't
54;; have a complete set of sensible function key map bindings, can
55;; still be configured for EDT Emulation.
56
57
58;; Usage:
59
60;; Simply load this file into emacs (version 19 or higher)
39;; using the following command. 61;; using the following command.
40 62
41;; emacs -q -l edt-mapper.el 63;; emacs -q -l edt-mapper.el
42 64
43;; The "-q" option prevents loading of your .emacs file (commands therein 65;; The "-q" option prevents loading of your .emacs file (commands
44;; might confuse this program). 66;; therein might confuse this program).
45 67
46;; An instruction screen showing the typical LK-201 terminal functions keys 68;; An instruction screen showing the typical LK-201 terminal
47;; will be displayed, and you will be prompted to press the keys on your 69;; functions keys will be displayed, and you will be prompted to
48;; keyboard which you want to emulate the corresponding LK-201 keys. 70;; press the keys on your keyboard which you want to emulate the
71;; corresponding LK-201 keys.
49 72
50;; Finally, you will be prompted for the name of the file to store 73;; Finally, you will be prompted for the name of the file to store
51;; the key definitions. If you chose the default, it will be found 74;; the key definitions. If you chose the default, it will be found
52;; and loaded automatically when the EDT emulation is started. If 75;; and loaded automatically when the EDT emulation is started. If
53;; you specify a different file name, you will need to set the 76;; you specify a different file name, you will need to set the
54;; variable "edt-xkeys-file" before starting the EDT emulation. 77;; variable "edt-keys-file" before starting the EDT emulation.
55;; Here's how you might go about doing that in your .emacs file. 78;; Here's how you might go about doing that in your .emacs file.
56 79
57;; (setq edt-xkeys-file (expand-file-name "~/.my-emacs-x-keys")) 80;; (setq edt-keys-file (expand-file-name "~/.my-emacs-keys"))
81
82
83;; Known Problems:
84
85;; Sometimes, edt-mapper will ignore a key you press, and just
86;; continue to prompt for the same key. This can happen when your
87;; window manager sucks up the key and doesn't pass it on to emacs,
88;; or it could be an emacs bug. Either way, there's nothing that
89;; edt-mapper can do about it. You must press RETURN, to skip the
90;; current key and continue. Later, you and/or your local Emacs guru
91;; can try to figure out why the key is being ignored.
58 92
59;;; Known Problems: 93;;; History:
94;;
60 95
61;; Sometimes, edt-mapper will ignore a key you press, and just continue to 96;; Version 4.0 2000 Added 2 New Features
62;; prompt for the same key. This can happen when your window manager sucks
63;; up the key and doesn't pass it on to emacs, or it could be an emacs bug.
64;; Either way, there's nothing that edt-mapper can do about it. You must
65;; press RETURN, to skip the current key and continue. Later, you and/or
66;; your local X guru can try to figure out why the key is being ignored.
67 97
68;; ==================================================================== 98;;; Code:
69 99
70;;; 100;;;
71;;; Make sure we're running X-windows and Emacs version 19 101;;; Make sure we're running Emacs version 19, or higher.
72;;; 102;;;
103
73(cond 104(cond
74 ((not (and window-system (not (string-lessp emacs-version "19")))) 105 ((string-lessp emacs-version "19")
75 (insert " 106 (insert "
76 107
77 Whoa! This isn't going to work... 108 Whoa! This isn't going to work...
78 109
79 You must run edt-mapper.el under X-windows and Emacs version 19. 110 You must run edt-mapper.el under Emacs version 19 or higher.
80 111
81 Press any key to exit. ") 112 Press any key to exit. ")
82 (sit-for 600) 113 (sit-for 600)
@@ -84,10 +115,24 @@
84 115
85 116
86;;; 117;;;
87;;; Decide whether we're running GNU or Lucid emacs. 118;;; Decide Emacs Variant, GNU Emacs or XEmacs (aka Lucid Emacs).
119;;; Determine Window System, and X Server Vendor (if appropriate).
88;;; 120;;;
89(defconst edt-lucid-emacs19-p (string-match "Lucid" emacs-version) 121(defconst edt-x-emacs-p (string-match "XEmacs" emacs-version)
90 "Non-NIL if we are running Lucid Emacs version 19.") 122 "Non-NIL if we are running XEmacs version 19, or higher.")
123
124(defconst edt-emacs-variant (if edt-x-emacs-p "xemacs" "gnu")
125 "Indicates Emacs variant: GNU Emacs or XEmacs \(aka Lucid Emacs\).")
126
127(defconst edt-window-system (if edt-x-emacs-p (console-type) window-system)
128 "Indicates window system \(in GNU Emacs\) or console type \(in XEmacs\).")
129
130(defconst edt-xserver (if (eq edt-window-system 'x)
131 (if edt-x-emacs-p
132 (replace-in-string (x-server-vendor) "[ _]" "-")
133 (subst-char-in-string ? ?- (x-server-vendor)))
134 nil)
135 "Indicates X server vendor name, if applicable.")
91 136
92 137
93;;; 138;;;
@@ -99,14 +144,23 @@
99(defvar edt-key-seq nil) 144(defvar edt-key-seq nil)
100(defvar edt-enter-seq nil) 145(defvar edt-enter-seq nil)
101(defvar edt-return-seq nil) 146(defvar edt-return-seq nil)
147(defvar edt-term nil)
102 148
103 149;;;
150;;; Determine Terminal Type (if appropriate).
104;;; 151;;;
105;;; Make sure the window is big enough to display the instructions 152
153(if (and edt-window-system (not (eq edt-window-system 'tty)))
154 (setq edt-term nil)
155 (setq edt-term (getenv "TERM")))
156
106;;; 157;;;
107(if edt-lucid-emacs19-p (set-screen-size nil 80 36) 158;;; Make sure the window is big enough to display the instructions,
108 (set-frame-size (selected-frame) 80 36)) 159;;; except where window cannot be re-sized.
160;;;
109 161
162(if (and edt-window-system (not (eq edt-window-system 'tty)))
163 (set-frame-size (selected-frame) 80 36))
110 164
111;;; 165;;;
112;;; Create buffers - Directions and Keys 166;;; Create buffers - Directions and Keys
@@ -131,56 +185,84 @@
131;;; Display directions 185;;; Display directions
132;;; 186;;;
133(switch-to-buffer "Directions") 187(switch-to-buffer "Directions")
134(insert " 188(if (and edt-window-system (not (eq edt-window-system 'tty)))
189 (insert "
135 EDT MAPPER 190 EDT MAPPER
136 191
137 You will be asked to press keys to create a custom mapping (under 192 You will be asked to press keys to create a custom mapping (under a
138 X-Windows) of your keypad keys and function keys so that they can emulate 193 Window Manager) of your keypad keys and function keys so that they can
139 the LK-201 keypad and function keys or the subset of keys found on a 194 emulate the LK-201 keypad and function keys or the subset of keys found
140 VT-100 series terminal keyboard. (The LK-201 keyboard is the standard 195 on a VT-100 series terminal keyboard. (The LK-201 keyboard is the
141 keyboard attached to VT-200 series terminals, and above.) 196 standard keyboard attached to VT-200 series terminals, and above.)
142 197
143 Sometimes, edt-mapper will ignore a key you press, and just continue to 198 Sometimes, edt-mapper will ignore a key you press, and just continue to
144 prompt for the same key. This can happen when your window manager sucks 199 prompt for the same key. This can happen when your window manager sucks
145 up the key and doesn't pass it on to emacs, or it could be an emacs bug. 200 up the key and doesn't pass it on to emacs, or it could be an emacs bug.
146 Either way, there's nothing that edt-mapper can do about it. You must 201 Either way, there's nothing that edt-mapper can do about it. You must
147 press RETURN, to skip the current key and continue. Later, you and/or 202 press RETURN, to skip the current key and continue. Later, you and/or
148 your local X guru can try to figure out why the key is being ignored. 203 your local system guru can try to figure out why the key is being ignored.
149 204
150 Start by pressing the RETURN key, and continue by pressing the keys 205 Start by pressing the RETURN key, and continue by pressing the keys
151 specified in the mini-buffer. If you want to entirely omit a key, 206 specified in the mini-buffer. If you want to entirely omit a key,
152 because your keyboard does not have a corresponding key, for example, 207 because your keyboard does not have a corresponding key, for example,
153 just press RETURN at the prompt. 208 just press RETURN at the prompt.
154 209
155") 210")
211 (insert "
212 EDT MAPPER
213
214 You will be asked to press keys to create a custom mapping of your
215 keypad keys and function keys so that they can emulate the LK-201
216 keypad and function keys or the subset of keys found on a VT-100
217 series terminal keyboard. (The LK-201 keyboard is the standard
218 keyboard attached to VT-200 series terminals, and above.)
219
220 If you are using an real LK-201 keyboard, you should map the keys
221 exactly as they are on the keyboard.
222
223 Start by pressing the RETURN key, and continue by pressing the keys
224 specified in the mini-buffer. If you want to entirely omit a key,
225 because your keyboard does not have a corresponding key, for example,
226 just press RETURN at the prompt.
227
228"))
229
156(delete-other-windows) 230(delete-other-windows)
157 231
158;;; 232;;;
159;;; Save <CR> for future reference 233;;; Save <CR> for future reference.
160;;; 234;;;
235;;; For GNU Emacs, running in a Window System, first hide bindings in
236;;; function-key-map.
237;;;
161(cond 238(cond
162 (edt-lucid-emacs19-p 239 (edt-x-emacs-p
163 (setq edt-return-seq (read-key-sequence "Hit carriage-return <CR> to continue ")) 240 (setq edt-return-seq (read-key-sequence "Hit carriage-return <CR> to continue "))
164 (setq edt-return (concat "[" (format "%s" (event-key (aref edt-return-seq 0))) "]"))) 241 (setq edt-return (concat "[" (format "%s" (event-key (aref edt-return-seq 0))) "]")))
165 (t 242 (t
166 (message "Hit carriage-return <CR> to continue ") 243 (if edt-window-system
167 (setq edt-return-seq (read-event)) 244 (progn
168 (setq edt-return (concat "[" (format "%s" edt-return-seq) "]")))) 245 (setq edt-save-function-key-map function-key-map)
246 (setq function-key-map (make-sparse-keymap))))
247 (setq edt-return (read-key-sequence "Hit carriage-return <CR> to continue "))))
169 248
170;;; 249;;;
250;;; Remove prefix-key bindings to F1 and F2 in global-map so they can be
251;;; bound in the EDT Emulation mode.
252;;;
253(global-unset-key [f1])
254(global-unset-key [f2])
255
256;;;
171;;; Display Keypad Diagram and Begin Prompting for Keys 257;;; Display Keypad Diagram and Begin Prompting for Keys
172;;; 258;;;
173(set-buffer "Directions") 259(set-buffer "Directions")
174(delete-region (point-min) (point-max)) 260(delete-region (point-min) (point-max))
175(insert " 261(if (and edt-window-system (not (eq edt-window-system 'tty)))
176 262 (insert "
177
178 263
179 PRESS THE KEY SPECIFIED IN THE MINIBUFFER BELOW. 264 PRESS THE KEY SPECIFIED IN THE MINIBUFFER BELOW.
180 265
181
182
183
184 Here's a picture of the standard LK-201 keypad for reference: 266 Here's a picture of the standard LK-201 keypad for reference:
185 267
186 _______________________ _______________________________ 268 _______________________ _______________________________
@@ -204,43 +286,72 @@
204 | | | | 286 | | | |
205 |_______________|_______|_______| 287 |_______________|_______|_______|
206 288
289 REMEMBER: JUST PRESS RETURN TO SKIP MAPPING A KEY.
290
207") 291")
292 (progn
293 (insert "
294 GENERATING A CUSTOM CONFIGURATION FILE FOR TERMINAL TYPE: ")
295 (insert (format "%s." edt-term))
296 (insert "
297
298 PRESS THE KEY SPECIFIED IN THE MINIBUFFER BELOW.
299
300 _______________________ _______________________________
301 | HELP | DO | | F17 | F18 | F19 | F20 |
302 |_______|_______________| |_______|_______|_______|_______|
303 _______________________ _______________________________
304 | FIND |INSERT |REMOVE | | PF1 | PF2 | PF3 | PF4 |
305 |_______|_______|_______| |_______|_______|_______|_______|
306 |SELECT |PREVIOU| NEXT | | KP7 | KP8 | KP9 | KP- |
307 |_______|_______|_______| |_______|_______|_______|_______|
308 | UP | | KP4 | KP5 | KP6 | KP, |
309 _______|_______|_______ |_______|_______|_______|_______|
310 | LEFT | DOWN | RIGHT | | KP1 | KP2 | KP3 | |
311 |_______|_______|_______| |_______|_______|_______| KPE |
312 | KP0 | KPP | |
313 |_______________|_______|_______|
314
315 REMEMBER: JUST PRESS RETURN TO SKIP MAPPING A KEY.")))
316
208 317
209;;; 318;;;
210;;; Key mapping functions 319;;; Key mapping functions
211;;; 320;;;
212(defun edt-lucid-map-key (ident descrip func gold-func) 321(defun edt-lucid-map-key (ident descrip)
213 (interactive) 322 (interactive)
214 (setq edt-key-seq (read-key-sequence (format "Press %s%s: " ident descrip))) 323 (setq edt-key-seq (read-key-sequence (format "Press %s%s: " ident descrip)))
215 (setq edt-key (concat "[" (format "%s" (event-key (aref edt-key-seq 0))) "]")) 324 (setq edt-key (concat "[" (format "%s" (event-key (aref edt-key-seq 0))) "]"))
216 (cond ((not (equal edt-key edt-return)) 325 (cond ((not (equal edt-key edt-return))
217 (set-buffer "Keys") 326 (set-buffer "Keys")
218 (insert (format " (\"%s\" . %s)\n" ident edt-key)) 327 (insert (format " (\"%s\" . %s)\n" ident edt-key))
219 (set-buffer "Directions")) 328 (set-buffer "Directions"))
220 ;; bogosity to get next prompt to come up, if the user hits <CR>! 329 ;; bogosity to get next prompt to come up, if the user hits <CR>!
221 ;; check periodically to see if this is still needed... 330 ;; check periodically to see if this is still needed...
222 (t 331 (t
223 (format "%s" edt-key))) 332 (set-buffer "Keys")
333 (insert (format " (\"%s\" . \"\" )\n" ident))
334 (set-buffer "Directions")))
224 edt-key) 335 edt-key)
225 336
226(defun edt-gnu-map-key (ident descrip) 337(defun edt-gnu-map-key (ident descrip)
227 (interactive) 338 (interactive)
228 (message "Press %s%s: " ident descrip) 339 (setq edt-key (read-key-sequence (format "Press %s%s: " ident descrip)))
229 (setq edt-key-seq (read-event))
230 (setq edt-key (concat "[" (format "%s" edt-key-seq) "]"))
231 (cond ((not (equal edt-key edt-return)) 340 (cond ((not (equal edt-key edt-return))
232 (set-buffer "Keys") 341 (set-buffer "Keys")
233 (insert (format " (\"%s\" . %s)\n" ident edt-key)) 342 (insert (if (vectorp edt-key)
234 (set-buffer "Directions")) 343 (format " (\"%s\" . %s)\n" ident edt-key)
235 ;; bogosity to get next prompt to come up, if the user hits <CR>! 344 (format " (\"%s\" . \"%s\")\n" ident edt-key)))
236 ;; check periodically to see if this is still needed... 345 (set-buffer "Directions"))
237 (t 346 ;; bogosity to get next prompt to come up, if the user hits <CR>!
238 (set-buffer "Keys") 347 ;; check periodically to see if this is still needed...
239 (insert (format " (\"%s\" . \"\" )\n" ident)) 348 (t
240 (set-buffer "Directions"))) 349 (set-buffer "Keys")
350 (insert (format " (\"%s\" . \"\" )\n" ident))
351 (set-buffer "Directions")))
241 edt-key) 352 edt-key)
242 353
243(fset 'edt-map-key (if edt-lucid-emacs19-p 'edt-lucid-map-key 'edt-gnu-map-key)) 354(fset 'edt-map-key (if edt-x-emacs-p 'edt-lucid-map-key 'edt-gnu-map-key))
244(set-buffer "Keys") 355(set-buffer "Keys")
245(insert " 356(insert "
246;; 357;;
@@ -343,28 +454,23 @@
343(set-buffer "Directions") 454(set-buffer "Directions")
344(delete-region (point-min) (point-max)) 455(delete-region (point-min) (point-max))
345(insert " 456(insert "
346 ADDITIONAL FUNCTION KEYS 457 ADDITIONAL FUNCTION KEYS
347 458
348 Your keyboard may have additional function keys which do not 459 Your keyboard may have additional function keys which do not correspond
349 correspond to any LK-201 keys. The EDT Emulation can be 460 to any LK-201 keys. The EDT Emulation can be configured to recognize
350 configured to recognize those keys, since you may wish to add your 461 those keys, since you may wish to add your own key bindings to those keys.
351 own key bindings to those keys.
352 462
353 For example, suppose your keyboard has a keycap marked \"Line Del\" 463 For example, suppose your keyboard has a keycap marked \"Line Del\" and
354 and you wish to add it to the list of keys which can be customized 464 you wish to add it to the list of keys which can be customized by the EDT
355 by the EDT Emulation. First, assign a unique single-word name to 465 Emulation. First, assign a unique single-word name to the key for use by
356 the key for use by the EDT Emulation, let's say \"linedel\", in this 466 the EDT Emulation, for example, \"linedel\". Then, at the \"EDT Key
357 example. Then, at the \"EDT Key Name:\" prompt, enter \"linedel\", 467 Name:\" prompt, enter \"linedel\", followed by a press of the RETURN key.
358 followed by a press of the RETURN key. Finally, when prompted, 468 Finally, when prompted, press the \"Line Del\" key. You now will be able
359 press the \"Line Del\" key. You now will be able to bind functions 469 to bind functions to \"linedel\" and \"Gold-linedel\" in edt-user.el in
360 to \"linedel\" and \"Gold-linedel\" in edt-user.el in just the same way 470 just the same way you can customize bindings of the LK-201 function and
361 you can customize bindings of the standard LK-201 keys. 471 keypad keys.
362 472
363 When you have no additional function keys to specify, just press 473 When you are done, just press RETURN at the \"EDT Key Name:\" prompt.
364 RETURN at the \"EDT Key Name:\" prompt. (If you change your mind
365 AFTER you enter an EDT Key Name and before you press a key at the
366 \"Press\" prompt, you may omit the key by simply pressing RETURN at
367 the prompt.)
368") 474")
369(switch-to-buffer "Directions") 475(switch-to-buffer "Directions")
370;;; 476;;;
@@ -373,12 +479,17 @@
373(set-buffer "Keys") 479(set-buffer "Keys")
374(insert "\ 480(insert "\
375;; 481;;
376;; Extra Keys 482;; Extra Keys
377;; 483;;
378") 484")
485;;;
486;;; Restore function-key-map.
487;;;
488(if (and edt-window-system (not edt-x-emacs-p))
489 (setq function-key-map edt-save-function-key-map))
379(setq EDT-key-name "") 490(setq EDT-key-name "")
380(while (not 491(while (not
381 (string-equal (setq EDT-key-name (read-string "EDT Key Name: ")) "")) 492 (string-equal (setq EDT-key-name (read-string "EDT Key Name: ")) ""))
382 (edt-map-key EDT-key-name "")) 493 (edt-map-key EDT-key-name ""))
383 494
384; 495;
@@ -391,9 +502,17 @@
391") 502")
392 503
393;;; 504;;;
394;;; Save the key mapping program and blow this pop stand 505;;; Save the key mapping program
506;;;
507;;;
508;;; Save the key mapping file
395;;; 509;;;
396(let ((file (if edt-lucid-emacs19-p "~/.edt-lucid-keys" "~/.edt-gnu-keys"))) 510(let ((file (concat
511 "~/.edt-" edt-emacs-variant
512 (if edt-term (concat "-" edt-term))
513 (if edt-xserver (concat "-" edt-xserver))
514 (if edt-window-system (concat "-" (upcase (symbol-name edt-window-system))))
515 "-keys")))
397 (set-visited-file-name 516 (set-visited-file-name
398 (read-file-name (format "Save key mapping to file (default %s): " file) nil file))) 517 (read-file-name (format "Save key mapping to file (default %s): " file) nil file)))
399(save-buffer) 518(save-buffer)