Mercurial > emacs
annotate lisp/emulation/tpu-mapper.el @ 7063:9a0d189fd877
(kill-line, kill-word): Don't use save-excursion.
(kill-read-only-ok): New variable.
(kill-region): Handle that variable. Handle read-only text property.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 24 Apr 1994 05:44:23 +0000 |
parents | 9cde7d7fea1f |
children | 0e9eddc5d598 |
rev | line source |
---|---|
4421 | 1 ;;; tpu-mapper.el --- Create a TPU-edt keymap file for x-windows emacs. |
2 | |
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> | |
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> | |
5140 | 7 ;; Keywords: emulations |
4421 | 8 |
4450 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
4421 | 15 |
4450 | 16 ;; GNU Emacs is distributed in the hope that it will be useful, |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
4421 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; 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 | |
29 ;; the "Usage" AND "Known Problems" sections before attempting to run this | |
30 ;; program. | |
31 | |
32 ;;; Usage: | |
33 | |
34 ;; Simply load this file into the X-windows version of emacs (version 19) | |
35 ;; using the following command. | |
36 | |
37 ;; emacs -q -l tpu-mapper.el | |
38 | |
39 ;; The "-q" option prevents loading of your .emacs file (commands therein | |
40 ;; might confuse this program). | |
41 | |
42 ;; 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 | |
44 ;; 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 | |
46 ;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC | |
47 ;; keypads). | |
48 | |
49 ;; 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 | |
51 ;; 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 | |
53 ;; you might go about doing that in your .emacs file. | |
54 | |
55 ;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys")) | |
56 ;; (load "tpu-edt") | |
57 | |
58 ;;; Known Problems: | |
59 | |
60 ;; 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 | |
62 ;; 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 | |
64 ;; 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. | |
66 | |
67 ;;; Code: | |
68 | |
69 ;;; | |
70 ;;; Revision Information | |
71 ;;; | |
5140 | 72 (defconst tpu-mapper-revision "$Revision: 1.4 $" |
4421 | 73 "Revision number of TPU-edt x-windows emacs key mapper.") |
74 | |
75 | |
76 ;;; | |
77 ;;; Make sure we're running X-windows and Emacs version 19 | |
78 ;;; | |
79 (cond | |
80 ((not (and window-system (not (string-lessp emacs-version "19")))) | |
81 (insert " | |
82 | |
83 Whoa! This isn't going to work... | |
84 | |
85 You must run tpu-mapper.el under X-windows and Emacs version 19. | |
86 | |
87 Press any key to exit. ") | |
88 (sit-for 600) | |
89 (kill-emacs t))) | |
90 | |
91 | |
92 ;;; | |
93 ;;; Decide whether we're running GNU or Lucid emacs. | |
94 ;;; | |
95 (defconst tpu-lucid-emacs19-p (string-match "Lucid" emacs-version) | |
96 "Non-NIL if we are running Lucid Emacs version 19.") | |
97 | |
98 | |
99 ;;; | |
100 ;;; Key variables | |
101 ;;; | |
102 (defvar tpu-key nil) | |
103 (defvar tpu-enter nil) | |
104 (defvar tpu-return nil) | |
105 (defvar tpu-key-seq nil) | |
106 (defvar tpu-enter-seq nil) | |
107 (defvar tpu-return-seq nil) | |
108 | |
109 | |
110 ;;; | |
111 ;;; Make sure the window is big enough to display the instructions | |
112 ;;; | |
113 (if tpu-lucid-emacs19-p (set-screen-size nil 80 36) | |
114 (set-frame-size (selected-frame) 80 36)) | |
115 | |
116 | |
117 ;;; | |
118 ;;; Create buffers - Directions, Keys, Gold-Keys | |
119 ;;; | |
120 (if (not (get-buffer "Directions")) (generate-new-buffer "Directions")) | |
121 (if (not (get-buffer "Keys")) (generate-new-buffer "Keys")) | |
122 (if (not (get-buffer "Gold-Keys")) (generate-new-buffer "Gold-Keys")) | |
123 | |
124 | |
125 ;;; | |
126 ;;; Put headers in the Keys buffer | |
127 ;;; | |
128 (set-buffer "Keys") | |
129 (insert "\ | |
130 ;; Key definitions for TPU-edt | |
131 ;; | |
132 ") | |
133 | |
134 | |
135 ;;; | |
136 ;;; Display directions | |
137 ;;; | |
138 (switch-to-buffer "Directions") | |
139 (insert " | |
140 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. | |
142 | |
143 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 | |
145 by pressing any key you want at any prompt. If you want to entirely | |
146 omit a key, just press RETURN at the prompt. | |
147 | |
148 Here's a picture of the standard TPU/edt keypad for reference: | |
149 | |
150 _______________________ _______________________________ | |
151 | HELP | Do | | | | | | | |
152 |KeyDefs| | | | | | | | |
153 |_______|_______________| |_______|_______|_______|_______| | |
154 _______________________ _______________________________ | |
155 | Find |Insert |Remove | | Gold | HELP |FndNxt | Del L | | |
156 | | |Sto Tex| | key |E-Help | Find |Undel L| | |
157 |_______|_______|_______| |_______|_______|_______|_______| | |
158 |Select |Pre Scr|Nex Scr| | Page | Sect |Append | Del W | | |
159 | Reset |Pre Win|Nex Win| | Do | Fill |Replace|Undel W| | |
160 |_______|_______|_______| |_______|_______|_______|_______| | |
161 |Move up| |Forward|Reverse|Remove | Del C | | |
162 | Top | |Bottom | Top |Insert |Undel C| | |
163 _______|_______|_______ |_______|_______|_______|_______| | |
164 |Mov Lef|Mov Dow|Mov Rig| | Word | EOL | Char | | | |
165 |StaOfLi|Bottom |EndOfLi| |ChngCas|Del EOL|SpecIns| Enter | | |
166 |_______|_______|_______| |_______|_______|_______| | | |
167 | Line |Select | Subs | | |
168 | Open Line | Reset | | | |
169 |_______________|_______|_______| | |
170 | |
171 | |
172 ") | |
173 (delete-other-windows) | |
174 | |
175 ;;; | |
176 ;;; Save <CR> for future reference | |
177 ;;; | |
178 (cond | |
179 (tpu-lucid-emacs19-p | |
4525
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
180 (setq tpu-return-seq (read-key-sequence "Hit carriage-return <CR> to continue ")) |
4421 | 181 (setq tpu-return (concat "[" (format "%s" (event-key (aref tpu-return-seq 0))) "]"))) |
182 (t | |
4525
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
183 (message "Hit carriage-return <CR> to continue ") |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
184 (setq tpu-return-seq (read-event)) |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
185 (setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]")))) |
4421 | 186 |
187 | |
188 ;;; | |
189 ;;; Key mapping functions | |
190 ;;; | |
191 (defun tpu-lucid-map-key (ident descrip func gold-func) | |
192 (interactive) | |
193 (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))) "]")) | |
195 (cond ((not (equal tpu-key tpu-return)) | |
196 (set-buffer "Keys") | |
197 (insert (format"(global-set-key %s %s)\n" tpu-key func)) | |
198 (set-buffer "Gold-Keys") | |
199 (insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func)) | |
200 (set-buffer "Directions")) | |
201 ;; bogosity to get next prompt to come up, if the user hits <CR>! | |
202 ;; check periodically to see if this is still needed... | |
203 (t | |
204 (format "%s" tpu-key))) | |
205 tpu-key) | |
206 | |
207 (defun tpu-gnu-map-key (ident descrip func gold-func) | |
208 (interactive) | |
4525
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
209 (message "Press %s%s: " ident descrip) |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
210 (setq tpu-key-seq (read-event)) |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
211 (setq tpu-key (concat "[" (format "%s" tpu-key-seq) "]")) |
4421 | 212 (cond ((not (equal tpu-key tpu-return)) |
213 (set-buffer "Keys") | |
214 (insert (format"(global-set-key %s %s)\n" tpu-key func)) | |
215 (set-buffer "Gold-Keys") | |
216 (insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func)) | |
217 (set-buffer "Directions")) | |
218 ;; bogosity to get next prompt to come up, if the user hits <CR>! | |
219 ;; check periodically to see if this is still needed... | |
220 (t | |
221 (format "%s" tpu-key))) | |
222 tpu-key) | |
223 | |
224 (fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-gnu-map-key)) | |
225 | |
226 | |
227 (set-buffer "Keys") | |
228 (insert " | |
229 ;; Arrows | |
230 ;; | |
231 ") | |
232 (set-buffer "Gold-Keys") | |
233 (insert " | |
234 ;; GOLD Arrows | |
235 ;; | |
236 ") | |
237 (set-buffer "Directions") | |
238 | |
239 (tpu-map-key "Up-Arrow" "" "'tpu-previous-line" "'tpu-move-to-beginning") | |
240 (tpu-map-key "Down-arrow" "" "'tpu-next-line" "'tpu-move-to-end") | |
241 (tpu-map-key "Right-arrow" "" "'tpu-forward-char" "'end-of-line") | |
242 (tpu-map-key "Left-arrow" "" "'tpu-backward-char" "'beginning-of-line") | |
243 | |
244 | |
245 (set-buffer "Keys") | |
246 (insert " | |
247 ;; PF keys | |
248 ;; | |
249 ") | |
250 (set-buffer "Gold-Keys") | |
251 (insert " | |
252 ;; GOLD PF keys | |
253 ;; | |
254 ") | |
255 (set-buffer "Directions") | |
256 | |
257 (tpu-map-key "PF1" " - The GOLD key" "GOLD-map" "'keyboard-quit") | |
258 (tpu-map-key "PF2" " - The Keypad Help key" "'tpu-help" "'help-for-help") | |
259 (tpu-map-key "PF3" " - The Find/Find-Next key" "'tpu-search-again" "'tpu-search") | |
260 (tpu-map-key "PF4" " - The Del/Undelete Line key" "'tpu-delete-current-line" "'tpu-undelete-lines") | |
261 | |
262 (set-buffer "Keys") | |
263 (insert " | |
264 ;; KP0-9 KP- KP, KP. and KPenter | |
265 ;; | |
266 ") | |
267 (set-buffer "Gold-Keys") | |
268 (insert " | |
269 ;; GOLD KP0-9 KP- KP, and KPenter | |
270 ;; | |
271 ") | |
272 (set-buffer "Directions") | |
273 | |
274 (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") | |
276 (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") | |
278 (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") | |
280 (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") | |
282 (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") | |
284 (tpu-map-key "KP--" " - The Delete/Undelete Word key" "'tpu-delete-current-word" "'tpu-undelete-words") | |
285 (tpu-map-key "KP-," " - The Delete/Undelete Character key" "'tpu-delete-current-char" "'tpu-undelete-char") | |
286 (tpu-map-key "KP-." " - The Select/Reset key" "'tpu-select" "'tpu-unselect") | |
287 (tpu-map-key "KP-Enter" " - The Enter key on the numeric keypad" "'newline" "'tpu-substitute") | |
288 ;; Save the enter key | |
289 (setq tpu-enter tpu-key) | |
290 (setq tpu-enter-seq tpu-key-seq) | |
291 | |
292 (set-buffer "Keys") | |
293 (insert " | |
294 ;; Editing keypad (find, insert, remove) | |
295 ;; (select, prev, next) | |
296 ;; | |
297 ") | |
298 (set-buffer "Gold-Keys") | |
299 (insert " | |
300 ;; GOLD Editing keypad (find, insert, remove) | |
301 ;; (select, prev, next) | |
302 ;; | |
303 ") | |
304 (set-buffer "Directions") | |
305 | |
306 (tpu-map-key "Find" " - The Find key on the editing keypad" "'tpu-search" "'nil") | |
307 (tpu-map-key "Insert" " - The Insert key on the editing keypad" "'tpu-paste" "'nil") | |
308 (tpu-map-key "Remove" " - The Remove key on the editing keypad" "'tpu-cut" "'tpu-store-text") | |
309 (tpu-map-key "Select" " - The Select key on the editing keypad" "'tpu-select" "'tpu-unselect") | |
310 (tpu-map-key "Prev Scr" " - The Prev Scr key on the editing keypad" "'tpu-scroll-window-down" "'tpu-previous-window") | |
311 (tpu-map-key "Next Scr" " - The Next Scr key on the editing keypad" "'tpu-scroll-window-up" "'tpu-next-window") | |
312 | |
313 (set-buffer "Keys") | |
314 (insert " | |
315 ;; F10-14 Help Do F17 | |
316 ;; | |
317 ") | |
318 (set-buffer "Gold-Keys") | |
319 (insert " | |
320 ;; GOLD F10-14 Help Do F17 | |
321 ;; | |
322 ") | |
323 (set-buffer "Directions") | |
324 | |
325 (tpu-map-key "F10" " - Invokes the Exit function on VT200+ terminals" "'tpu-exit" "'nil") | |
326 (tpu-map-key "F11" " - Inserts an Escape character into the text" "'tpu-insert-escape" "'nil") | |
327 (tpu-map-key "Backspace" " - Not Delete nor ^H! Sometimes on the F12 key" "'tpu-next-beginning-of-line" "'nil") | |
328 (tpu-map-key "F13" " - Invokes the delete previous word function" "'tpu-delete-previous-word" "'nil") | |
329 (tpu-map-key "F14" " - Toggles insert/overstrike modes" "'tpu-toggle-overwrite-mode" "'nil") | |
330 (tpu-map-key "Help" " - Brings up the help screen, same as PF2" "'tpu-help" "'describe-bindings") | |
331 (tpu-map-key "Do" " - Invokes the COMMAND function" "'execute-extended-command" "'nil") | |
332 (tpu-map-key "F17" "" "'tpu-goto-breadcrumb" "'tpu-drop-breadcrumb") | |
333 | |
334 (set-buffer "Gold-Keys") | |
335 (cond | |
336 ((not (equal tpu-enter tpu-return)) | |
337 (insert " | |
338 ;; Minibuffer map additions to make KP_enter = RET | |
339 ;; | |
340 ") | |
341 | |
342 (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)) | |
344 (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)))) | |
346 | |
347 (insert " | |
348 ;; Define the tpu-help-enter/return symbols | |
349 ;; | |
350 ") | |
351 | |
4525
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
352 (cond (tpu-lucid-emacs19-p |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
353 (insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter-seq)) |
4548
fb0f96c4154b
Insert setqs for tpu-help-... variables.
Richard M. Stallman <rms@gnu.org>
parents:
4525
diff
changeset
|
354 (insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq)) |
fb0f96c4154b
Insert setqs for tpu-help-... variables.
Richard M. Stallman <rms@gnu.org>
parents:
4525
diff
changeset
|
355 (insert "(setq tpu-help-N \"[#<keypress-event N>]\")\n") |
fb0f96c4154b
Insert setqs for tpu-help-... variables.
Richard M. Stallman <rms@gnu.org>
parents:
4525
diff
changeset
|
356 (insert "(setq tpu-help-n \"[#<keypress-event n>]\")\n") |
fb0f96c4154b
Insert setqs for tpu-help-... variables.
Richard M. Stallman <rms@gnu.org>
parents:
4525
diff
changeset
|
357 (insert "(setq tpu-help-P \"[#<keypress-event P>]\")\n") |
fb0f96c4154b
Insert setqs for tpu-help-... variables.
Richard M. Stallman <rms@gnu.org>
parents:
4525
diff
changeset
|
358 (insert "(setq tpu-help-p \"[#<keypress-event p>]\")\n")) |
4525
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
359 (t |
03d1a39e66c9
(tpu-gnu-map-key): Repaired the key name
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
360 (insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter)))) |
4421 | 361 |
362 (append-to-buffer "Keys" 1 (point)) | |
363 (set-buffer "Keys") | |
364 | |
365 ;;; | |
366 ;;; Save the key mapping program and blow this pop stand | |
367 ;;; | |
368 (let ((file (if tpu-lucid-emacs19-p "~/.tpu-lucid-keys" "~/.tpu-gnu-keys"))) | |
369 (set-visited-file-name | |
370 (read-file-name (format "Save key mapping to file (default %s): " file) nil file))) | |
371 (save-buffer) | |
372 | |
373 (message "That's it! Press any key to exit") | |
374 (sit-for 600) | |
375 (kill-emacs t) | |
376 | |
377 ;;; tpu-mapper.el ends here |