Commit | Line | Data |
---|---|---|
be010748 | 1 | ;;; edt.el --- Enhanced EDT Keypad Mode Emulation for GNU Emacs 19 |
1a06eabd | 2 | |
3bef4fb9 | 3 | ;; Copyright (C) 1986, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
3a801d0c | 4 | |
3bef4fb9 KH |
5 | ;; Author: Kevin Gallagher <kgallagh@spd.dsccc.com> |
6 | ;; Maintainer: Kevin Gallagher <kgallagh@spd.dsccc.com> | |
fd7fa35a | 7 | ;; Keywords: emulations |
e5167999 | 8 | |
4bf7f5d1 RS |
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 | |
e5167999 | 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
4bf7f5d1 RS |
14 | ;; any later version. |
15 | ||
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. | |
24 | ||
3bef4fb9 KH |
25 | ;;; Usage: |
26 | ||
e4360875 | 27 | ;; See edt-user.doc in the Emacs etc directory. |
3bef4fb9 KH |
28 | |
29 | ;; ==================================================================== | |
30 | \f | |
31 | ;;; Electric Help functions are used for keypad help displays. A few | |
32 | ;;; picture functions are used in rectangular cut and paste commands. | |
33 | (require 'ehelp) | |
34 | (require 'picture) | |
35 | ||
36 | ;;;; | |
37 | ;;;; VARIABLES and CONSTANTS | |
38 | ;;;; | |
39 | ||
4bf7f5d1 | 40 | (defvar edt-last-deleted-lines "" |
3bef4fb9 KH |
41 | "Last text deleted by an EDT emulation line delete command.") |
42 | ||
4bf7f5d1 | 43 | (defvar edt-last-deleted-words "" |
3bef4fb9 KH |
44 | "Last text deleted by an EDT emulation word delete command.") |
45 | ||
4bf7f5d1 | 46 | (defvar edt-last-deleted-chars "" |
3bef4fb9 KH |
47 | "Last text deleted by an EDT emulation character delete command.") |
48 | ||
49 | (defvar edt-last-replaced-key-definition "" | |
50 | "Key definition replaced with edt-define-key or edt-learn command.") | |
51 | ||
52 | (defvar edt-direction-string "" | |
e4360875 | 53 | "String indicating current direction of movement.") |
3bef4fb9 KH |
54 | |
55 | (defvar edt-select-mode nil | |
e4360875 | 56 | "Non-nil means select mode is active.") |
3bef4fb9 KH |
57 | |
58 | (defvar edt-select-mode-text "" | |
e4360875 | 59 | "Text displayed in mode line when select mode is active.") |
3bef4fb9 KH |
60 | |
61 | (defconst edt-select-mode-string " Select" | |
e4360875 | 62 | "String to indicate select mode is active.") |
3bef4fb9 KH |
63 | |
64 | (defconst edt-forward-string " ADVANCE" | |
e4360875 | 65 | "Direction string in mode line to indicate forward movement.") |
3bef4fb9 KH |
66 | |
67 | (defconst edt-backward-string " BACKUP" | |
e4360875 | 68 | "Direction string in mode line to indicate backward movement.") |
3bef4fb9 KH |
69 | |
70 | (defvar edt-default-map-active nil | |
e4360875 KH |
71 | "Non-nil indicates that default EDT emulation key bindings are active. |
72 | Nil means user-defined custom bindings are active.") | |
3bef4fb9 KH |
73 | |
74 | (defvar edt-user-map-configured nil | |
e4360875 KH |
75 | "Non-nil indicates that user custom EDT key bindings are configured. |
76 | This means that an edt-user.el file was found in the user's load-path.") | |
3bef4fb9 KH |
77 | |
78 | (defvar edt-keep-current-page-delimiter nil | |
e4360875 KH |
79 | "Non-nil leaves current value of page-delimiter unchanged. |
80 | Nil causes the page-delimiter variable to be set to to \"\\f\" | |
81 | when edt-emulation-on is first invoked. Original value is restored | |
82 | when edt-emulation-off is called.") | |
3bef4fb9 KH |
83 | |
84 | (defvar edt-use-EDT-control-key-bindings nil | |
e4360875 KH |
85 | "Non-nil causes the control key bindings to be replaced with EDT bindings. |
86 | Nil (the default) means EDT control key bindings are not used and the current | |
87 | control key bindings are retained for use in the EDT emulation.") | |
3bef4fb9 KH |
88 | |
89 | (defvar edt-word-entities '(?\t) | |
e4360875 | 90 | "*Specifies the list of EDT word entity characters.") |
4bf7f5d1 | 91 | |
3bef4fb9 KH |
92 | ;;; |
93 | ;;; Emacs version identifiers - currently referenced by | |
94 | ;;; | |
95 | ;;; o edt-emulation-on o edt-load-xkeys | |
96 | ;;; | |
97 | (defconst edt-emacs19-p (not (string-lessp emacs-version "19")) | |
e4360875 | 98 | "Non-nil if we are running Lucid or GNU Emacs version 19.") |
3bef4fb9 KH |
99 | |
100 | (defconst edt-lucid-emacs19-p | |
101 | (and edt-emacs19-p (string-match "Lucid" emacs-version)) | |
e4360875 | 102 | "Non-nil if we are running Lucid Emacs version 19.") |
3bef4fb9 KH |
103 | |
104 | (defconst edt-gnu-emacs19-p (and edt-emacs19-p (not edt-lucid-emacs19-p)) | |
e4360875 | 105 | "Non-nil if we are running GNU Emacs version 19.") |
3bef4fb9 KH |
106 | |
107 | (defvar edt-xkeys-file nil | |
108 | "File mapping X function keys to LK-201 keyboard function and keypad keys.") | |
109 | \f | |
110 | ;;;; | |
111 | ;;;; EDT Emulation Commands | |
112 | ;;;; | |
113 | ||
114 | ;;; Almost all of EDT's keypad mode commands have equivalent | |
115 | ;;; counterparts in Emacs. Some behave the same way in Emacs as they | |
116 | ;;; do in EDT, but most do not. | |
117 | ;;; | |
118 | ;;; The following Emacs functions emulate, where practical, the exact | |
119 | ;;; behavior of the corresponding EDT keypad mode commands. In a few | |
120 | ;;; cases, the emulation is not exact, but it is close enough for most | |
121 | ;;; EDT die-hards. | |
122 | ;;; | |
123 | ;;; In a very few cases, we chose to use the superior Emacs way of | |
124 | ;;; handling things. For example, we do not emulate the EDT SUBS | |
125 | ;;; command. Instead, we chose to use the superior Emacs | |
126 | ;;; query-replace function. | |
127 | ;;; | |
128 | ||
129 | ;;; | |
130 | ;;; PAGE | |
131 | ;;; | |
132 | ;;; Emacs uses the regexp assigned to page-delimiter to determine what | |
133 | ;;; marks a page break. This is normally "^\f", which causes the | |
134 | ;;; edt-page command to ignore form feeds not located at the beginning | |
135 | ;;; of a line. To emulate the EDT PAGE command exactly, | |
136 | ;;; page-delimiter is set to "\f" when EDT emulation is turned on, and | |
137 | ;;; restored to its original value when EDT emulation is turned off. | |
138 | ;;; But this can be overridden if the EDT definition is not desired by | |
139 | ;;; placing | |
140 | ;;; | |
141 | ;;; (setq edt-keep-current-page-delimiter t) | |
142 | ;;; | |
143 | ;;; in your .emacs file. | |
144 | ||
145 | (defun edt-page-forward (num) | |
146 | "Move forward to just after next page delimiter. | |
147 | Accepts a positive prefix argument for the number of page delimiters to move." | |
148 | (interactive "p") | |
149 | (edt-check-prefix num) | |
150 | (if (eobp) | |
151 | (error "End of buffer") | |
152 | (progn | |
153 | (forward-page num) | |
154 | (if (eobp) | |
155 | (edt-line-to-bottom-of-window) | |
156 | (edt-line-to-top-of-window))))) | |
157 | ||
158 | (defun edt-page-backward (num) | |
159 | "Move backward to just after previous page delimiter. | |
160 | Accepts a positive prefix argument for the number of page delimiters to move." | |
161 | (interactive "p") | |
162 | (edt-check-prefix num) | |
163 | (if (bobp) | |
164 | (error "Beginning of buffer") | |
165 | (progn | |
166 | (backward-page num) | |
167 | (edt-line-to-top-of-window)))) | |
168 | ||
169 | (defun edt-page (num) | |
170 | "Move in current direction to next page delimiter. | |
171 | Accepts a positive prefix argument for the number of page delimiters to move." | |
4bf7f5d1 | 172 | (interactive "p") |
3bef4fb9 KH |
173 | (if (equal edt-direction-string edt-forward-string) |
174 | (edt-page-forward num) | |
175 | (edt-page-backward num))) | |
176 | ||
177 | ;;; | |
178 | ;;; SECT | |
179 | ;;; | |
180 | ;;; EDT defaults a section size to be 16 lines of its one and only | |
181 | ;;; 24-line window. That's two-thirds of the window at a time. The | |
182 | ;;; EDT SECT commands moves the cursor, not the window. | |
183 | ;;; | |
184 | ;;; This emulation of EDT's SECT moves the cursor approximately two-thirds | |
185 | ;;; of the current window at a time. | |
186 | ||
187 | (defun edt-sect-forward (num) | |
188 | "Move cursor forward two-thirds of a window. | |
189 | Accepts a positive prefix argument for the number of sections to move." | |
190 | (interactive "p") | |
191 | (edt-check-prefix num) | |
192 | (edt-line-forward (* (* (/ (- (window-height) 1) 3) 2) num))) | |
193 | ||
194 | (defun edt-sect-backward (num) | |
195 | "Move cursor backward two-thirds of a window. | |
196 | Accepts a positive prefix argument for the number of sections to move." | |
197 | (interactive "p") | |
198 | (edt-check-prefix num) | |
199 | (edt-line-backward (* (* (/ (- (window-height) 1) 3) 2) num))) | |
200 | ||
201 | (defun edt-sect (num) | |
202 | "Move in current direction a full window. | |
203 | Accepts a positive prefix argument for the number windows to move." | |
204 | (interactive "p") | |
205 | (if (equal edt-direction-string edt-forward-string) | |
206 | (edt-sect-forward num) | |
207 | (edt-sect-backward num))) | |
208 | ||
209 | ;;; | |
210 | ;;; BEGINNING OF LINE | |
211 | ;;; | |
212 | ;;; EDT's beginning-of-line command is not affected by current | |
213 | ;;; direction, for some unknown reason. | |
214 | ||
215 | (defun edt-beginning-of-line (num) | |
216 | "Move backward to next beginning of line mark. | |
217 | Accepts a positive prefix argument for the number of BOL marks to move." | |
218 | (interactive "p") | |
219 | (edt-check-prefix num) | |
220 | (if (bolp) | |
221 | (forward-line (* -1 num)) | |
222 | (progn | |
223 | (setq num (1- num)) | |
224 | (forward-line (* -1 num))))) | |
225 | ||
226 | ;;; | |
227 | ;;; EOL (End of Line) | |
228 | ;;; | |
229 | ||
230 | (defun edt-end-of-line-forward (num) | |
231 | "Move forward to next end of line mark. | |
232 | Accepts a positive prefix argument for the number of EOL marks to move." | |
233 | (interactive "p") | |
234 | (edt-check-prefix num) | |
235 | (forward-char) | |
236 | (end-of-line num)) | |
237 | ||
238 | (defun edt-end-of-line-backward (num) | |
239 | "Move backward to next end of line mark. | |
240 | Accepts a positive prefix argument for the number of EOL marks to move." | |
241 | (interactive "p") | |
242 | (edt-check-prefix num) | |
243 | (end-of-line (1- num))) | |
244 | ||
245 | (defun edt-end-of-line (num) | |
246 | "Move in current direction to next end of line mark. | |
247 | Accepts a positive prefix argument for the number of EOL marks to move." | |
248 | (interactive "p") | |
249 | (if (equal edt-direction-string edt-forward-string) | |
250 | (edt-end-of-line-forward num) | |
251 | (edt-end-of-line-backward num))) | |
252 | ||
253 | ;;; | |
254 | ;;; WORD | |
255 | ;;; | |
256 | ;;; This one is a tad messy. To emulate EDT's behavior everywhere in | |
257 | ;;; the file (beginning of file, end of file, beginning of line, end | |
258 | ;;; of line, etc.) it takes a bit of special handling. | |
259 | ;;; | |
260 | ;;; The variable edt-word-entities contains a list of characters which | |
261 | ;;; are to be viewed as distinct words where ever they appear in the | |
262 | ;;; buffer. This emulates the EDT line mode command SET ENTITY WORD. | |
263 | ||
264 | ||
265 | (defun edt-one-word-forward () | |
266 | "Move forward to first character of next word." | |
267 | (interactive) | |
268 | (if (eobp) | |
269 | (error "End of buffer")) | |
270 | (if (eolp) | |
271 | (forward-char) | |
272 | (progn | |
273 | (if (memq (following-char) edt-word-entities) | |
274 | (forward-char) | |
275 | (while (and | |
276 | (not (eolp)) | |
277 | (not (eobp)) | |
278 | (not (eq ?\ (char-syntax (following-char)))) | |
279 | (not (memq (following-char) edt-word-entities))) | |
280 | (forward-char))) | |
281 | (while (and | |
282 | (not (eolp)) | |
283 | (not (eobp)) | |
284 | (eq ?\ (char-syntax (following-char))) | |
285 | (not (memq (following-char) edt-word-entities))) | |
286 | (forward-char))))) | |
287 | ||
288 | (defun edt-one-word-backward () | |
289 | "Move backward to first character of previous word." | |
290 | (interactive) | |
291 | (if (bobp) | |
292 | (error "Beginning of buffer")) | |
293 | (if (bolp) | |
294 | (backward-char) | |
295 | (progn | |
296 | (backward-char) | |
297 | (while (and | |
298 | (not (bolp)) | |
299 | (not (bobp)) | |
300 | (eq ?\ (char-syntax (following-char))) | |
301 | (not (memq (following-char) edt-word-entities))) | |
302 | (backward-char)) | |
303 | (if (not (memq (following-char) edt-word-entities)) | |
304 | (while (and | |
305 | (not (bolp)) | |
306 | (not (bobp)) | |
307 | (not (eq ?\ (char-syntax (preceding-char)))) | |
308 | (not (memq (preceding-char) edt-word-entities))) | |
309 | (backward-char)))))) | |
310 | ||
311 | (defun edt-word-forward (num) | |
312 | "Move forward to first character of next word. | |
313 | Accepts a positive prefix argument for the number of words to move." | |
314 | (interactive "p") | |
315 | (edt-check-prefix num) | |
316 | (while (> num 0) | |
317 | (edt-one-word-forward) | |
318 | (setq num (1- num)))) | |
319 | ||
320 | (defun edt-word-backward (num) | |
321 | "Move backward to first character of previous word. | |
322 | Accepts a positive prefix argument for the number of words to move." | |
323 | (interactive "p") | |
324 | (edt-check-prefix num) | |
325 | (while (> num 0) | |
326 | (edt-one-word-backward) | |
327 | (setq num (1- num)))) | |
328 | ||
329 | (defun edt-word (num) | |
330 | "Move in current direction to first character of next word. | |
331 | Accepts a positive prefix argument for the number of words to move." | |
332 | (interactive "p") | |
333 | (if (equal edt-direction-string edt-forward-string) | |
334 | (edt-word-forward num) | |
335 | (edt-word-backward num))) | |
336 | ||
337 | ;;; | |
338 | ;;; CHAR | |
339 | ;;; | |
340 | ||
341 | (defun edt-character (num) | |
342 | "Move in current direction to next character. | |
343 | Accepts a positive prefix argument for the number of characters to move." | |
344 | (interactive "p") | |
345 | (edt-check-prefix num) | |
346 | (if (equal edt-direction-string edt-forward-string) | |
347 | (forward-char num) | |
348 | (backward-char num))) | |
349 | ||
350 | ;;; | |
351 | ;;; LINE | |
352 | ;;; | |
353 | ;;; When direction is set to BACKUP, LINE behaves just like BEGINNING | |
354 | ;;; OF LINE in EDT. So edt-line-backward is not really needed as a | |
355 | ;;; separate function. | |
356 | ||
357 | (defun edt-line-backward (num) | |
358 | "Move backward to next beginning of line mark. | |
359 | Accepts a positive prefix argument for the number of BOL marks to move." | |
360 | (interactive "p") | |
361 | (edt-beginning-of-line num)) | |
362 | ||
363 | (defun edt-line-forward (num) | |
364 | "Move forward to next beginning of line mark. | |
365 | Accepts a positive prefix argument for the number of BOL marks to move." | |
366 | (interactive "p") | |
367 | (edt-check-prefix num) | |
368 | (forward-line num)) | |
369 | ||
370 | (defun edt-line (num) | |
371 | "Move in current direction to next beginning of line mark. | |
372 | Accepts a positive prefix argument for the number of BOL marks to move." | |
373 | (interactive "p") | |
374 | (if (equal edt-direction-string edt-forward-string) | |
375 | (edt-line-forward num) | |
376 | (edt-line-backward num))) | |
377 | ||
378 | ;;; | |
379 | ;;; TOP | |
380 | ;;; | |
381 | ||
382 | (defun edt-top () | |
383 | "Move cursor to the beginning of buffer." | |
384 | (interactive) | |
385 | (goto-char (point-min))) | |
386 | ||
387 | ;;; | |
388 | ;;; BOTTOM | |
389 | ;;; | |
390 | ||
391 | (defun edt-bottom () | |
392 | "Move cursor to the end of buffer." | |
393 | (interactive) | |
394 | (goto-char (point-max)) | |
395 | (edt-line-to-bottom-of-window)) | |
396 | ||
397 | ;;; | |
398 | ;;; FIND | |
399 | ;;; | |
400 | ||
401 | (defun edt-find-forward (&optional find) | |
896b7329 | 402 | "Find first occurrence of a string in forward direction and save it." |
3bef4fb9 KH |
403 | (interactive) |
404 | (if (not find) | |
405 | (set 'search-last-string (read-string "Search forward: "))) | |
406 | (if (search-forward search-last-string) | |
407 | (search-backward search-last-string))) | |
408 | ||
409 | (defun edt-find-backward (&optional find) | |
896b7329 | 410 | "Find first occurrence of a string in the backward direction and save it." |
3bef4fb9 KH |
411 | (interactive) |
412 | (if (not find) | |
413 | (set 'search-last-string (read-string "Search backward: "))) | |
414 | (search-backward search-last-string)) | |
415 | ||
416 | (defun edt-find () | |
896b7329 | 417 | "Find first occurrence of string in current direction and save it." |
3bef4fb9 KH |
418 | (interactive) |
419 | (set 'search-last-string (read-string "Search: ")) | |
420 | (if (equal edt-direction-string edt-forward-string) | |
421 | (edt-find-forward t) | |
422 | (edt-find-backward t))) | |
423 | ||
424 | ||
425 | ;;; | |
426 | ;;; FNDNXT | |
427 | ;;; | |
428 | ||
429 | (defun edt-find-next-forward () | |
896b7329 | 430 | "Find next occurrence of a string in forward direction." |
3bef4fb9 KH |
431 | (interactive) |
432 | (forward-char 1) | |
433 | (if (search-forward search-last-string nil t) | |
434 | (search-backward search-last-string) | |
435 | (progn | |
436 | (backward-char 1) | |
437 | (error "Search failed: \"%s\"." search-last-string)))) | |
438 | ||
439 | (defun edt-find-next-backward () | |
896b7329 | 440 | "Find next occurrence of a string in backward direction." |
3bef4fb9 KH |
441 | (interactive) |
442 | (if (eq (search-backward search-last-string nil t) nil) | |
443 | (progn | |
444 | (error "Search failed: \"%s\"." search-last-string)))) | |
445 | ||
446 | (defun edt-find-next () | |
896b7329 | 447 | "Find next occurrence of a string in current direction." |
3bef4fb9 KH |
448 | (interactive) |
449 | (if (equal edt-direction-string edt-forward-string) | |
450 | (edt-find-next-forward) | |
451 | (edt-find-next-backward))) | |
452 | ||
453 | ;;; | |
454 | ;;; APPEND | |
455 | ;;; | |
456 | ||
457 | (defun edt-append () | |
458 | "Append this kill region to last killed region." | |
459 | (interactive "*") | |
460 | (edt-check-selection) | |
461 | (append-next-kill) | |
462 | (kill-region (mark) (point)) | |
463 | (message "Selected text APPENDED to kill ring")) | |
464 | ||
465 | ;;; | |
466 | ;;; DEL L | |
467 | ;;; | |
468 | ||
469 | (defun edt-delete-line (num) | |
470 | "Delete from cursor up to and including the end of line mark. | |
471 | Accepts a positive prefix argument for the number of lines to delete." | |
472 | (interactive "*p") | |
473 | (edt-check-prefix num) | |
4bf7f5d1 RS |
474 | (let ((beg (point))) |
475 | (forward-line num) | |
476 | (if (not (eq (preceding-char) ?\n)) | |
3bef4fb9 | 477 | (insert "\n")) |
4bf7f5d1 | 478 | (setq edt-last-deleted-lines |
3bef4fb9 | 479 | (buffer-substring beg (point))) |
4bf7f5d1 RS |
480 | (delete-region beg (point)))) |
481 | ||
3bef4fb9 KH |
482 | ;;; |
483 | ;;; DEL EOL | |
484 | ;;; | |
485 | ||
486 | (defun edt-delete-to-end-of-line (num) | |
487 | "Delete from cursor up to but excluding the end of line mark. | |
488 | Accepts a positive prefix argument for the number of lines to delete." | |
489 | (interactive "*p") | |
490 | (edt-check-prefix num) | |
4bf7f5d1 RS |
491 | (let ((beg (point))) |
492 | (forward-char 1) | |
493 | (end-of-line num) | |
494 | (setq edt-last-deleted-lines | |
3bef4fb9 | 495 | (buffer-substring beg (point))) |
4bf7f5d1 RS |
496 | (delete-region beg (point)))) |
497 | ||
3bef4fb9 KH |
498 | ;;; |
499 | ;;; SELECT | |
500 | ;;; | |
501 | ||
502 | (defun edt-select-mode (arg) | |
e4360875 | 503 | "Turn EDT select mode off if ARG is nil; otherwise, turn EDT select mode on. |
3bef4fb9 KH |
504 | In select mode, selected text is highlighted." |
505 | (if arg | |
506 | (progn | |
507 | (make-local-variable 'edt-select-mode) | |
508 | (setq edt-select-mode 'edt-select-mode-text) | |
509 | (setq rect-start-point (window-point))) | |
510 | (progn | |
511 | (kill-local-variable 'edt-select-mode))) | |
512 | (force-mode-line-update)) | |
513 | ||
514 | (defun edt-select () | |
515 | "Set mark at cursor and start text selection." | |
516 | (interactive) | |
517 | (set-mark-command nil)) | |
518 | ||
519 | (defun edt-reset () | |
520 | "Cancel text selection." | |
521 | (interactive) | |
522 | (deactivate-mark)) | |
523 | ||
524 | ;;; | |
525 | ;;; CUT | |
526 | ;;; | |
527 | ||
528 | (defun edt-cut () | |
529 | "Deletes selected text but copies to kill ring." | |
530 | (interactive "*") | |
531 | (edt-check-selection) | |
532 | (kill-region (mark) (point)) | |
533 | (message "Selected text CUT to kill ring")) | |
534 | ||
535 | ;;; | |
536 | ;;; DELETE TO BEGINNING OF LINE | |
537 | ;;; | |
538 | ||
539 | (defun edt-delete-to-beginning-of-line (num) | |
e4360875 | 540 | "Delete from cursor to beginning of line. |
3bef4fb9 KH |
541 | Accepts a positive prefix argument for the number of lines to delete." |
542 | (interactive "*p") | |
543 | (edt-check-prefix num) | |
4bf7f5d1 | 544 | (let ((beg (point))) |
3bef4fb9 KH |
545 | (edt-beginning-of-line num) |
546 | (setq edt-last-deleted-lines | |
547 | (buffer-substring (point) beg)) | |
4bf7f5d1 RS |
548 | (delete-region beg (point)))) |
549 | ||
3bef4fb9 KH |
550 | ;;; |
551 | ;;; DEL W | |
552 | ;;; | |
553 | ||
554 | (defun edt-delete-word (num) | |
555 | "Delete from cursor up to but excluding first character of next word. | |
556 | Accepts a positive prefix argument for the number of words to delete." | |
557 | (interactive "*p") | |
558 | (edt-check-prefix num) | |
4bf7f5d1 | 559 | (let ((beg (point))) |
3bef4fb9 KH |
560 | (edt-word-forward num) |
561 | (setq edt-last-deleted-words (buffer-substring beg (point))) | |
4bf7f5d1 RS |
562 | (delete-region beg (point)))) |
563 | ||
3bef4fb9 KH |
564 | ;;; |
565 | ;;; DELETE TO BEGINNING OF WORD | |
566 | ;;; | |
567 | ||
568 | (defun edt-delete-to-beginning-of-word (num) | |
569 | "Delete from cursor to beginning of word. | |
570 | Accepts a positive prefix argument for the number of words to delete." | |
571 | (interactive "*p") | |
572 | (edt-check-prefix num) | |
573 | (let ((beg (point))) | |
574 | (edt-word-backward num) | |
575 | (setq edt-last-deleted-words (buffer-substring (point) beg)) | |
576 | (delete-region beg (point)))) | |
577 | ||
578 | ;;; | |
579 | ;;; DEL C | |
580 | ;;; | |
581 | ||
582 | (defun edt-delete-character (num) | |
583 | "Delete character under cursor. | |
584 | Accepts a positive prefix argument for the number of characters to delete." | |
585 | (interactive "*p") | |
586 | (edt-check-prefix num) | |
4bf7f5d1 | 587 | (setq edt-last-deleted-chars |
3bef4fb9 | 588 | (buffer-substring (point) (min (point-max) (+ (point) num)))) |
4bf7f5d1 RS |
589 | (delete-region (point) (min (point-max) (+ (point) num)))) |
590 | ||
3bef4fb9 KH |
591 | ;;; |
592 | ;;; DELETE CHAR | |
593 | ;;; | |
594 | ||
595 | (defun edt-delete-previous-character (num) | |
596 | "Delete character in front of cursor. | |
597 | Accepts a positive prefix argument for the number of characters to delete." | |
598 | (interactive "*p") | |
599 | (edt-check-prefix num) | |
4bf7f5d1 | 600 | (setq edt-last-deleted-chars |
3bef4fb9 | 601 | (buffer-substring (max (point-min) (- (point) num)) (point))) |
4bf7f5d1 RS |
602 | (delete-region (max (point-min) (- (point) num)) (point))) |
603 | ||
3bef4fb9 KH |
604 | ;;; |
605 | ;;; UND L | |
606 | ;;; | |
607 | ||
608 | (defun edt-undelete-line () | |
609 | "Undelete previous deleted line(s)." | |
610 | (interactive "*") | |
611 | (point-to-register 1) | |
612 | (insert edt-last-deleted-lines) | |
613 | (register-to-point 1)) | |
614 | ||
615 | ;;; | |
616 | ;;; UND W | |
617 | ;;; | |
618 | ||
619 | (defun edt-undelete-word () | |
e4360875 | 620 | "Undelete previous deleted word(s)." |
3bef4fb9 KH |
621 | (interactive "*") |
622 | (point-to-register 1) | |
623 | (insert edt-last-deleted-words) | |
624 | (register-to-point 1)) | |
625 | ||
626 | ;;; | |
627 | ;;; UND C | |
628 | ;;; | |
629 | ||
630 | (defun edt-undelete-character () | |
e4360875 | 631 | "Undelete previous deleted character(s)." |
3bef4fb9 KH |
632 | (interactive "*") |
633 | (point-to-register 1) | |
634 | (insert edt-last-deleted-chars) | |
635 | (register-to-point 1)) | |
636 | ||
637 | ;;; | |
638 | ;;; REPLACE | |
639 | ;;; | |
640 | ||
641 | (defun edt-replace () | |
642 | "Replace marked section with last CUT (killed) text." | |
643 | (interactive "*") | |
644 | (exchange-point-and-mark) | |
645 | (let ((beg (point))) | |
646 | (exchange-point-and-mark) | |
647 | (delete-region beg (point))) | |
648 | (yank)) | |
649 | ||
650 | ;;; | |
651 | ;;; ADVANCE | |
652 | ;;; | |
653 | ||
654 | (defun edt-advance () | |
e4360875 KH |
655 | "Set movement direction forward. |
656 | Also, execute command specified if in Minibuffer." | |
4bf7f5d1 | 657 | (interactive) |
3bef4fb9 | 658 | (setq edt-direction-string edt-forward-string) |
ca341104 | 659 | (force-mode-line-update) |
3bef4fb9 KH |
660 | (if (string-equal " *Minibuf" |
661 | (substring (buffer-name) 0 (min (length (buffer-name)) 9))) | |
662 | (exit-minibuffer))) | |
663 | ||
664 | ;;; | |
665 | ;;; BACKUP | |
666 | ;;; | |
4bf7f5d1 | 667 | |
3bef4fb9 | 668 | (defun edt-backup () |
e4360875 KH |
669 | "Set movement direction backward. |
670 | Also, execute command specified if in Minibuffer." | |
4bf7f5d1 | 671 | (interactive) |
3bef4fb9 | 672 | (setq edt-direction-string edt-backward-string) |
ca341104 | 673 | (force-mode-line-update) |
3bef4fb9 KH |
674 | (if (string-equal " *Minibuf" |
675 | (substring (buffer-name) 0 (min (length (buffer-name)) 9))) | |
676 | (exit-minibuffer))) | |
677 | ||
678 | ;;; | |
679 | ;;; CHNGCASE | |
680 | ;;; | |
681 | ;; This function is based upon Jeff Kowalski's case-flip function in his | |
682 | ;; tpu.el. | |
683 | ||
684 | (defun edt-change-case (num) | |
685 | "Change the case of specified characters. | |
686 | If text selection IS active, then characters between the cursor and mark are | |
687 | changed. If text selection is NOT active, there are two cases. First, if the | |
688 | current direction is ADVANCE, then the prefix number of character(s) under and | |
689 | following cursor are changed. Second, if the current direction is BACKUP, then | |
690 | the prefix number of character(s) before the cursor are changed. Accepts a | |
691 | positive prefix for the number of characters to change, but the prefix is | |
692 | ignored if text selection is active." | |
693 | (interactive "*p") | |
694 | (edt-check-prefix num) | |
695 | (if edt-select-mode | |
696 | (let ((end (max (mark) (point))) | |
697 | (point-save (point))) | |
698 | (goto-char (min (point) (mark))) | |
699 | (while (not (eq (point) end)) | |
700 | (funcall (if (<= ?a (following-char)) | |
701 | 'upcase-region 'downcase-region) | |
702 | (point) (1+ (point))) | |
703 | (forward-char 1)) | |
704 | (goto-char point-save)) | |
705 | (progn | |
706 | (if (string= edt-direction-string edt-backward-string) | |
707 | (backward-char num)) | |
708 | (while (> num 0) | |
709 | (funcall (if (<= ?a (following-char)) | |
710 | 'upcase-region 'downcase-region) | |
711 | (point) (1+ (point))) | |
712 | (forward-char 1) | |
713 | (setq num (1- num)))))) | |
4bf7f5d1 | 714 | |
3bef4fb9 KH |
715 | ;;; |
716 | ;;; DEFINE KEY | |
717 | ;;; | |
718 | ||
719 | (defun edt-define-key () | |
720 | "Assign an interactively-callable function to a specified key sequence. | |
721 | The current key definition is saved in edt-last-replaced-key-definition. | |
722 | Use edt-restore-key to restore last replaced key definition." | |
4bf7f5d1 | 723 | (interactive) |
3bef4fb9 KH |
724 | (let (edt-function |
725 | edt-key-definition-string) | |
726 | (setq edt-key-definition-string | |
727 | (read-key-sequence "Press the key to be defined: ")) | |
728 | (if (string-equal "\C-m" edt-key-definition-string) | |
729 | (message "Key not defined") | |
730 | (progn | |
731 | (setq edt-function (read-command "Enter command name: ")) | |
732 | (if (string-equal "" edt-function) | |
733 | (message "Key not defined") | |
734 | (progn | |
735 | (setq edt-last-replaced-key-definition | |
736 | (lookup-key (current-global-map) edt-key-definition-string)) | |
737 | (define-key (current-global-map) | |
738 | edt-key-definition-string edt-function))))))) | |
4bf7f5d1 | 739 | |
3bef4fb9 KH |
740 | ;;; |
741 | ;;; FORM FEED INSERT | |
742 | ;;; | |
4bf7f5d1 | 743 | |
3bef4fb9 KH |
744 | (defun edt-form-feed-insert (num) |
745 | "Insert form feed character at cursor position. | |
746 | Accepts a positive prefix argument for the number of form feeds to insert." | |
747 | (interactive "*p") | |
748 | (edt-check-prefix num) | |
749 | (while (> num 0) | |
750 | (insert ?\f) | |
751 | (setq num (1- num)))) | |
4bf7f5d1 | 752 | |
3bef4fb9 KH |
753 | ;;; |
754 | ;;; TAB INSERT | |
755 | ;;; | |
4bf7f5d1 | 756 | |
3bef4fb9 KH |
757 | (defun edt-tab-insert (num) |
758 | "Insert tab character at cursor position. | |
759 | Accepts a positive prefix argument for the number of tabs to insert." | |
760 | (interactive "*p") | |
761 | (edt-check-prefix num) | |
762 | (while (> num 0) | |
763 | (insert ?\t) | |
764 | (setq num (1- num)))) | |
765 | ||
766 | ;;; | |
767 | ;;; Check Prefix | |
768 | ;;; | |
769 | ||
770 | (defun edt-check-prefix (num) | |
771 | "Indicate error if prefix is not positive." | |
772 | (if (<= num 0) | |
773 | (error "Prefix must be positive"))) | |
774 | ||
775 | ;;; | |
776 | ;;; Check Selection | |
777 | ;;; | |
778 | ||
779 | (defun edt-check-selection () | |
780 | "Indicate error if EDT selection is not active." | |
781 | (if (not edt-select-mode) | |
782 | (error "Selection NOT active"))) | |
783 | \f | |
784 | ;;;; | |
785 | ;;;; ENHANCEMENTS AND ADDITIONS FOR EDT KEYPAD MODE | |
786 | ;;;; | |
787 | ||
788 | ;;; | |
789 | ;;; Several enhancements and additions to EDT keypad mode commands are | |
790 | ;;; provided here. Some of these have been motivated by similar | |
791 | ;;; TPU/EVE and EVE-Plus commands. Others are new. | |
792 | ||
3bef4fb9 KH |
793 | ;;; |
794 | ;;; CHANGE DIRECTION | |
795 | ;;; | |
4bf7f5d1 | 796 | |
3bef4fb9 KH |
797 | (defun edt-change-direction () |
798 | "Toggle movement direction." | |
799 | (interactive) | |
800 | (if (equal edt-direction-string edt-forward-string) | |
801 | (edt-backup) | |
802 | (edt-advance))) | |
803 | ||
804 | ;;; | |
805 | ;;; TOGGLE SELECT | |
806 | ;;; | |
807 | ||
808 | (defun edt-toggle-select () | |
809 | "Toggle to start (or cancel) text selection." | |
810 | (interactive) | |
811 | (if edt-select-mode | |
812 | (edt-reset) | |
813 | (edt-select))) | |
814 | ||
815 | ;;; | |
816 | ;;; SENTENCE | |
817 | ;;; | |
818 | ||
819 | (defun edt-sentence-forward (num) | |
820 | "Move forward to start of next sentence. | |
821 | Accepts a positive prefix argument for the number of sentences to move." | |
4bf7f5d1 | 822 | (interactive "p") |
3bef4fb9 KH |
823 | (edt-check-prefix num) |
824 | (if (eobp) | |
825 | (progn | |
826 | (error "End of buffer")) | |
827 | (progn | |
828 | (forward-sentence num) | |
829 | (edt-one-word-forward)))) | |
4bf7f5d1 | 830 | |
3bef4fb9 KH |
831 | (defun edt-sentence-backward (num) |
832 | "Move backward to next sentence beginning. | |
833 | Accepts a positive prefix argument for the number of sentences to move." | |
4bf7f5d1 | 834 | (interactive "p") |
3bef4fb9 KH |
835 | (edt-check-prefix num) |
836 | (if (eobp) | |
837 | (progn | |
838 | (error "End of buffer")) | |
839 | (backward-sentence num))) | |
4bf7f5d1 | 840 | |
3bef4fb9 KH |
841 | (defun edt-sentence (num) |
842 | "Move in current direction to next sentence. | |
843 | Accepts a positive prefix argument for the number of sentences to move." | |
4bf7f5d1 | 844 | (interactive "p") |
3bef4fb9 KH |
845 | (if (equal edt-direction-string edt-forward-string) |
846 | (edt-sentence-forward num) | |
847 | (edt-sentence-backward num))) | |
848 | ||
849 | ;;; | |
850 | ;;; PARAGRAPH | |
851 | ;;; | |
4bf7f5d1 | 852 | |
3bef4fb9 KH |
853 | (defun edt-paragraph-forward (num) |
854 | "Move forward to beginning of paragraph. | |
855 | Accepts a positive prefix argument for the number of paragraphs to move." | |
4bf7f5d1 | 856 | (interactive "p") |
3bef4fb9 | 857 | (edt-check-prefix num) |
4bf7f5d1 RS |
858 | (while (> num 0) |
859 | (next-line 1) | |
860 | (forward-paragraph) | |
861 | (previous-line 1) | |
3bef4fb9 KH |
862 | (if (eolp) |
863 | (next-line 1)) | |
4bf7f5d1 RS |
864 | (setq num (1- num)))) |
865 | ||
3bef4fb9 KH |
866 | (defun edt-paragraph-backward (num) |
867 | "Move backward to beginning of paragraph. | |
868 | Accepts a positive prefix argument for the number of paragraphs to move." | |
4bf7f5d1 | 869 | (interactive "p") |
3bef4fb9 | 870 | (edt-check-prefix num) |
4bf7f5d1 RS |
871 | (while (> num 0) |
872 | (backward-paragraph) | |
873 | (previous-line 1) | |
874 | (if (eolp) (next-line 1)) | |
875 | (setq num (1- num)))) | |
876 | ||
3bef4fb9 KH |
877 | (defun edt-paragraph (num) |
878 | "Move in current direction to next paragraph. | |
879 | Accepts a positive prefix argument for the number of paragraph to move." | |
880 | (interactive "p") | |
881 | (if (equal edt-direction-string edt-forward-string) | |
882 | (edt-paragraph-forward num) | |
883 | (edt-paragraph-backward num))) | |
884 | ||
885 | ;;; | |
886 | ;;; RESTORE KEY | |
887 | ;;; | |
888 | ||
889 | (defun edt-restore-key () | |
e4360875 KH |
890 | "Restore last replaced key definition. |
891 | Definition is stored in edt-last-replaced-key-definition." | |
4bf7f5d1 | 892 | (interactive) |
3bef4fb9 KH |
893 | (if edt-last-replaced-key-definition |
894 | (progn | |
895 | (let (edt-key-definition-string) | |
896 | (set 'edt-key-definition-string | |
897 | (read-key-sequence "Press the key to be restored: ")) | |
898 | (if (string-equal "\C-m" edt-key-definition-string) | |
899 | (message "Key not restored") | |
900 | (define-key (current-global-map) | |
901 | edt-key-definition-string edt-last-replaced-key-definition)))) | |
902 | (error "No replaced key definition to restore!"))) | |
903 | ||
904 | ;;; | |
905 | ;;; WINDOW TOP | |
906 | ;;; | |
4bf7f5d1 | 907 | |
3bef4fb9 KH |
908 | (defun edt-window-top () |
909 | "Move the cursor to the top of the window." | |
4bf7f5d1 | 910 | (interactive) |
3bef4fb9 KH |
911 | (let ((start-column (current-column))) |
912 | (move-to-window-line 0) | |
913 | (move-to-column start-column))) | |
4bf7f5d1 | 914 | |
3bef4fb9 KH |
915 | ;;; |
916 | ;;; WINDOW BOTTOM | |
917 | ;;; | |
4bf7f5d1 | 918 | |
3bef4fb9 KH |
919 | (defun edt-window-bottom () |
920 | "Move the cursor to the bottom of the window." | |
921 | (interactive) | |
922 | (let ((start-column (current-column))) | |
923 | (move-to-window-line (- (window-height) 2)) | |
924 | (move-to-column start-column))) | |
925 | ||
926 | ;;; | |
927 | ;;; SCROLL WINDOW LINE | |
928 | ;;; | |
929 | ||
930 | (defun edt-scroll-window-forward-line () | |
e4360875 | 931 | "Move window forward one line leaving cursor at position in window." |
3bef4fb9 KH |
932 | (interactive) |
933 | (scroll-up 1)) | |
934 | ||
935 | (defun edt-scroll-window-backward-line () | |
e4360875 | 936 | "Move window backward one line leaving cursor at position in window." |
3bef4fb9 KH |
937 | (interactive) |
938 | (scroll-down 1)) | |
939 | ||
940 | (defun edt-scroll-line () | |
941 | "Move window one line in current direction." | |
942 | (interactive) | |
943 | (if (equal edt-direction-string edt-forward-string) | |
944 | (edt-scroll-window-forward-line) | |
945 | (edt-scroll-window-backward-line))) | |
4bf7f5d1 | 946 | |
3bef4fb9 KH |
947 | ;;; |
948 | ;;; SCROLL WINDOW | |
949 | ;;; | |
950 | ;;; Scroll a window (less one line) at a time. Leave cursor in center of | |
951 | ;;; window. | |
952 | ||
953 | (defun edt-scroll-window-forward (num) | |
954 | "Scroll forward one window in buffer, less one line. | |
955 | Accepts a positive prefix argument for the number of windows to move." | |
956 | (interactive "p") | |
957 | (edt-check-prefix num) | |
958 | (scroll-up (- (* (window-height) num) 2)) | |
959 | (edt-line-forward (/ (- (window-height) 1) 2))) | |
960 | ||
961 | (defun edt-scroll-window-backward (num) | |
962 | "Scroll backward one window in buffer, less one line. | |
963 | Accepts a positive prefix argument for the number of windows to move." | |
964 | (interactive "p") | |
965 | (edt-check-prefix num) | |
966 | (scroll-down (- (* (window-height) num) 2)) | |
967 | (edt-line-backward (/ (- (window-height) 1) 2))) | |
968 | ||
969 | (defun edt-scroll-window (num) | |
970 | "Scroll one window in buffer, less one line, in current direction. | |
971 | Accepts a positive prefix argument for the number windows to move." | |
972 | (interactive "p") | |
973 | (if (equal edt-direction-string edt-forward-string) | |
974 | (edt-scroll-window-forward num) | |
975 | (edt-scroll-window-backward num))) | |
976 | ||
977 | ;;; | |
978 | ;;; LINE TO BOTTOM OF WINDOW | |
979 | ;;; | |
4bf7f5d1 RS |
980 | |
981 | (defun edt-line-to-bottom-of-window () | |
3bef4fb9 | 982 | "Move the current line to the bottom of the window." |
4bf7f5d1 RS |
983 | (interactive) |
984 | (recenter -1)) | |
985 | ||
3bef4fb9 KH |
986 | ;;; |
987 | ;;; LINE TO TOP OF WINDOW | |
988 | ;;; | |
989 | ||
4bf7f5d1 RS |
990 | (defun edt-line-to-top-of-window () |
991 | "Move the current line to the top of the window." | |
992 | (interactive) | |
993 | (recenter 0)) | |
994 | ||
3bef4fb9 KH |
995 | ;;; |
996 | ;;; LINE TO MIDDLE OF WINDOW | |
997 | ;;; | |
4bf7f5d1 | 998 | |
3bef4fb9 KH |
999 | (defun edt-line-to-middle-of-window () |
1000 | "Move window so line with cursor is in the middle of the window." | |
4bf7f5d1 | 1001 | (interactive) |
3bef4fb9 KH |
1002 | (recenter '(4))) |
1003 | ||
1004 | ;;; | |
1005 | ;;; GOTO PERCENTAGE | |
1006 | ;;; | |
1007 | ||
1008 | (defun edt-goto-percentage (num) | |
1009 | "Move to specified percentage in buffer from top of buffer." | |
1010 | (interactive "NGoto-percentage: ") | |
1011 | (if (or (> num 100) (< num 0)) | |
1012 | (error "Percentage %d out of range 0 < percent < 100" num) | |
1013 | (goto-char (/ (* (point-max) num) 100)))) | |
1014 | ||
1015 | ;;; | |
1016 | ;;; FILL REGION | |
1017 | ;;; | |
1018 | ||
1019 | (defun edt-fill-region () | |
1020 | "Fill selected text." | |
1021 | (interactive "*") | |
1022 | (edt-check-selection) | |
1023 | (fill-region (point) (mark))) | |
1024 | ||
1025 | ;;; | |
1026 | ;;; INDENT OR FILL REGION | |
1027 | ;;; | |
1028 | ||
1029 | (defun edt-indent-or-fill-region () | |
1030 | "Fill region in text modes, indent region in programming language modes." | |
1031 | (interactive "*") | |
dabbbb65 | 1032 | (if (string= paragraph-start "$\\|\f") |
4bf7f5d1 | 1033 | (indent-region (point) (mark) nil) |
3bef4fb9 | 1034 | (fill-region (point) (mark)))) |
4bf7f5d1 | 1035 | |
3bef4fb9 KH |
1036 | ;;; |
1037 | ;;; MARK SECTION WISELY | |
1038 | ;;; | |
1039 | ||
1040 | (defun edt-mark-section-wisely () | |
4bf7f5d1 | 1041 | "Mark the section in a manner consistent with the major-mode. |
3bef4fb9 | 1042 | Uses mark-defun for emacs-lisp and lisp, |
4bf7f5d1 | 1043 | mark-c-function for C, |
3bef4fb9 | 1044 | mark-fortran-subsystem for fortran, |
4bf7f5d1 RS |
1045 | and mark-paragraph for other modes." |
1046 | (interactive) | |
3bef4fb9 KH |
1047 | (if edt-select-mode |
1048 | (progn | |
1049 | (edt-reset)) | |
1050 | (progn | |
1051 | (cond ((or (eq major-mode 'emacs-lisp-mode) | |
1052 | (eq major-mode 'lisp-mode)) | |
1053 | (mark-defun) | |
1054 | (message "Lisp defun selected")) | |
1055 | ((eq major-mode 'c-mode) | |
1056 | (mark-c-function) | |
1057 | (message "C function selected")) | |
1058 | ((eq major-mode 'fortran-mode) | |
1059 | (mark-fortran-subprogram) | |
1060 | (message "Fortran subprogram selected")) | |
1061 | (t (mark-paragraph) | |
1062 | (message "Paragraph selected")))))) | |
1063 | ||
1064 | ;;; | |
1065 | ;;; COPY | |
1066 | ;;; | |
1067 | ||
1068 | (defun edt-copy () | |
1069 | "Copy selected region to kill ring, but don't delete it!" | |
1070 | (interactive) | |
1071 | (edt-check-selection) | |
1072 | (copy-region-as-kill (mark) (point)) | |
1073 | (edt-reset) | |
1074 | (message "Selected text COPIED to kill ring")) | |
1075 | ||
1076 | ;;; | |
1077 | ;;; CUT or COPY | |
1078 | ;;; | |
1079 | ||
1080 | (defun edt-cut-or-copy () | |
1081 | "Cuts (or copies) selected text to kill ring. | |
1082 | Cuts selected text if buffer-read-only is nil. | |
1083 | Copies selected text if buffer-read-only is t." | |
1084 | (interactive) | |
1085 | (if buffer-read-only | |
1086 | (edt-copy) | |
1087 | (edt-cut))) | |
1088 | ||
1089 | ;;; | |
1090 | ;;; DELETE ENTIRE LINE | |
1091 | ;;; | |
1092 | ||
1093 | (defun edt-delete-entire-line () | |
1094 | "Delete entire line regardless of cursor position in the line." | |
1095 | (interactive "*") | |
1096 | (beginning-of-line) | |
1097 | (edt-delete-line 1)) | |
1098 | ||
1099 | ;;; | |
1100 | ;;; DUPLICATE LINE | |
1101 | ;;; | |
1102 | ||
1103 | (defun edt-duplicate-line (num) | |
1104 | "Duplicate a line of text. | |
1105 | Accepts a positive prefix argument for the number times to duplicate the line." | |
1106 | (interactive "*p") | |
1107 | (edt-check-prefix num) | |
1108 | (let ((old-column (current-column)) | |
1109 | (count num)) | |
1110 | (edt-delete-entire-line) | |
1111 | (edt-undelete-line) | |
1112 | (while (> count 0) | |
1113 | (edt-undelete-line) | |
1114 | (setq count (1- count))) | |
1115 | (edt-line-forward num) | |
1116 | (move-to-column old-column))) | |
1117 | ||
1118 | ;;; | |
1119 | ;;; DUPLICATE WORD | |
1120 | ;;; | |
1121 | ||
1122 | (defun edt-duplicate-word() | |
1123 | "Duplicate word (or rest of word) found directly above cursor, if any." | |
1124 | (interactive "*") | |
1125 | (let ((start (point)) | |
1126 | (start-column (current-column))) | |
1127 | (forward-line -1) | |
1128 | (move-to-column start-column) | |
1129 | (if (and (not (equal start (point))) | |
1130 | (not (eolp))) | |
1131 | (progn | |
1132 | (if (and (equal ?\t (preceding-char)) | |
1133 | (< start-column (current-column))) | |
1134 | (backward-char)) | |
1135 | (let ((beg (point))) | |
1136 | (edt-one-word-forward) | |
1137 | (setq edt-last-copied-word (buffer-substring beg (point)))) | |
1138 | (forward-line) | |
1139 | (move-to-column start-column) | |
1140 | (insert edt-last-copied-word)) | |
1141 | (progn | |
1142 | (if (not (equal start (point))) | |
1143 | (forward-line)) | |
1144 | (move-to-column start-column) | |
1145 | (error "Nothing to duplicate!"))))) | |
1146 | ||
1147 | ;;; | |
1148 | ;;; KEY NOT ASSIGNED | |
1149 | ;;; | |
1150 | ||
1151 | (defun edt-key-not-assigned () | |
1152 | "Displays message that key has not been assigned to a function." | |
1153 | (interactive) | |
1154 | (error "Key not assigned")) | |
1155 | ||
1156 | ;;; | |
1157 | ;;; TOGGLE CAPITALIZATION OF WORD | |
1158 | ;;; | |
1159 | ||
1160 | (defun edt-toggle-capitalization-of-word () | |
1161 | "Toggle the capitalization of the current word and move forward to next." | |
1162 | (interactive "*") | |
1163 | (edt-one-word-forward) | |
1164 | (edt-one-word-backward) | |
1165 | (edt-change-case 1) | |
1166 | (edt-one-word-backward) | |
1167 | (edt-one-word-forward)) | |
1168 | ||
1169 | ;;; | |
1170 | ;;; ELIMINATE ALL TABS | |
1171 | ;;; | |
1172 | ||
1173 | (defun edt-eliminate-all-tabs () | |
1174 | "Convert all tabs to spaces in the entire buffer." | |
1175 | (interactive "*") | |
1176 | (untabify (point-min) (point-max)) | |
1177 | (message "TABS converted to SPACES")) | |
1178 | ||
1179 | ;;; | |
1180 | ;;; DISPLAY THE TIME | |
1181 | ;;; | |
1182 | ||
1183 | (defun edt-display-the-time () | |
1184 | "Display the current time." | |
1185 | (interactive) | |
1186 | (set 'time-string (current-time-string)) | |
1187 | (message time-string)) | |
1188 | ||
1189 | ;;; | |
1190 | ;;; LEARN | |
1191 | ;;; | |
1192 | ||
1193 | (defun edt-learn () | |
1194 | "Learn a sequence of key strokes to bind to a key." | |
1195 | (interactive) | |
1196 | (if (eq defining-kbd-macro t) | |
1197 | (edt-remember) | |
1198 | (start-kbd-macro nil))) | |
1199 | ||
1200 | ;;; | |
1201 | ;;; REMEMBER | |
1202 | ;;; | |
1203 | ||
1204 | (defun edt-remember () | |
1205 | "Store the sequence of key strokes started by edt-learn to a key." | |
1206 | (interactive) | |
1207 | (if (eq defining-kbd-macro nil) | |
1208 | (error "Nothing to remember!") | |
1209 | (progn | |
1210 | (end-kbd-macro nil) | |
1211 | (let (edt-key-definition-string) | |
1212 | (set 'edt-key-definition-string | |
1213 | (read-key-sequence "Enter key for binding: ")) | |
1214 | (if (string-equal "\C-m" edt-key-definition-string) | |
1215 | (message "Key sequence not remembered") | |
1216 | (progn | |
1217 | (set 'edt-learn-macro-count (+ edt-learn-macro-count 1)) | |
1218 | (setq edt-last-replaced-key-definition | |
1219 | (lookup-key (current-global-map) | |
1220 | edt-key-definition-string)) | |
1221 | (define-key (current-global-map) edt-key-definition-string | |
1222 | (name-last-kbd-macro | |
1223 | (intern (concat "last-learned-sequence-" | |
1224 | (int-to-string edt-learn-macro-count))))))))))) | |
1225 | ||
1226 | ;;; | |
1227 | ;;; EXIT | |
1228 | ;;; | |
1229 | ||
1230 | (defun edt-exit () | |
1231 | "Save current buffer, ask to save other buffers, and then exit Emacs." | |
1232 | (interactive) | |
1233 | (save-buffer) | |
1234 | (save-buffers-kill-emacs)) | |
1235 | ||
1236 | ;;; | |
1237 | ;;; QUIT | |
1238 | ;;; | |
1239 | ||
1240 | (defun edt-quit () | |
1241 | "Quit Emacs without saving changes." | |
1242 | (interactive) | |
1243 | (kill-emacs)) | |
1244 | ||
1245 | ;;; | |
1246 | ;;; SPLIT WINDOW | |
1247 | ;;; | |
1248 | ||
1249 | (defun edt-split-window () | |
1250 | "Split current window and place cursor in the new window." | |
1251 | (interactive) | |
1252 | (split-window) | |
1253 | (other-window 1)) | |
1254 | ||
3bef4fb9 KH |
1255 | ;;; |
1256 | ;;; COPY RECTANGLE | |
1257 | ;;; | |
1258 | ||
1259 | (defun edt-copy-rectangle () | |
1260 | "Copy a rectangle of text between mark and cursor to register." | |
1261 | (interactive) | |
1262 | (edt-check-selection) | |
1263 | (copy-rectangle-to-register 3 (region-beginning) (region-end) nil) | |
1264 | (edt-reset) | |
1265 | (message "Selected rectangle COPIED to register")) | |
1266 | ||
1267 | ;;; | |
1268 | ;;; CUT RECTANGLE | |
1269 | ;;; | |
1270 | ||
1271 | (defun edt-cut-rectangle-overstrike-mode () | |
e4360875 KH |
1272 | "Cut a rectangle of text between mark and cursor to register. |
1273 | Replace cut characters with spaces and moving cursor back to | |
1274 | upper left corner." | |
3bef4fb9 KH |
1275 | (interactive "*") |
1276 | (edt-check-selection) | |
1277 | (setq edt-rect-start-point (region-beginning)) | |
1278 | (picture-clear-rectangle-to-register (region-beginning) (region-end) 3) | |
1279 | (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point) | |
1280 | (message "Selected rectangle CUT to register")) | |
1281 | ||
1282 | (defun edt-cut-rectangle-insert-mode () | |
e4360875 KH |
1283 | "Cut a rectangle of text between mark and cursor to register. |
1284 | Move cursor back to upper left corner." | |
3bef4fb9 KH |
1285 | (interactive "*") |
1286 | (edt-check-selection) | |
1287 | (setq edt-rect-start-point (region-beginning)) | |
1288 | (picture-clear-rectangle-to-register (region-beginning) (region-end) 3 t) | |
1289 | (fixup-whitespace) | |
1290 | (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point) | |
1291 | (message "Selected rectangle CUT to register")) | |
1292 | ||
1293 | (defun edt-cut-rectangle () | |
1294 | "Cut a rectangular region of text to register. | |
e4360875 | 1295 | If overwrite mode is active, cut text is replaced with whitespace." |
3bef4fb9 KH |
1296 | (interactive "*") |
1297 | (if overwrite-mode | |
1298 | (edt-cut-rectangle-overstrike-mode) | |
1299 | (edt-cut-rectangle-insert-mode))) | |
1300 | ||
1301 | ;;; | |
1302 | ;;; PASTE RECTANGLE | |
1303 | ;;; | |
1304 | ||
1305 | (defun edt-paste-rectangle-overstrike-mode () | |
1306 | "Paste a rectangular region of text from register, replacing text at cursor." | |
1307 | (interactive "*") | |
1308 | (picture-yank-rectangle-from-register 3)) | |
1309 | ||
1310 | (defun edt-paste-rectangle-insert-mode () | |
1311 | "Paste previously deleted rectangular region, inserting text at cursor." | |
1312 | (interactive "*") | |
1313 | (picture-yank-rectangle-from-register 3 t)) | |
1314 | ||
1315 | (defun edt-paste-rectangle () | |
1316 | "Paste a rectangular region of text. | |
1317 | If overwrite mode is active, existing text is replace with text from register." | |
1318 | (interactive) | |
1319 | (if overwrite-mode | |
1320 | (edt-paste-rectangle-overstrike-mode) | |
1321 | (edt-paste-rectangle-insert-mode))) | |
1322 | ||
1323 | ;;; | |
1324 | ;;; DOWNCASE REGION | |
1325 | ;;; | |
1326 | ||
1327 | (defun edt-lowercase () | |
1328 | "Change specified characters to lower case. | |
1329 | If text selection IS active, then characters between the cursor and | |
1330 | mark are changed. If text selection is NOT active, there are two | |
1331 | situations. If the current direction is ADVANCE, then the word under | |
1332 | the cursor is changed to lower case and the cursor is moved to rest at | |
1333 | the beginning of the next word. If the current direction is BACKUP, | |
1334 | the word prior to the word under the cursor is changed to lower case | |
1335 | and the cursor is left to rest at the beginning of that word." | |
1336 | (interactive "*") | |
1337 | (if edt-select-mode | |
1338 | (progn | |
1339 | (downcase-region (mark) (point))) | |
1340 | (progn | |
1341 | ;; Move to beginning of current word. | |
1342 | (if (and | |
1343 | (not (bobp)) | |
1344 | (not (eobp)) | |
1345 | (not (bolp)) | |
1346 | (not (eolp)) | |
1347 | (not (eq ?\ (char-syntax (preceding-char)))) | |
1348 | (not (memq (preceding-char) edt-word-entities)) | |
1349 | (not (memq (following-char) edt-word-entities))) | |
1350 | (edt-one-word-backward)) | |
1351 | (if (equal edt-direction-string edt-backward-string) | |
1352 | (edt-one-word-backward)) | |
1353 | (let ((beg (point))) | |
1354 | (edt-one-word-forward) | |
1355 | (downcase-region beg (point))) | |
1356 | (if (equal edt-direction-string edt-backward-string) | |
1357 | (edt-one-word-backward))))) | |
1358 | ||
1359 | ;;; | |
1360 | ;;; UPCASE REGION | |
1361 | ;;; | |
1362 | ||
1363 | (defun edt-uppercase () | |
1364 | "Change specified characters to upper case. | |
1365 | If text selection IS active, then characters between the cursor and | |
1366 | mark are changed. If text selection is NOT active, there are two | |
1367 | situations. If the current direction is ADVANCE, then the word under | |
1368 | the cursor is changed to upper case and the cursor is moved to rest at | |
1369 | the beginning of the next word. If the current direction is BACKUP, | |
1370 | the word prior to the word under the cursor is changed to upper case | |
1371 | and the cursor is left to rest at the beginning of that word." | |
1372 | (interactive "*") | |
1373 | (if edt-select-mode | |
1374 | (progn | |
1375 | (upcase-region (mark) (point))) | |
1376 | (progn | |
1377 | ;; Move to beginning of current word. | |
1378 | (if (and | |
1379 | (not (bobp)) | |
1380 | (not (eobp)) | |
1381 | (not (bolp)) | |
1382 | (not (eolp)) | |
1383 | (not (eq ?\ (char-syntax (preceding-char)))) | |
1384 | (not (memq (preceding-char) edt-word-entities)) | |
1385 | (not (memq (following-char) edt-word-entities))) | |
1386 | (edt-one-word-backward)) | |
1387 | (if (equal edt-direction-string edt-backward-string) | |
1388 | (edt-one-word-backward)) | |
1389 | (let ((beg (point))) | |
1390 | (edt-one-word-forward) | |
1391 | (upcase-region beg (point))) | |
1392 | (if (equal edt-direction-string edt-backward-string) | |
1393 | (edt-one-word-backward))))) | |
1394 | ||
1395 | \f | |
1396 | ;;; | |
1397 | ;;; INITIALIZATION COMMANDS. | |
1398 | ;;; | |
1399 | ||
1400 | ;;; | |
1401 | ;;; Emacs version 19 X-windows key definition support | |
1402 | ;;; | |
e4360875 KH |
1403 | (defvar edt-last-answer nil |
1404 | "Most recent response to edt-y-or-n-p.") | |
3bef4fb9 KH |
1405 | |
1406 | (defun edt-y-or-n-p (prompt &optional not-yes) | |
1407 | "Prompt for a y or n answer with positive default. | |
1408 | Optional second argument NOT-YES changes default to negative. | |
1409 | Like emacs y-or-n-p, also accepts space as y and DEL as n." | |
1410 | (message (format "%s[%s]" prompt (if not-yes "n" "y"))) | |
1411 | (let ((doit t)) | |
1412 | (while doit | |
1413 | (setq doit nil) | |
1414 | (let ((ans (read-char))) | |
1415 | (cond ((or (= ans ?y) (= ans ?Y) (= ans ?\ )) | |
1416 | (setq edt-last-answer t)) | |
1417 | ((or (= ans ?n) (= ans ?N) (= ans ?\C-?)) | |
1418 | (setq edt-last-answer nil)) | |
1419 | ((= ans ?\r) (setq edt-last-answer (not not-yes))) | |
1420 | (t | |
1421 | (setq doit t) (beep) | |
1422 | (message (format "Please answer y or n. %s[%s]" | |
1423 | prompt (if not-yes "n" "y")))))))) | |
1424 | edt-last-answer) | |
1425 | ||
1426 | (defun edt-load-xkeys (file) | |
1427 | "Load the EDT X-windows key definitions FILE. | |
1428 | If FILE is nil, try to load a default file. The default file names are | |
1429 | ~/.edt-lucid-keys for Lucid emacs, and ~/.edt-gnu-keys for GNU emacs." | |
1430 | (interactive "fX key definition file: ") | |
1431 | (cond (file | |
1432 | (setq file (expand-file-name file))) | |
1433 | (edt-xkeys-file | |
1434 | (setq file (expand-file-name edt-xkeys-file))) | |
1435 | (edt-gnu-emacs19-p | |
1436 | (setq file (expand-file-name "~/.edt-gnu-keys"))) | |
1437 | (edt-lucid-emacs19-p | |
1438 | (setq file (expand-file-name "~/.edt-lucid-keys")))) | |
1439 | (cond ((file-readable-p file) | |
1440 | (load-file file)) | |
1441 | (t | |
1442 | (switch-to-buffer "*scratch*") | |
1443 | (erase-buffer) | |
1444 | (insert " | |
1445 | ||
1446 | Ack!! You're running the Enhanced EDT Emulation under X-windows | |
1447 | without loading an EDT X key definition file. To create an EDT X | |
1448 | key definition file, run the edt-mapper.el program. But ONLY run | |
1449 | it from an Emacs loaded without any of your own customizations | |
1450 | found in your .emacs file, etc. Some user customization confuse | |
1451 | the edt-mapper function. To do this, you need to invoke Emacs | |
1452 | as follows: | |
1453 | ||
1454 | emacs -q -l edt-mapper.el | |
1455 | ||
1456 | The file edt-mapper.el includes these same directions on how to | |
1457 | use it! Perhaps it's laying around here someplace. \n ") | |
1458 | (let ((file "edt-mapper.el") | |
1459 | (found nil) | |
1460 | (path nil) | |
1461 | (search-list (append (list (expand-file-name ".")) load-path))) | |
1462 | (while (and (not found) search-list) | |
1463 | (setq path (concat (car search-list) | |
1464 | (if (string-match "/$" (car search-list)) "" "/") | |
1465 | file)) | |
1466 | (if (and (file-exists-p path) (not (file-directory-p path))) | |
1467 | (setq found t)) | |
1468 | (setq search-list (cdr search-list))) | |
1469 | (cond (found | |
1470 | (insert (format | |
1471 | "Ah yes, there it is, in \n\n %s \n\n" path)) | |
1472 | (if (edt-y-or-n-p "Do you want to run it now? ") | |
1473 | (load-file path) | |
1474 | (error "EDT Emulation not configured."))) | |
1475 | (t | |
1476 | (insert "Nope, I can't seem to find it. :-(\n\n") | |
1477 | (sit-for 20) | |
1478 | (error "EDT Emulation not configured."))))))) | |
4bf7f5d1 | 1479 | |
f9f9507e | 1480 | ;;;###autoload |
4bf7f5d1 | 1481 | (defun edt-emulation-on () |
3bef4fb9 KH |
1482 | "Turn on EDT Emulation." |
1483 | (interactive) | |
1484 | ;; If using MS-DOS, need to load edt-pc.el | |
1485 | (if (string-equal system-type "ms-dos") | |
1486 | (setq edt-term "pc") | |
1487 | (setq edt-term (getenv "TERM"))) | |
1488 | ;; All DEC VT series terminals are supported by loading edt-vt100.el | |
1489 | (if (string-equal "vt" (substring edt-term 0 (min (length edt-term) 2))) | |
1490 | (setq edt-term "vt100")) | |
1491 | ;; Load EDT terminal specific configuration file. | |
1492 | (let ((term edt-term) | |
1493 | hyphend) | |
1494 | (while (and term | |
1495 | (not (load (concat "edt-" term) t t))) | |
1496 | ;; Strip off last hyphen and what follows, then try again | |
1497 | (if (setq hyphend (string-match "[-_][^-_]+$" term)) | |
1498 | (setq term (substring term 0 hyphend)) | |
1499 | (setq term nil))) | |
1500 | ;; Override terminal-specific file if running X Windows. X Windows support | |
1501 | ;; is handled differently in edt-load-xkeys | |
f873df69 | 1502 | (if (eq window-system 'x) |
3bef4fb9 KH |
1503 | (edt-load-xkeys nil) |
1504 | (if (null term) | |
1505 | (error "Unable to load EDT terminal specific file for %s" edt-term))) | |
1506 | (setq edt-term term)) | |
1507 | (setq edt-orig-transient-mark-mode transient-mark-mode) | |
1508 | (add-hook 'activate-mark-hook | |
1509 | (function | |
1510 | (lambda () | |
1511 | (edt-select-mode t)))) | |
1512 | (add-hook 'deactivate-mark-hook | |
1513 | (function | |
1514 | (lambda () | |
1515 | (edt-select-mode nil)))) | |
1516 | (if (load "edt-user" t t) | |
1517 | (edt-user-emulation-setup) | |
1518 | (edt-default-emulation-setup))) | |
1519 | ||
1520 | (defun edt-emulation-off() | |
1521 | "Select original global key bindings, disabling EDT Emulation." | |
1522 | (interactive) | |
1523 | (use-global-map global-map) | |
1524 | (if (not edt-keep-current-page-delimiter) | |
1525 | (setq page-delimiter edt-orig-page-delimiter)) | |
1526 | (setq edt-direction-string "") | |
1527 | (setq edt-select-mode-text nil) | |
1528 | (edt-reset) | |
1529 | (force-mode-line-update t) | |
1530 | (setq transient-mark-mode edt-orig-transient-mark-mode) | |
1531 | (message "Original key bindings restored; EDT Emulation disabled")) | |
1532 | ||
1533 | (defun edt-default-emulation-setup (&optional user-setup) | |
1534 | "Setup emulation of DEC's EDT editor." | |
1535 | ;; Setup default EDT global map by copying global map bindings. | |
1536 | ;; This preserves ESC and C-x prefix bindings and other bindings we | |
1537 | ;; wish to retain in EDT emulation mode keymaps. It also permits | |
1538 | ;; customization of these bindings in the EDT global maps without | |
1539 | ;; disturbing the original bindings in global-map. | |
1540 | (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix)) | |
1541 | (setq edt-default-global-map (copy-keymap (current-global-map))) | |
1542 | (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) | |
1543 | (define-prefix-command 'edt-default-gold-map) | |
1544 | (edt-setup-default-bindings) | |
1545 | ;; If terminal has additional function keys, the terminal-specific | |
1546 | ;; initialization file can assign bindings to them via the optional | |
1547 | ;; function edt-setup-extra-default-bindings. | |
1548 | (if (fboundp 'edt-setup-extra-default-bindings) | |
1549 | (edt-setup-extra-default-bindings)) | |
1550 | ;; Variable needed by edt-learn. | |
1551 | (setq edt-learn-macro-count 0) | |
1552 | ;; Display EDT text selection active within the mode line | |
1553 | (or (assq 'edt-select-mode minor-mode-alist) | |
1554 | (setq minor-mode-alist | |
1555 | (cons '(edt-select-mode edt-select-mode) minor-mode-alist))) | |
1556 | ;; Display EDT direction of motion within the mode line | |
1557 | (or (assq 'edt-direction-string minor-mode-alist) | |
1558 | (setq minor-mode-alist | |
1559 | (cons | |
1560 | '(edt-direction-string edt-direction-string) minor-mode-alist))) | |
1561 | (if user-setup | |
1562 | (progn | |
1563 | (setq edt-user-map-configured t) | |
1564 | (fset 'edt-emulation-on (symbol-function 'edt-select-user-global-map))) | |
1565 | (progn | |
1566 | (fset 'edt-emulation-on (symbol-function 'edt-select-default-global-map)) | |
1567 | (edt-select-default-global-map)))) | |
1568 | ||
1569 | (defun edt-user-emulation-setup () | |
1570 | "Setup user custom emulation of DEC's EDT editor." | |
1571 | ;; Initialize EDT default bindings. | |
1572 | (edt-default-emulation-setup t) | |
1573 | ;; Setup user EDT global map by copying default EDT global map bindings. | |
1574 | (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix)) | |
1575 | (setq edt-user-global-map (copy-keymap edt-default-global-map)) | |
1576 | (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) | |
1577 | ;; If terminal has additional function keys, the user's initialization | |
1578 | ;; file can assign bindings to them via the optional | |
1579 | ;; function edt-setup-extra-default-bindings. | |
1580 | (define-prefix-command 'edt-user-gold-map) | |
1581 | (fset 'edt-user-gold-map (copy-keymap 'edt-default-gold-map)) | |
1582 | (edt-setup-user-bindings) | |
1583 | (edt-select-user-global-map)) | |
1584 | ||
1585 | (defun edt-select-default-global-map() | |
1586 | "Select default EDT emulation key bindings." | |
1587 | (interactive) | |
1588 | (transient-mark-mode 1) | |
1589 | (use-global-map edt-default-global-map) | |
1590 | (if (not edt-keep-current-page-delimiter) | |
1591 | (progn | |
1592 | (setq edt-orig-page-delimiter page-delimiter) | |
1593 | (setq page-delimiter "\f"))) | |
1594 | (setq edt-default-map-active t) | |
1595 | (edt-advance) | |
1596 | (setq edt-select-mode-text 'edt-select-mode-string) | |
1597 | (edt-reset) | |
1598 | (message "Default EDT keymap active")) | |
1599 | ||
1600 | (defun edt-select-user-global-map() | |
1601 | "Select user EDT emulation custom key bindings." | |
1602 | (interactive) | |
1603 | (if edt-user-map-configured | |
1604 | (progn | |
1605 | (transient-mark-mode 1) | |
1606 | (use-global-map edt-user-global-map) | |
1607 | (if (not edt-keep-current-page-delimiter) | |
1608 | (progn | |
1609 | (setq edt-orig-page-delimiter page-delimiter) | |
1610 | (setq page-delimiter "\f"))) | |
1611 | (setq edt-default-map-active nil) | |
1612 | (edt-advance) | |
1613 | (setq edt-select-mode-text 'edt-select-mode-string) | |
1614 | (edt-reset) | |
1615 | (message "User EDT custom keymap active")) | |
1616 | (error "User EDT custom keymap NOT configured!"))) | |
1617 | ||
1618 | (defun edt-switch-global-maps () | |
1619 | "Toggle between default EDT keymap and user EDT keymap." | |
1620 | (interactive) | |
1621 | (if edt-default-map-active | |
1622 | (edt-select-user-global-map) | |
1623 | (edt-select-default-global-map))) | |
1624 | ||
1625 | ;; There are three key binding functions needed: one for standard keys | |
1626 | ;; (used to bind control keys, primarily), one for Gold sequences of | |
1627 | ;; standard keys, and one for function keys. | |
1628 | ||
1629 | (defun edt-bind-gold-key (key gold-binding &optional default) | |
1630 | "Binds commands to a gold key sequence in the EDT Emulator." | |
1631 | (if default | |
1632 | (define-key 'edt-default-gold-map key gold-binding) | |
1633 | (define-key 'edt-user-gold-map key gold-binding))) | |
1634 | ||
1635 | (defun edt-bind-standard-key (key gold-binding &optional default) | |
1636 | "Bind commands to a gold key sequence in the default EDT keymap." | |
1637 | (if default | |
1638 | (define-key edt-default-global-map key gold-binding) | |
1639 | (define-key edt-user-global-map key gold-binding))) | |
1640 | ||
1641 | (defun edt-bind-function-key | |
1642 | (function-key binding gold-binding &optional default) | |
1643 | "Binds function keys in the EDT Emulator." | |
1644 | (catch 'edt-key-not-supported | |
1645 | (let ((key-vector (cdr (assoc function-key *EDT-keys*)))) | |
1646 | (if (stringp key-vector) | |
1647 | (throw 'edt-key-not-supported t)) | |
1648 | (if (not (null key-vector)) | |
1649 | (progn | |
1650 | (if default | |
1651 | (progn | |
1652 | (define-key edt-default-global-map key-vector binding) | |
1653 | (define-key 'edt-default-gold-map key-vector gold-binding)) | |
1654 | (progn | |
1655 | (define-key edt-user-global-map key-vector binding) | |
1656 | (define-key 'edt-user-gold-map key-vector gold-binding)))) | |
1657 | (error "%s is not a legal function key name" function-key))))) | |
1658 | ||
1659 | (defun edt-setup-default-bindings () | |
1660 | "Assigns default EDT Emulation keyboard bindings." | |
1661 | ||
1662 | ;; Function Key Bindings: Regular and GOLD. | |
1663 | ||
1664 | ;; VT100/VT200/VT300 PF1 (GOLD), PF2, PF3, PF4 Keys | |
1665 | (edt-bind-function-key "PF1" 'edt-default-gold-map 'edt-mark-section-wisely t) | |
1666 | (edt-bind-function-key "PF2" 'edt-electric-keypad-help 'describe-function t) | |
1667 | (edt-bind-function-key "PF3" 'edt-find-next 'edt-find t) | |
1668 | (edt-bind-function-key "PF4" 'edt-delete-line 'edt-undelete-line t) | |
1669 | ||
1670 | ;; VT100/VT200/VT300 Arrow Keys | |
1671 | (edt-bind-function-key "UP" 'previous-line 'edt-window-top t) | |
1672 | (edt-bind-function-key "DOWN" 'next-line 'edt-window-bottom t) | |
1673 | (edt-bind-function-key "LEFT" 'backward-char 'edt-sentence-backward t) | |
1674 | (edt-bind-function-key "RIGHT" 'forward-char 'edt-sentence-forward t) | |
1675 | ||
1676 | ;; VT100/VT200/VT300 Keypad Keys | |
1677 | (edt-bind-function-key "KP0" 'edt-line 'open-line t) | |
1678 | (edt-bind-function-key "KP1" 'edt-word 'edt-change-case t) | |
1679 | (edt-bind-function-key "KP2" 'edt-end-of-line 'edt-delete-to-end-of-line t) | |
1680 | (edt-bind-function-key "KP3" 'edt-character 'quoted-insert t) | |
1681 | (edt-bind-function-key "KP4" 'edt-advance 'edt-bottom t) | |
1682 | (edt-bind-function-key "KP5" 'edt-backup 'edt-top t) | |
1683 | (edt-bind-function-key "KP6" 'edt-cut 'yank t) | |
1684 | (edt-bind-function-key "KP7" 'edt-page 'execute-extended-command t) | |
1685 | (edt-bind-function-key "KP8" 'edt-sect 'edt-fill-region t) | |
1686 | (edt-bind-function-key "KP9" 'edt-append 'edt-replace t) | |
1687 | (edt-bind-function-key "KP-" 'edt-delete-word 'edt-undelete-word t) | |
1688 | (edt-bind-function-key "KP," 'edt-delete-character 'edt-undelete-character t) | |
1689 | (edt-bind-function-key "KPP" 'edt-select 'edt-reset t) | |
1690 | (edt-bind-function-key "KPE" 'other-window 'query-replace t) | |
1691 | ||
1692 | ;; VT200/VT300 Function Keys | |
1693 | ;; (F1 through F5, on the VT220, are not programmable, so we skip | |
1694 | ;; making default bindings to those keys. | |
1695 | (edt-bind-function-key "FIND" 'edt-find-next 'edt-find t) | |
1696 | (edt-bind-function-key "INSERT" 'yank 'edt-key-not-assigned t) | |
1697 | (edt-bind-function-key "REMOVE" 'edt-cut 'edt-copy t) | |
1698 | (edt-bind-function-key "SELECT" 'edt-toggle-select 'edt-key-not-assigned t) | |
1699 | (edt-bind-function-key "NEXT" 'edt-sect-forward 'edt-key-not-assigned t) | |
1700 | (edt-bind-function-key "PREVIOUS" 'edt-sect-backward 'edt-key-not-assigned t) | |
1701 | (edt-bind-function-key "F6" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1702 | (edt-bind-function-key "F7" 'edt-copy-rectangle 'edt-key-not-assigned t) | |
1703 | (edt-bind-function-key "F8" | |
1704 | 'edt-cut-rectangle-overstrike-mode 'edt-paste-rectangle-overstrike-mode t) | |
1705 | (edt-bind-function-key "F9" | |
1706 | 'edt-cut-rectangle-insert-mode 'edt-paste-rectangle-insert-mode t) | |
1707 | (edt-bind-function-key "F10" 'edt-cut-rectangle 'edt-paste-rectangle t) | |
1708 | ;; Under X, the F11 key can be bound. If using a VT-200 or higher terminal, | |
1709 | ;; the default emacs terminal support causes the VT F11 key to seem as if it | |
1710 | ;; is an ESC key when in emacs. | |
1711 | (edt-bind-function-key "F11" | |
1712 | 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1713 | (edt-bind-function-key "F12" | |
1714 | 'edt-beginning-of-line 'delete-other-windows t) ;BS | |
1715 | (edt-bind-function-key "F13" | |
1716 | 'edt-delete-to-beginning-of-word 'edt-key-not-assigned t) ;LF | |
1717 | (edt-bind-function-key "F14" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1718 | (edt-bind-function-key "HELP" 'edt-electric-keypad-help 'edt-key-not-assigned t) | |
1719 | (edt-bind-function-key "DO" 'execute-extended-command 'edt-key-not-assigned t) | |
1720 | (edt-bind-function-key "F17" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1721 | (edt-bind-function-key "F18" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1722 | (edt-bind-function-key "F19" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1723 | (edt-bind-function-key "F20" 'edt-key-not-assigned 'edt-key-not-assigned t) | |
1724 | ||
1725 | ;; Control key bindings: Regular and GOLD | |
1726 | ;; | |
1727 | ;; Standard EDT control key bindings conflict with standard Emacs | |
1728 | ;; control key bindings. Normally, the standard Emacs control key | |
1729 | ;; bindings are left unchanged in the default EDT mode. However, if | |
1730 | ;; the variable edt-use-EDT-control-key-bindings is set to true | |
1731 | ;; before invoking edt-emulation-on for the first time, then the | |
1732 | ;; standard EDT bindings (with some enhancements) as defined here are | |
1733 | ;; used, instead. | |
1734 | (if edt-use-EDT-control-key-bindings | |
1735 | (progn | |
1736 | (edt-bind-standard-key "\C-a" 'edt-key-not-assigned t) | |
1737 | (edt-bind-standard-key "\C-b" 'edt-key-not-assigned t) | |
1738 | ;; Leave binding of C-c as original prefix key. | |
1739 | (edt-bind-standard-key "\C-d" 'edt-key-not-assigned t) | |
1740 | (edt-bind-standard-key "\C-e" 'edt-key-not-assigned t) | |
1741 | (edt-bind-standard-key "\C-f" 'edt-key-not-assigned t) | |
1742 | ;; Leave binding of C-g to keyboard-quit | |
1743 | ; (edt-bind-standard-key "\C-g" 'keyboard-quit t) | |
1744 | ;; Standard EDT binding of C-h. To invoke Emacs help, use | |
1745 | ;; GOLD-C-h instead. | |
1746 | (edt-bind-standard-key "\C-h" 'edt-beginning-of-line t) | |
1747 | (edt-bind-standard-key "\C-i" 'edt-tab-insert t) | |
1748 | (edt-bind-standard-key "\C-j" 'edt-delete-to-beginning-of-word t) | |
1749 | (edt-bind-standard-key "\C-k" 'edt-define-key t) | |
1750 | (edt-bind-gold-key "\C-k" 'edt-restore-key t) | |
1751 | (edt-bind-standard-key "\C-l" 'edt-form-feed-insert t) | |
1752 | ;; Leave binding of C-m to newline. | |
1753 | (edt-bind-standard-key "\C-n" 'edt-set-screen-width-80 t) | |
1754 | (edt-bind-standard-key "\C-o" 'edt-key-not-assigned t) | |
1755 | (edt-bind-standard-key "\C-p" 'edt-key-not-assigned t) | |
1756 | (edt-bind-standard-key "\C-q" 'edt-key-not-assigned t) | |
1757 | ;; Leave binding of C-r to isearch-backward. | |
1758 | ;; Leave binding of C-s to isearch-forward. | |
1759 | (edt-bind-standard-key "\C-t" 'edt-display-the-time t) | |
1760 | (edt-bind-standard-key "\C-u" 'edt-delete-to-beginning-of-line t) | |
1761 | (edt-bind-standard-key "\C-v" 'redraw-display t) | |
1762 | (edt-bind-standard-key "\C-w" 'edt-set-screen-width-132 t) | |
1763 | ;; Leave binding of C-x as original prefix key. | |
1764 | (edt-bind-standard-key "\C-y" 'edt-key-not-assigned t) | |
1765 | ; (edt-bind-standard-key "\C-z" 'suspend-emacs t) | |
1766 | ) | |
1767 | ) | |
1768 | ||
1769 | ;; GOLD bindings for a few Control keys. | |
1770 | (edt-bind-gold-key "\C-g" 'keyboard-quit t); Just in case. | |
1771 | (edt-bind-gold-key "\C-h" 'help-for-help t) | |
a15bb73a RS |
1772 | (edt-bind-gold-key [f1] 'help-for-help t) |
1773 | (edt-bind-gold-key [help] 'help-for-help t) | |
3bef4fb9 KH |
1774 | (edt-bind-gold-key "\C-\\" 'split-window-vertically t) |
1775 | ||
1776 | ;; GOLD bindings for regular keys. | |
1777 | (edt-bind-gold-key "a" 'edt-key-not-assigned t) | |
1778 | (edt-bind-gold-key "A" 'edt-key-not-assigned t) | |
1779 | (edt-bind-gold-key "b" 'buffer-menu t) | |
1780 | (edt-bind-gold-key "B" 'buffer-menu t) | |
1781 | (edt-bind-gold-key "c" 'compile t) | |
1782 | (edt-bind-gold-key "C" 'compile t) | |
1783 | (edt-bind-gold-key "d" 'delete-window t) | |
1784 | (edt-bind-gold-key "D" 'delete-window t) | |
1785 | (edt-bind-gold-key "e" 'edt-exit t) | |
1786 | (edt-bind-gold-key "E" 'edt-exit t) | |
1787 | (edt-bind-gold-key "f" 'find-file t) | |
1788 | (edt-bind-gold-key "F" 'find-file t) | |
1789 | (edt-bind-gold-key "g" 'find-file-other-window t) | |
1790 | (edt-bind-gold-key "G" 'find-file-other-window t) | |
1791 | (edt-bind-gold-key "h" 'edt-electric-keypad-help t) | |
1792 | (edt-bind-gold-key "H" 'edt-electric-keypad-help t) | |
1793 | (edt-bind-gold-key "i" 'insert-file t) | |
1794 | (edt-bind-gold-key "I" 'insert-file t) | |
1795 | (edt-bind-gold-key "j" 'edt-key-not-assigned t) | |
1796 | (edt-bind-gold-key "J" 'edt-key-not-assigned t) | |
1797 | (edt-bind-gold-key "k" 'edt-toggle-capitalization-of-word t) | |
1798 | (edt-bind-gold-key "K" 'edt-toggle-capitalization-of-word t) | |
1799 | (edt-bind-gold-key "l" 'edt-lowercase t) | |
1800 | (edt-bind-gold-key "L" 'edt-lowercase t) | |
1801 | (edt-bind-gold-key "m" 'save-some-buffers t) | |
1802 | (edt-bind-gold-key "M" 'save-some-buffers t) | |
1803 | (edt-bind-gold-key "n" 'next-error t) | |
1804 | (edt-bind-gold-key "N" 'next-error t) | |
1805 | (edt-bind-gold-key "o" 'switch-to-buffer-other-window t) | |
1806 | (edt-bind-gold-key "O" 'switch-to-buffer-other-window t) | |
1807 | (edt-bind-gold-key "p" 'edt-key-not-assigned t) | |
1808 | (edt-bind-gold-key "P" 'edt-key-not-assigned t) | |
1809 | (edt-bind-gold-key "q" 'edt-quit t) | |
1810 | (edt-bind-gold-key "Q" 'edt-quit t) | |
90bfea27 KH |
1811 | (edt-bind-gold-key "r" 'revert-buffer t) |
1812 | (edt-bind-gold-key "R" 'revert-buffer t) | |
3bef4fb9 KH |
1813 | (edt-bind-gold-key "s" 'save-buffer t) |
1814 | (edt-bind-gold-key "S" 'save-buffer t) | |
1815 | (edt-bind-gold-key "t" 'edt-key-not-assigned t) | |
1816 | (edt-bind-gold-key "T" 'edt-key-not-assigned t) | |
1817 | (edt-bind-gold-key "u" 'edt-uppercase t) | |
1818 | (edt-bind-gold-key "U" 'edt-uppercase t) | |
1819 | (edt-bind-gold-key "v" 'find-file-other-window t) | |
1820 | (edt-bind-gold-key "V" 'find-file-other-window t) | |
1821 | (edt-bind-gold-key "w" 'write-file t) | |
1822 | (edt-bind-gold-key "W" 'write-file t) | |
1823 | (edt-bind-gold-key "x" 'edt-key-not-assigned t) | |
1824 | (edt-bind-gold-key "X" 'edt-key-not-assigned t) | |
1825 | (edt-bind-gold-key "y" 'edt-emulation-off t) | |
1826 | (edt-bind-gold-key "Y" 'edt-emulation-off t) | |
1827 | (edt-bind-gold-key "z" 'edt-switch-global-maps t) | |
1828 | (edt-bind-gold-key "Z" 'edt-switch-global-maps t) | |
1829 | (edt-bind-gold-key "1" 'delete-other-windows t) | |
1830 | (edt-bind-gold-key "!" 'edt-key-not-assigned t) | |
1831 | (edt-bind-gold-key "2" 'edt-split-window t) | |
1832 | (edt-bind-gold-key "@" 'edt-key-not-assigned t) | |
1833 | (edt-bind-gold-key "3" 'edt-key-not-assigned t) | |
1834 | (edt-bind-gold-key "#" 'edt-key-not-assigned t) | |
1835 | (edt-bind-gold-key "4" 'edt-key-not-assigned t) | |
1836 | (edt-bind-gold-key "$" 'edt-key-not-assigned t) | |
1837 | (edt-bind-gold-key "5" 'edt-key-not-assigned t) | |
1838 | (edt-bind-gold-key "%" 'edt-goto-percentage t) | |
1839 | (edt-bind-gold-key "6" 'edt-key-not-assigned t) | |
1840 | (edt-bind-gold-key "^" 'edt-key-not-assigned t) | |
1841 | (edt-bind-gold-key "7" 'edt-key-not-assigned t) | |
1842 | (edt-bind-gold-key "&" 'edt-key-not-assigned t) | |
1843 | (edt-bind-gold-key "8" 'edt-key-not-assigned t) | |
1844 | (edt-bind-gold-key "*" 'edt-key-not-assigned t) | |
1845 | (edt-bind-gold-key "9" 'edt-key-not-assigned t) | |
1846 | (edt-bind-gold-key "(" 'edt-key-not-assigned t) | |
1847 | (edt-bind-gold-key "0" 'edt-key-not-assigned t) | |
1848 | (edt-bind-gold-key ")" 'edt-key-not-assigned t) | |
1849 | (edt-bind-gold-key " " 'undo t) | |
1850 | (edt-bind-gold-key "," 'edt-key-not-assigned t) | |
1851 | (edt-bind-gold-key "<" 'edt-key-not-assigned t) | |
1852 | (edt-bind-gold-key "." 'edt-key-not-assigned t) | |
1853 | (edt-bind-gold-key ">" 'edt-key-not-assigned t) | |
1854 | (edt-bind-gold-key "/" 'edt-key-not-assigned t) | |
1855 | (edt-bind-gold-key "?" 'edt-key-not-assigned t) | |
1856 | (edt-bind-gold-key "\\" 'edt-key-not-assigned t) | |
1857 | (edt-bind-gold-key "|" 'edt-key-not-assigned t) | |
1858 | (edt-bind-gold-key ";" 'edt-key-not-assigned t) | |
1859 | (edt-bind-gold-key ":" 'edt-key-not-assigned t) | |
1860 | (edt-bind-gold-key "'" 'edt-key-not-assigned t) | |
1861 | (edt-bind-gold-key "\"" 'edt-key-not-assigned t) | |
1862 | (edt-bind-gold-key "-" 'edt-key-not-assigned t) | |
1863 | (edt-bind-gold-key "_" 'edt-key-not-assigned t) | |
1864 | (edt-bind-gold-key "=" 'goto-line t) | |
1865 | (edt-bind-gold-key "+" 'edt-key-not-assigned t) | |
1866 | (edt-bind-gold-key "[" 'edt-key-not-assigned t) | |
1867 | (edt-bind-gold-key "{" 'edt-key-not-assigned t) | |
1868 | (edt-bind-gold-key "]" 'edt-key-not-assigned t) | |
1869 | (edt-bind-gold-key "}" 'edt-key-not-assigned t) | |
1870 | (edt-bind-gold-key "`" 'what-line t) | |
1871 | (edt-bind-gold-key "~" 'edt-key-not-assigned t) | |
1872 | ) | |
1873 | \f | |
1874 | ;;; | |
1875 | ;;; DEFAULT EDT KEYPAD HELP | |
1876 | ;;; | |
1877 | ||
1878 | ;;; | |
1879 | ;;; Upper case commands in the keypad diagram below indicate that the | |
1880 | ;;; emulation should look and feel very much like EDT. Lower case | |
1881 | ;;; commands are enhancements and/or additions to the EDT keypad | |
1882 | ;;; commands or are native Emacs commands. | |
1883 | ;;; | |
1884 | ||
1885 | (defun edt-keypad-help () | |
1886 | " | |
1887 | DEFAULT EDT Keypad Active | |
1888 | ||
1889 | F7: Copy Rectangle +----------+----------+----------+----------+ | |
1890 | F8: Cut Rect Overstrike |Prev Line |Next Line |Bkwd Char |Frwd Char | | |
1891 | G-F8: Paste Rect Overstrike | (UP) | (DOWN) | (LEFT) | (RIGHT) | | |
1892 | F9: Cut Rect Insert |Window Top|Window Bot|Bkwd Sent |Frwd Sent | | |
1893 | G-F9: Paste Rect Insert +----------+----------+----------+----------+ | |
1894 | F10: Cut Rectangle | |
1895 | G-F10: Paste Rectangle | |
1896 | F11: ESC | |
1897 | F12: Begining of Line +----------+----------+----------+----------+ | |
1898 | G-F12: Delete Other Windows | GOLD | HELP | FNDNXT | DEL L | | |
1899 | F13: Delete to Begin of Word | (PF1) | (PF2) | (PF3) | (PF4) | | |
1900 | HELP: Keypad Help |Mark Wisel|Desc Funct| FIND | UND L | | |
1901 | DO: Execute extended command +----------+----------+----------+----------+ | |
1902 | | PAGE | SECT | APPEND | DEL W | | |
1903 | C-g: Keyboard Quit | (7) | (8) | (9) | (-) | | |
1904 | G-C-g: Keyboard Quit |Ex Ext Cmd|Fill Regio| REPLACE | UND W | | |
1905 | C-h: Beginning of Line +----------+----------+----------+----------+ | |
1906 | G-C-h: Emacs Help | ADVANCE | BACKUP | CUT | DEL C | | |
1907 | C-i: Tab Insert | (4) | (5) | (6) | (,) | | |
1908 | C-j: Delete to Begin of Word | BOTTOM | TOP | Yank | UND C | | |
1909 | C-k: Define Key +----------+----------+----------+----------+ | |
1910 | G-C-k: Restore Key | WORD | EOL | CHAR | Next | | |
1911 | C-l: Form Feed Insert | (1) | (2) | (3) | Window | | |
1912 | C-n: Set Screen Width 80 | CHNGCASE | DEL EOL |Quoted Ins| ! | |
1913 | C-r: Isearch Backward +---------------------+----------+ (ENTER) | | |
1914 | C-s: Isearch Forward | LINE | SELECT | ! | |
1915 | C-t: Display the Time | (0) | (.) | Query | | |
1916 | C-u: Delete to Begin of Line | Open Line | RESET | Replace | | |
1917 | C-v: Redraw Display +---------------------+----------+----------+ | |
1918 | C-w: Set Screen Width 132 | |
1919 | C-z: Suspend Emacs +----------+----------+----------+ | |
1920 | G-C-\\: Split Window | FNDNXT | Yank | CUT | | |
1921 | | (FIND) | (INSERT) | (REMOVE) | | |
1922 | G-b: Buffer Menu | FIND | | COPY | | |
1923 | G-c: Compile +----------+----------+----------+ | |
1924 | G-d: Delete Window |SELECT/RES|SECT BACKW|SECT FORWA| | |
1925 | G-e: Exit | (SELECT) |(PREVIOUS)| (NEXT) | | |
1926 | G-f: Find File | | | | | |
1927 | G-g: Find File Other Window +----------+----------+----------+ | |
1928 | G-h: Keypad Help | |
1929 | G-i: Insert File | |
1930 | G-k: Toggle Capitalization Word | |
1931 | G-l: Downcase Region | |
1932 | G-m: Save Some Buffers | |
1933 | G-n: Next Error | |
1934 | G-o: Switch to Next Window | |
1935 | G-q: Quit | |
1936 | G-r: Revert File | |
1937 | G-s: Save Buffer | |
1938 | G-u: Upcase Region | |
1939 | G-v: Find File Other Window | |
1940 | G-w: Write file | |
1941 | G-y: EDT Emulation OFF | |
1942 | G-z: Switch to User EDT Key Bindings | |
1943 | G-1: Delete Other Windows | |
1944 | G-2: Split Window | |
1945 | G-%: Go to Percentage | |
1946 | G- : Undo (GOLD Spacebar) | |
1947 | G-=: Go to Line | |
1948 | G-`: What line" | |
1949 | ||
1950 | (interactive) | |
1951 | (describe-function 'edt-keypad-help)) | |
1952 | ||
1953 | (defun edt-electric-helpify (fun) | |
1954 | (let ((name "*Help*")) | |
1955 | (if (save-window-excursion | |
1956 | (let* ((p (symbol-function 'print-help-return-message)) | |
1957 | (b (get-buffer name)) | |
1958 | (m (buffer-modified-p b))) | |
1959 | (and b (not (get-buffer-window b)) | |
1960 | (setq b nil)) | |
1961 | (unwind-protect | |
1962 | (progn | |
1963 | (message "%s..." (capitalize (symbol-name fun))) | |
1964 | (and b | |
1965 | (save-excursion | |
1966 | (set-buffer b) | |
1967 | (set-buffer-modified-p t))) | |
1968 | (fset 'print-help-return-message 'ignore) | |
1969 | (call-interactively fun) | |
1970 | (and (get-buffer name) | |
1971 | (get-buffer-window (get-buffer name)) | |
1972 | (or (not b) | |
1973 | (not (eq b (get-buffer name))) | |
1974 | (not (buffer-modified-p b))))) | |
1975 | (fset 'print-help-return-message p) | |
1976 | (and b (buffer-name b) | |
1977 | (save-excursion | |
1978 | (set-buffer b) | |
1979 | (set-buffer-modified-p m)))))) | |
1980 | (with-electric-help 'delete-other-windows name t)))) | |
1981 | ||
1982 | (defun edt-electric-keypad-help () | |
e4360875 | 1983 | "Display default EDT bindings." |
3bef4fb9 KH |
1984 | (interactive) |
1985 | (edt-electric-helpify 'edt-keypad-help)) | |
1986 | ||
1987 | (defun edt-electric-user-keypad-help () | |
e4360875 | 1988 | "Display user custom EDT bindings." |
3bef4fb9 KH |
1989 | (interactive) |
1990 | (edt-electric-helpify 'edt-user-keypad-help)) | |
1991 | ||
1992 | ;;; | |
a0ac0c19 | 1993 | ;;; EDT emulation screen width commands. |
3bef4fb9 | 1994 | ;;; |
a0ac0c19 KH |
1995 | ;; Some terminals require modification of terminal attributes when changing the |
1996 | ;; number of columns displayed, hence the fboundp tests below. These functions | |
1997 | ;; are defined in the corresponding terminal specific file, if needed. | |
3bef4fb9 KH |
1998 | |
1999 | (defun edt-set-screen-width-80 () | |
2000 | "Set screen width to 80 columns." | |
2001 | (interactive) | |
a0ac0c19 KH |
2002 | (if (fboundp 'edt-set-term-width-80) |
2003 | (edt-set-term-width-80)) | |
3bef4fb9 KH |
2004 | (set-screen-width 80) |
2005 | (message "Screen width 80")) | |
2006 | ||
2007 | (defun edt-set-screen-width-132 () | |
2008 | "Set screen width to 132 columns." | |
2009 | (interactive) | |
a0ac0c19 KH |
2010 | (if (fboundp 'edt-set-term-width-132) |
2011 | (edt-set-term-width-132)) | |
3bef4fb9 KH |
2012 | (set-screen-width 132) |
2013 | (message "Screen width 132")) | |
2014 | ||
2015 | (provide 'edt) | |
1a06eabd ER |
2016 | |
2017 | ;;; edt.el ends here |