Mercurial > hg > xemacs-beta
comparison lisp/emulators/tpu-mapper.el @ 72:b9518feda344 r20-0b31
Import from CVS: tag r20-0b31
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:03:46 +0200 |
parents | 131b0175ea99 |
children |
comparison
equal
deleted
inserted
replaced
71:bae944334fa4 | 72:b9518feda344 |
---|---|
1 ;;; tpu-mapper.el --- Create a TPU-edt keymap file for x-windows emacs. | 1 ;;; tpu-mapper.el --- Create a TPU-edt X-windows keymap file |
2 | 2 |
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> | 5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> |
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> | 6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> |
7 ;; Keywords: emulations | 7 ;; Keywords: emulations |
8 | 8 |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 ;; General Public License for more details. | 19 ;; General Public License for more details. |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
24 ;; 02111-1307, USA. | |
25 | |
26 ;;; Synched up with: FSF 19.34 | |
24 | 27 |
25 ;;; Commentary: | 28 ;;; Commentary: |
26 | 29 |
27 ;; This emacs lisp program can be used to create an emacs lisp file that | 30 ;; This emacs lisp program can be used to create an emacs lisp file that |
28 ;; defines the TPU-edt keypad for emacs running on x-windows. Please read | 31 ;; defines the TPU-edt keypad for emacs running on x-windows. Please read |
29 ;; the "Usage" AND "Known Problems" sections before attempting to run this | 32 ;; the "Usage" AND "Known Problems" sections before attempting to run this |
30 ;; program. | 33 ;; program. |
31 | 34 |
32 ;;; Usage: | 35 ;;; Usage: |
33 | 36 |
34 ;; Simply load this file into the X-windows version of emacs (version 19) | 37 ;; Simply load this file into the X-windows version of XEmacs using the |
35 ;; using the following command. | 38 ;; following command. |
36 | 39 |
37 ;; emacs -q -l tpu-mapper.el | 40 ;; xemacs -q -l tpu-mapper |
38 | 41 |
39 ;; The "-q" option prevents loading of your .emacs file (commands therein | 42 ;; The "-q" option prevents loading of your .emacs file (commands therein |
40 ;; might confuse this program). | 43 ;; might confuse this program). |
41 | 44 |
42 ;; An instruction screen showing the TPU-edt keypad will be displayed, and | 45 ;; An instruction screen showing the TPU-edt keypad will be displayed, and |
43 ;; you will be prompted to press the TPU-edt editing keys. Tpu-mapper uses | 46 ;; you will be prompted to press the TPU-edt editing keys. Tpu-mapper uses |
44 ;; the keys you press to create an emacs lisp file that will define a | 47 ;; the keys you press to create an Emacs Lisp file that will define a |
45 ;; TPU-edt keypad for your X server. You can even re-arrange the standard | 48 ;; TPU-edt keypad for your X server. You can even re-arrange the standard |
46 ;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC | 49 ;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC |
47 ;; keypads). | 50 ;; keypads). |
48 | 51 |
49 ;; Finally, you will be prompted for the name of the file to store the key | 52 ;; Finally, you will be prompted for the name of the file to store the key |
50 ;; definitions. If you chose the default, TPU-edt will find it and load it | 53 ;; definitions. If you chose the default, TPU-edt will find it and load it |
51 ;; automatically. If you specify a different file name, you will need to | 54 ;; automatically. If you specify a different file name, you will need to |
52 ;; set the variable "tpu-xkeys-file" before loading TPU-edt. Here's how | 55 ;; set the variable "tpu-xkeys-file" before starting TPU-edt. Here's how |
53 ;; you might go about doing that in your .emacs file. | 56 ;; you might go about doing that in your .emacs file. |
54 | 57 |
55 ;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys")) | 58 ;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys")) |
56 ;; (load "tpu-edt") | 59 ;; (tpu-edt) |
57 | 60 |
58 ;;; Known Problems: | 61 ;;; Known Problems: |
59 | 62 |
60 ;; Sometimes, tpu-mapper will ignore a key you press, and just continue to | 63 ;; Sometimes, tpu-mapper will ignore a key you press, and just continue to |
61 ;; prompt for the same key. This can happen when your window manager sucks | 64 ;; prompt for the same key. This can happen when your window manager sucks |
62 ;; up the key and doesn't pass it on to emacs, or it could be an emacs bug. | 65 ;; up the key and doesn't pass it on to Emacs, or it could be an Emacs bug. |
63 ;; Either way, there's nothing that tpu-mapper can do about it. You must | 66 ;; Either way, there's nothing that tpu-mapper can do about it. You must |
64 ;; press RETURN, to skip the current key and continue. Later, you and/or | 67 ;; press RETURN, to skip the current key and continue. Later, you and/or |
65 ;; your local X guru can try to figure out why the key is being ignored. | 68 ;; your local X guru can try to figure out why the key is being ignored. |
66 | 69 |
70 ;; NOTE: There was a very old tpu-edt in XEmacs 19.14 so I deleted it and | |
71 ;; replaced it with the one in Emacs 19.34. -sb | |
72 | |
67 ;;; Code: | 73 ;;; Code: |
68 | |
69 ;;; | |
70 ;;; Revision Information | |
71 ;;; | |
72 (defconst tpu-mapper-revision "!Revision: 1.5 !" | |
73 "Revision number of TPU-edt x-windows emacs key mapper.") | |
74 | 74 |
75 | 75 |
76 ;;; | 76 ;;; |
77 ;;; Make sure we're running X-windows and Emacs version 19 | 77 ;;; Make sure we're running X-windows and Emacs version 19 |
78 ;;; | 78 ;;; |
79 (cond | 79 (cond |
80 ((not (and window-system (not (string-lessp emacs-version "19")))) | 80 ((not (and window-system (not (string-lessp emacs-version "19")))) |
81 (insert " | 81 (error "tpu-mapper requires running in Emacs 19, with an X display"))) |
82 | 82 |
83 Whoa! This isn't going to work... | 83 |
84 | 84 ;;; |
85 You must run tpu-mapper.el under X-windows and Emacs version 19. | 85 ;;; Decide whether we're running Lucid Emacs or Emacs itself. |
86 | 86 ;;; |
87 Press any key to exit. ") | 87 (defconst tpu-lucid-emacs19-p (string-match "Lucid" emacs-version) |
88 (sit-for 600) | 88 "Non-NIL if we are running Lucid Emacs version 19.") |
89 (kill-emacs t))) | |
90 | |
91 | |
92 ;;; | |
93 ;;; Decide whether we're running GNU Emacs or XEmacs. | |
94 ;;; | |
95 (defconst tpu-xemacs-emacs19-p (string-match "XEmacs" emacs-version) | |
96 "Non-NIL if we are running XEmacs version 19.") | |
97 | 89 |
98 | 90 |
99 ;;; | 91 ;;; |
100 ;;; Key variables | 92 ;;; Key variables |
101 ;;; | 93 ;;; |
94 (defvar tpu-kp4 nil) | |
95 (defvar tpu-kp5 nil) | |
102 (defvar tpu-key nil) | 96 (defvar tpu-key nil) |
103 (defvar tpu-enter nil) | 97 (defvar tpu-enter nil) |
104 (defvar tpu-return nil) | 98 (defvar tpu-return nil) |
105 (defvar tpu-key-seq nil) | 99 (defvar tpu-key-seq nil) |
106 (defvar tpu-enter-seq nil) | 100 (defvar tpu-enter-seq nil) |
108 | 102 |
109 | 103 |
110 ;;; | 104 ;;; |
111 ;;; Make sure the window is big enough to display the instructions | 105 ;;; Make sure the window is big enough to display the instructions |
112 ;;; | 106 ;;; |
113 (if tpu-xemacs-emacs19-p (set-screen-size nil 80 36) | 107 (if tpu-lucid-emacs19-p (set-screen-size (selected-screen) 80 36) |
114 (set-frame-size (selected-frame) 80 36)) | 108 (set-frame-size (selected-frame) 80 36)) |
115 | 109 |
116 | 110 |
117 ;;; | 111 ;;; |
118 ;;; Create buffers - Directions, Keys, Gold-Keys | 112 ;;; Create buffers - Directions, Keys, Gold-Keys |
136 ;;; Display directions | 130 ;;; Display directions |
137 ;;; | 131 ;;; |
138 (switch-to-buffer "Directions") | 132 (switch-to-buffer "Directions") |
139 (insert " | 133 (insert " |
140 This program prompts you to press keys to create a custom keymap file | 134 This program prompts you to press keys to create a custom keymap file |
141 for use with the x-windows version of emacs and TPU-edt. | 135 for use with the x-windows version of Emacs and TPU-edt. |
142 | 136 |
143 Start by pressing the RETURN key, and continue by pressing the keys | 137 Start by pressing the RETURN key, and continue by pressing the keys |
144 specified in the mini-buffer. You can re-arrange the TPU-edt keypad | 138 specified in the mini-buffer. You can re-arrange the TPU-edt keypad |
145 by pressing any key you want at any prompt. If you want to entirely | 139 by pressing any key you want at any prompt. If you want to entirely |
146 omit a key, just press RETURN at the prompt. | 140 omit a key, just press RETURN at the prompt. |
169 |_______________|_______|_______| | 163 |_______________|_______|_______| |
170 | 164 |
171 | 165 |
172 ") | 166 ") |
173 (delete-other-windows) | 167 (delete-other-windows) |
168 (goto-char (point-min)) | |
174 | 169 |
175 ;;; | 170 ;;; |
176 ;;; Save <CR> for future reference | 171 ;;; Save <CR> for future reference |
177 ;;; | 172 ;;; |
178 (cond | 173 (cond |
179 (tpu-xemacs-emacs19-p | 174 (tpu-lucid-emacs19-p |
180 (setq tpu-return-seq (read-key-sequence "Hit carriage-return <CR> to continue ")) | 175 (setq tpu-return-seq (read-key-sequence "Hit carriage-return <CR> to continue ")) |
181 (setq tpu-return (concat "[" (format "%s" (event-key (aref tpu-return-seq 0))) "]"))) | 176 (setq tpu-return (concat "[" (format "%s" (event-key (aref tpu-return-seq 0))) "]"))) |
182 (t | 177 (t |
183 (message "Hit carriage-return <CR> to continue ") | 178 (message "Hit carriage-return <CR> to continue ") |
184 (setq tpu-return-seq (read-event)) | 179 (setq tpu-return-seq (read-event)) |
185 (setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]")))) | 180 (setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]")))) |
186 | 181 |
187 | 182 |
188 ;;; | 183 ;;; |
189 ;;; Key mapping functions | 184 ;;; Key mapping functions |
190 ;;; | 185 ;;; |
191 (defun tpu-xemacs-map-key (ident descrip func gold-func) | 186 (defun tpu-lucid-map-key (ident descrip func gold-func) |
192 (interactive) | 187 (interactive) |
193 (setq tpu-key-seq (read-key-sequence (format "Press %s%s: " ident descrip))) | 188 (setq tpu-key-seq (read-key-sequence (format "Press %s%s: " ident descrip))) |
194 (setq tpu-key (concat "[" (format "%s" (event-key (aref tpu-key-seq 0))) "]")) | 189 (setq tpu-key (concat "[" (format "%s" (event-key (aref tpu-key-seq 0))) "]")) |
195 (cond ((not (equal tpu-key tpu-return)) | 190 (cond ((not (equal tpu-key tpu-return)) |
196 (set-buffer "Keys") | 191 (set-buffer "Keys") |
202 ;; check periodically to see if this is still needed... | 197 ;; check periodically to see if this is still needed... |
203 (t | 198 (t |
204 (format "%s" tpu-key))) | 199 (format "%s" tpu-key))) |
205 tpu-key) | 200 tpu-key) |
206 | 201 |
207 (defun tpu-gnu-map-key (ident descrip func gold-func) | 202 (defun tpu-emacs-map-key (ident descrip func gold-func) |
208 (interactive) | 203 (interactive) |
209 (message "Press %s%s: " ident descrip) | 204 (message "Press %s%s: " ident descrip) |
210 (setq tpu-key-seq (read-event)) | 205 (setq tpu-key-seq (read-event)) |
211 (setq tpu-key (concat "[" (format "%s" tpu-key-seq) "]")) | 206 (setq tpu-key (concat "[" (format "%s" tpu-key-seq) "]")) |
212 (cond ((not (equal tpu-key tpu-return)) | 207 (cond ((not (equal tpu-key tpu-return)) |
219 ;; check periodically to see if this is still needed... | 214 ;; check periodically to see if this is still needed... |
220 (t | 215 (t |
221 (format "%s" tpu-key))) | 216 (format "%s" tpu-key))) |
222 tpu-key) | 217 tpu-key) |
223 | 218 |
224 (fset 'tpu-map-key (if tpu-xemacs-emacs19-p 'tpu-xemacs-map-key 'tpu-gnu-map-key)) | 219 (fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-emacs-map-key)) |
225 | 220 |
226 | 221 |
227 (set-buffer "Keys") | 222 (set-buffer "Keys") |
228 (insert " | 223 (insert " |
229 ;; Arrows | 224 ;; Arrows |
273 | 268 |
274 (tpu-map-key "KP-0" " - The Line/Open-Line key" "'tpu-line" "'open-line") | 269 (tpu-map-key "KP-0" " - The Line/Open-Line key" "'tpu-line" "'open-line") |
275 (tpu-map-key "KP-1" " - The Word/Change-Case key" "'tpu-word" "'tpu-change-case") | 270 (tpu-map-key "KP-1" " - The Word/Change-Case key" "'tpu-word" "'tpu-change-case") |
276 (tpu-map-key "KP-2" " - The EOL/Delete-EOL key" "'tpu-end-of-line" "'tpu-delete-to-eol") | 271 (tpu-map-key "KP-2" " - The EOL/Delete-EOL key" "'tpu-end-of-line" "'tpu-delete-to-eol") |
277 (tpu-map-key "KP-3" " - The Character/Special-Insert key" "'tpu-char" "'tpu-special-insert") | 272 (tpu-map-key "KP-3" " - The Character/Special-Insert key" "'tpu-char" "'tpu-special-insert") |
278 (tpu-map-key "KP-4" " - The Forward/Bottom key" "'tpu-advance-direction" "'tpu-move-to-end") | 273 (setq tpu-kp4 (tpu-map-key "KP-4" " - The Forward/Bottom key" "'tpu-advance-direction" "'tpu-move-to-end")) |
279 (tpu-map-key "KP-5" " - The Reverse/Top key" "'tpu-backup-direction" "'tpu-move-to-beginning") | 274 (setq tpu-kp5 (tpu-map-key "KP-5" " - The Reverse/Top key" "'tpu-backup-direction" "'tpu-move-to-beginning")) |
280 (tpu-map-key "KP-6" " - The Remove/Insert key" "'tpu-cut" "'tpu-paste") | 275 (tpu-map-key "KP-6" " - The Remove/Insert key" "'tpu-cut" "'tpu-paste") |
281 (tpu-map-key "KP-7" " - The Page/Do key" "'tpu-page" "'execute-extended-command") | 276 (tpu-map-key "KP-7" " - The Page/Do key" "'tpu-page" "'execute-extended-command") |
282 (tpu-map-key "KP-8" " - The Section/Fill key" "'tpu-scroll-window" "'tpu-fill") | 277 (tpu-map-key "KP-8" " - The Section/Fill key" "'tpu-scroll-window" "'tpu-fill") |
283 (tpu-map-key "KP-9" " - The Append/Replace key" "'tpu-append-region" "'tpu-replace") | 278 (tpu-map-key "KP-9" " - The Append/Replace key" "'tpu-append-region" "'tpu-replace") |
284 (tpu-map-key "KP--" " - The Delete/Undelete Word key" "'tpu-delete-current-word" "'tpu-undelete-words") | 279 (tpu-map-key "KP--" " - The Delete/Undelete Word key" "'tpu-delete-current-word" "'tpu-undelete-words") |
342 (insert (format "(define-key minibuffer-local-map %s 'exit-minibuffer)\n" tpu-enter)) | 337 (insert (format "(define-key minibuffer-local-map %s 'exit-minibuffer)\n" tpu-enter)) |
343 (insert (format "(define-key minibuffer-local-ns-map %s 'exit-minibuffer)\n" tpu-enter)) | 338 (insert (format "(define-key minibuffer-local-ns-map %s 'exit-minibuffer)\n" tpu-enter)) |
344 (insert (format "(define-key minibuffer-local-completion-map %s 'exit-minibuffer)\n" tpu-enter)) | 339 (insert (format "(define-key minibuffer-local-completion-map %s 'exit-minibuffer)\n" tpu-enter)) |
345 (insert (format "(define-key minibuffer-local-must-match-map %s 'minibuffer-complete-and-exit)\n" tpu-enter)))) | 340 (insert (format "(define-key minibuffer-local-must-match-map %s 'minibuffer-complete-and-exit)\n" tpu-enter)))) |
346 | 341 |
342 (cond | |
343 ((not (or (equal tpu-kp4 tpu-return) (equal tpu-kp5 tpu-return))) | |
344 (insert " | |
345 ;; Minibuffer map additions to allow KP-4/5 termination of search strings. | |
346 ;; | |
347 ") | |
348 | |
349 (insert (format "(define-key minibuffer-local-map %s 'tpu-search-forward-exit)\n" tpu-kp4)) | |
350 (insert (format "(define-key minibuffer-local-map %s 'tpu-search-backward-exit)\n" tpu-kp5)))) | |
351 | |
347 (insert " | 352 (insert " |
348 ;; Define the tpu-help-enter/return symbols | 353 ;; Define the tpu-help-enter/return symbols |
349 ;; | 354 ;; |
350 ") | 355 ") |
351 | 356 |
352 (cond (tpu-xemacs-emacs19-p | 357 (cond (tpu-lucid-emacs19-p |
353 (insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter-seq)) | 358 (insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter-seq)) |
354 (insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq)) | 359 (insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq)) |
355 (insert "(setq tpu-help-N \"[#<keypress-event N>]\")\n") | 360 (insert "(setq tpu-help-N \"[#<keypress-event N>]\")\n") |
356 (insert "(setq tpu-help-n \"[#<keypress-event n>]\")\n") | 361 (insert "(setq tpu-help-n \"[#<keypress-event n>]\")\n") |
357 (insert "(setq tpu-help-P \"[#<keypress-event P>]\")\n") | 362 (insert "(setq tpu-help-P \"[#<keypress-event P>]\")\n") |
361 | 366 |
362 (append-to-buffer "Keys" 1 (point)) | 367 (append-to-buffer "Keys" 1 (point)) |
363 (set-buffer "Keys") | 368 (set-buffer "Keys") |
364 | 369 |
365 ;;; | 370 ;;; |
366 ;;; Save the key mapping program and blow this pop stand | 371 ;;; Save the key mapping program |
367 ;;; | 372 ;;; |
368 (let ((file (if tpu-xemacs-emacs19-p "~/.tpu-xemacs-keys" "~/.tpu-gnu-keys"))) | 373 (let ((file |
374 (convert-standard-filename | |
375 (if tpu-lucid-emacs19-p "~/.tpu-lucid-keys" "~/.tpu-keys")))) | |
369 (set-visited-file-name | 376 (set-visited-file-name |
370 (read-file-name (format "Save key mapping to file (default %s): " file) nil file))) | 377 (read-file-name (format "Save key mapping to file (default %s): " file) "" file))) |
371 (save-buffer) | 378 (save-buffer) |
372 | 379 |
373 (message "That's it! Press any key to exit") | 380 ;;; |
374 (sit-for 600) | 381 ;;; Load the newly defined keys and clean up |
375 (kill-emacs t) | 382 ;;; |
383 (eval-current-buffer) | |
384 (kill-buffer (current-buffer)) | |
385 (kill-buffer "*scratch*") | |
386 (kill-buffer "Gold-Keys") | |
387 | |
388 ;;; | |
389 ;;; Let them know it worked. | |
390 ;;; | |
391 (switch-to-buffer "Directions") | |
392 (erase-buffer) | |
393 (insert " | |
394 A custom TPU-edt keymap file has been created. | |
395 | |
396 Press GOLD-k to remove this buffer and continue editing. | |
397 ") | |
398 (goto-char (point-min)) | |
376 | 399 |
377 ;;; tpu-mapper.el ends here | 400 ;;; tpu-mapper.el ends here |