1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
;;; tpu-mapper.el --- Create a TPU-edt keymap file for x-windows emacs.
;; Copyright (C) 1993 Free Software Foundation, Inc.
;; Author: Rob Riepel <riepel@networking.stanford.edu>
;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
;; Keywords: tpu-edt
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY. No author or distributor
;; accepts responsibility to anyone for the consequences of using it
;; or for whether it serves any particular purpose or works at all,
;; unless he says so in writing. Refer to the GNU Emacs General Public
;; License for full details.
;; Everyone is granted permission to copy, modify and redistribute
;; GNU Emacs, but only under the conditions described in the
;; GNU Emacs General Public License. A copy of this license is
;; supposed to have been given to you along with GNU Emacs so you
;; can know your rights and responsibilities. It should be in a
;; file named COPYING. Among other things, the copyright notice
;; and this notice must be preserved on all copies.
;;
;;; Revision: $Id: tpu-mapper.el,v 1.1 1993/08/01 21:39:07 riepel Exp $
;;; Commentary:
;; This emacs lisp program can be used to create an emacs lisp file that
;; defines the TPU-edt keypad for emacs running on x-windows. Please read
;; the "Usage" AND "Known Problems" sections before attempting to run this
;; program.
;;; Usage:
;; Simply load this file into the X-windows version of emacs (version 19)
;; using the following command.
;; emacs -q -l tpu-mapper.el
;; The "-q" option prevents loading of your .emacs file (commands therein
;; might confuse this program).
;; An instruction screen showing the TPU-edt keypad will be displayed, and
;; you will be prompted to press the TPU-edt editing keys. Tpu-mapper uses
;; the keys you press to create an emacs lisp file that will define a
;; TPU-edt keypad for your X server. You can even re-arrange the standard
;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC
;; keypads).
;; Finally, you will be prompted for the name of the file to store the key
;; definitions. If you chose the default, TPU-edt will find it and load it
;; automatically. If you specify a different file name, you will need to
;; set the variable "tpu-xkeys-file" before loading TPU-edt. Here's how
;; you might go about doing that in your .emacs file.
;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys"))
;; (load "tpu-edt")
;;; Known Problems:
;; Sometimes, tpu-mapper will ignore a key you press, and just continue to
;; prompt for the same key. This can happen when your window manager sucks
;; up the key and doesn't pass it on to emacs, or it could be an emacs bug.
;; Either way, there's nothing that tpu-mapper can do about it. You must
;; press RETURN, to skip the current key and continue. Later, you and/or
;; your local X guru can try to figure out why the key is being ignored.
;;; Code:
;;;
;;; Revision Information
;;;
(defconst tpu-mapper-revision "$Revision: 1.1 $"
"Revision number of TPU-edt x-windows emacs key mapper.")
;;;
;;; Make sure we're running X-windows and Emacs version 19
;;;
(cond
((not (and window-system (not (string-lessp emacs-version "19"))))
(insert "
Whoa! This isn't going to work...
You must run tpu-mapper.el under X-windows and Emacs version 19.
Press any key to exit. ")
(sit-for 600)
(kill-emacs t)))
;;;
;;; Decide whether we're running GNU or Lucid emacs.
;;;
(defconst tpu-lucid-emacs19-p (string-match "Lucid" emacs-version)
"Non-NIL if we are running Lucid Emacs version 19.")
;;;
;;; Key variables
;;;
(defvar tpu-key nil)
(defvar tpu-enter nil)
(defvar tpu-return nil)
(defvar tpu-key-seq nil)
(defvar tpu-enter-seq nil)
(defvar tpu-return-seq nil)
;;;
;;; Make sure the window is big enough to display the instructions
;;;
(if tpu-lucid-emacs19-p (set-screen-size nil 80 36)
(set-frame-size (selected-frame) 80 36))
;;;
;;; Create buffers - Directions, Keys, Gold-Keys
;;;
(if (not (get-buffer "Directions")) (generate-new-buffer "Directions"))
(if (not (get-buffer "Keys")) (generate-new-buffer "Keys"))
(if (not (get-buffer "Gold-Keys")) (generate-new-buffer "Gold-Keys"))
;;;
;;; Put headers in the Keys buffer
;;;
(set-buffer "Keys")
(insert "\
;; Key definitions for TPU-edt
;;
")
;;;
;;; Display directions
;;;
(switch-to-buffer "Directions")
(insert "
This program prompts you to press keys to create a custom keymap file
for use with the x-windows version of emacs and TPU-edt.
Start by pressing the RETURN key, and continue by pressing the keys
specified in the mini-buffer. You can re-arrange the TPU-edt keypad
by pressing any key you want at any prompt. If you want to entirely
omit a key, just press RETURN at the prompt.
Here's a picture of the standard TPU/edt keypad for reference:
_______________________ _______________________________
| HELP | Do | | | | | |
|KeyDefs| | | | | | |
|_______|_______________| |_______|_______|_______|_______|
_______________________ _______________________________
| Find |Insert |Remove | | Gold | HELP |FndNxt | Del L |
| | |Sto Tex| | key |E-Help | Find |Undel L|
|_______|_______|_______| |_______|_______|_______|_______|
|Select |Pre Scr|Nex Scr| | Page | Sect |Append | Del W |
| Reset |Pre Win|Nex Win| | Do | Fill |Replace|Undel W|
|_______|_______|_______| |_______|_______|_______|_______|
|Move up| |Forward|Reverse|Remove | Del C |
| Top | |Bottom | Top |Insert |Undel C|
_______|_______|_______ |_______|_______|_______|_______|
|Mov Lef|Mov Dow|Mov Rig| | Word | EOL | Char | |
|StaOfLi|Bottom |EndOfLi| |ChngCas|Del EOL|SpecIns| Enter |
|_______|_______|_______| |_______|_______|_______| |
| Line |Select | Subs |
| Open Line | Reset | |
|_______________|_______|_______|
")
(delete-other-windows)
;;;
;;; Save <CR> for future reference
;;;
(setq tpu-return-seq (read-key-sequence "Hit carriage-return <CR> to continue "))
(cond
(tpu-lucid-emacs19-p
(setq tpu-return (concat "[" (format "%s" (event-key (aref tpu-return-seq 0))) "]")))
(t
(setq tpu-return (format "%s" tpu-return-seq))))
;;;
;;; Key mapping functions
;;;
(defun tpu-lucid-map-key (ident descrip func gold-func)
(interactive)
(setq tpu-key-seq (read-key-sequence (format "Press %s%s: " ident descrip)))
(setq tpu-key (concat "[" (format "%s" (event-key (aref tpu-key-seq 0))) "]"))
(cond ((not (equal tpu-key tpu-return))
(set-buffer "Keys")
(insert (format"(global-set-key %s %s)\n" tpu-key func))
(set-buffer "Gold-Keys")
(insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func))
(set-buffer "Directions"))
;; bogosity to get next prompt to come up, if the user hits <CR>!
;; check periodically to see if this is still needed...
(t
(format "%s" tpu-key)))
tpu-key)
(defun tpu-gnu-map-key (ident descrip func gold-func)
(interactive)
(setq tpu-key-seq (read-key-sequence (format "Press %s%s: " ident descrip)))
(setq tpu-key (format "%s" tpu-key-seq))
(cond ((not (equal tpu-key tpu-return))
(set-buffer "Keys")
(insert (format"(global-set-key %s %s)\n" tpu-key func))
(set-buffer "Gold-Keys")
(insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func))
(set-buffer "Directions"))
;; bogosity to get next prompt to come up, if the user hits <CR>!
;; check periodically to see if this is still needed...
(t
(format "%s" tpu-key)))
tpu-key)
(fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-gnu-map-key))
(set-buffer "Keys")
(insert "
;; Arrows
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD Arrows
;;
")
(set-buffer "Directions")
(tpu-map-key "Up-Arrow" "" "'tpu-previous-line" "'tpu-move-to-beginning")
(tpu-map-key "Down-arrow" "" "'tpu-next-line" "'tpu-move-to-end")
(tpu-map-key "Right-arrow" "" "'tpu-forward-char" "'end-of-line")
(tpu-map-key "Left-arrow" "" "'tpu-backward-char" "'beginning-of-line")
(set-buffer "Keys")
(insert "
;; PF keys
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD PF keys
;;
")
(set-buffer "Directions")
(tpu-map-key "PF1" " - The GOLD key" "GOLD-map" "'keyboard-quit")
(tpu-map-key "PF2" " - The Keypad Help key" "'tpu-help" "'help-for-help")
(tpu-map-key "PF3" " - The Find/Find-Next key" "'tpu-search-again" "'tpu-search")
(tpu-map-key "PF4" " - The Del/Undelete Line key" "'tpu-delete-current-line" "'tpu-undelete-lines")
(set-buffer "Keys")
(insert "
;; KP0-9 KP- KP, KP. and KPenter
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD KP0-9 KP- KP, and KPenter
;;
")
(set-buffer "Directions")
(tpu-map-key "KP-0" " - The Line/Open-Line key" "'tpu-line" "'open-line")
(tpu-map-key "KP-1" " - The Word/Change-Case key" "'tpu-word" "'tpu-change-case")
(tpu-map-key "KP-2" " - The EOL/Delete-EOL key" "'tpu-end-of-line" "'tpu-delete-to-eol")
(tpu-map-key "KP-3" " - The Character/Special-Insert key" "'tpu-char" "'tpu-special-insert")
(tpu-map-key "KP-4" " - The Forward/Bottom key" "'tpu-advance-direction" "'tpu-move-to-end")
(tpu-map-key "KP-5" " - The Reverse/Top key" "'tpu-backup-direction" "'tpu-move-to-beginning")
(tpu-map-key "KP-6" " - The Remove/Insert key" "'tpu-cut" "'tpu-paste")
(tpu-map-key "KP-7" " - The Page/Do key" "'tpu-page" "'execute-extended-command")
(tpu-map-key "KP-8" " - The Section/Fill key" "'tpu-scroll-window" "'tpu-fill")
(tpu-map-key "KP-9" " - The Append/Replace key" "'tpu-append-region" "'tpu-replace")
(tpu-map-key "KP--" " - The Delete/Undelete Word key" "'tpu-delete-current-word" "'tpu-undelete-words")
(tpu-map-key "KP-," " - The Delete/Undelete Character key" "'tpu-delete-current-char" "'tpu-undelete-char")
(tpu-map-key "KP-." " - The Select/Reset key" "'tpu-select" "'tpu-unselect")
(tpu-map-key "KP-Enter" " - The Enter key on the numeric keypad" "'newline" "'tpu-substitute")
;; Save the enter key
(setq tpu-enter tpu-key)
(setq tpu-enter-seq tpu-key-seq)
(set-buffer "Keys")
(insert "
;; Editing keypad (find, insert, remove)
;; (select, prev, next)
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD Editing keypad (find, insert, remove)
;; (select, prev, next)
;;
")
(set-buffer "Directions")
(tpu-map-key "Find" " - The Find key on the editing keypad" "'tpu-search" "'nil")
(tpu-map-key "Insert" " - The Insert key on the editing keypad" "'tpu-paste" "'nil")
(tpu-map-key "Remove" " - The Remove key on the editing keypad" "'tpu-cut" "'tpu-store-text")
(tpu-map-key "Select" " - The Select key on the editing keypad" "'tpu-select" "'tpu-unselect")
(tpu-map-key "Prev Scr" " - The Prev Scr key on the editing keypad" "'tpu-scroll-window-down" "'tpu-previous-window")
(tpu-map-key "Next Scr" " - The Next Scr key on the editing keypad" "'tpu-scroll-window-up" "'tpu-next-window")
(set-buffer "Keys")
(insert "
;; F10-14 Help Do F17
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD F10-14 Help Do F17
;;
")
(set-buffer "Directions")
(tpu-map-key "F10" " - Invokes the Exit function on VT200+ terminals" "'tpu-exit" "'nil")
(tpu-map-key "F11" " - Inserts an Escape character into the text" "'tpu-insert-escape" "'nil")
(tpu-map-key "Backspace" " - Not Delete nor ^H! Sometimes on the F12 key" "'tpu-next-beginning-of-line" "'nil")
(tpu-map-key "F13" " - Invokes the delete previous word function" "'tpu-delete-previous-word" "'nil")
(tpu-map-key "F14" " - Toggles insert/overstrike modes" "'tpu-toggle-overwrite-mode" "'nil")
(tpu-map-key "Help" " - Brings up the help screen, same as PF2" "'tpu-help" "'describe-bindings")
(tpu-map-key "Do" " - Invokes the COMMAND function" "'execute-extended-command" "'nil")
(tpu-map-key "F17" "" "'tpu-goto-breadcrumb" "'tpu-drop-breadcrumb")
(set-buffer "Gold-Keys")
(cond
((not (equal tpu-enter tpu-return))
(insert "
;; Minibuffer map additions to make KP_enter = RET
;;
")
(insert (format "(define-key minibuffer-local-map %s 'exit-minibuffer)\n" tpu-enter))
(insert (format "(define-key minibuffer-local-ns-map %s 'exit-minibuffer)\n" tpu-enter))
(insert (format "(define-key minibuffer-local-completion-map %s 'exit-minibuffer)\n" tpu-enter))
(insert (format "(define-key minibuffer-local-must-match-map %s 'minibuffer-complete-and-exit)\n" tpu-enter))))
(insert "
;; Define the tpu-help-enter/return symbols
;;
")
(insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter-seq))
(insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq))
(append-to-buffer "Keys" 1 (point))
(set-buffer "Keys")
;;;
;;; Save the key mapping program and blow this pop stand
;;;
(let ((file (if tpu-lucid-emacs19-p "~/.tpu-lucid-keys" "~/.tpu-gnu-keys")))
(set-visited-file-name
(read-file-name (format "Save key mapping to file (default %s): " file) nil file)))
(save-buffer)
(message "That's it! Press any key to exit")
(sit-for 600)
(kill-emacs t)
;;; tpu-mapper.el ends here
|