1 ;;; edt.el --- Enhanced EDT Keypad Mode Emulation for GNU Emacs 19
3 ;; Copyright (C) 1986, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
5 ;; Author: Kevin Gallagher <kevingal@onramp.net>
6 ;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
7 ;; Keywords: emulations
9 ;; This file is part of GNU Emacs.
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)
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.
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 the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; See edt-user.doc in the Emacs etc directory.
30 ;; ====================================================================
32 ;;; Electric Help functions are used for keypad help displays. A few
33 ;;; picture functions are used in rectangular cut and paste commands.
38 ;;;; VARIABLES and CONSTANTS
41 (defvar edt-last-deleted-lines
""
42 "Last text deleted by an EDT emulation line delete command.")
44 (defvar edt-last-deleted-words
""
45 "Last text deleted by an EDT emulation word delete command.")
47 (defvar edt-last-deleted-chars
""
48 "Last text deleted by an EDT emulation character delete command.")
50 (defvar edt-last-replaced-key-definition
""
51 "Key definition replaced with edt-define-key or edt-learn command.")
53 (defvar edt-direction-string
""
54 "String indicating current direction of movement.")
56 (defvar edt-select-mode nil
57 "Non-nil means select mode is active.")
59 (defvar edt-select-mode-text
""
60 "Text displayed in mode line when select mode is active.")
62 (defconst edt-select-mode-string
" Select"
63 "String to indicate select mode is active.")
65 (defconst edt-forward-string
" ADVANCE"
66 "Direction string in mode line to indicate forward movement.")
68 (defconst edt-backward-string
" BACKUP"
69 "Direction string in mode line to indicate backward movement.")
71 (defvar edt-default-map-active nil
72 "Non-nil indicates that default EDT emulation key bindings are active.
73 Nil means user-defined custom bindings are active.")
75 (defvar edt-user-map-configured nil
76 "Non-nil indicates that user custom EDT key bindings are configured.
77 This means that an edt-user.el file was found in the user's load-path.")
79 (defvar edt-keep-current-page-delimiter nil
80 "Non-nil leaves current value of page-delimiter unchanged.
81 Nil causes the page-delimiter variable to be set to to \"\\f\"
82 when edt-emulation-on is first invoked. Original value is restored
83 when edt-emulation-off is called.")
85 (defvar edt-use-EDT-control-key-bindings nil
86 "Non-nil causes the control key bindings to be replaced with EDT bindings.
87 Nil (the default) means EDT control key bindings are not used and the current
88 control key bindings are retained for use in the EDT emulation.")
90 (defvar edt-word-entities
'(?
\t)
91 "*Specifies the list of EDT word entity characters.")
94 ;;; Emacs version identifiers - currently referenced by
96 ;;; o edt-emulation-on o edt-load-xkeys
98 (defconst edt-emacs19-p
(not (string-lessp emacs-version
"19"))
99 "Non-nil if we are running Lucid or GNU Emacs version 19.")
101 (defconst edt-lucid-emacs19-p
102 (and edt-emacs19-p
(string-match "Lucid" emacs-version
))
103 "Non-nil if we are running Lucid Emacs version 19.")
105 (defconst edt-gnu-emacs19-p
(and edt-emacs19-p
(not edt-lucid-emacs19-p
))
106 "Non-nil if we are running GNU Emacs version 19.")
108 (defvar edt-xkeys-file nil
109 "File mapping X function keys to LK-201 keyboard function and keypad keys.")
112 ;;;; EDT Emulation Commands
115 ;;; Almost all of EDT's keypad mode commands have equivalent
116 ;;; counterparts in Emacs. Some behave the same way in Emacs as they
117 ;;; do in EDT, but most do not.
119 ;;; The following Emacs functions emulate, where practical, the exact
120 ;;; behavior of the corresponding EDT keypad mode commands. In a few
121 ;;; cases, the emulation is not exact, but it is close enough for most
124 ;;; In a very few cases, we chose to use the superior Emacs way of
125 ;;; handling things. For example, we do not emulate the EDT SUBS
126 ;;; command. Instead, we chose to use the superior Emacs
127 ;;; query-replace function.
133 ;;; Emacs uses the regexp assigned to page-delimiter to determine what
134 ;;; marks a page break. This is normally "^\f", which causes the
135 ;;; edt-page command to ignore form feeds not located at the beginning
136 ;;; of a line. To emulate the EDT PAGE command exactly,
137 ;;; page-delimiter is set to "\f" when EDT emulation is turned on, and
138 ;;; restored to its original value when EDT emulation is turned off.
139 ;;; But this can be overridden if the EDT definition is not desired by
142 ;;; (setq edt-keep-current-page-delimiter t)
144 ;;; in your .emacs file.
146 (defun edt-page-forward (num)
147 "Move forward to just after next page delimiter.
148 Accepts a positive prefix argument for the number of page delimiters to move."
150 (edt-check-prefix num
)
152 (error "End of buffer")
156 (edt-line-to-bottom-of-window)
157 (edt-line-to-top-of-window)))))
159 (defun edt-page-backward (num)
160 "Move backward to just after previous page delimiter.
161 Accepts a positive prefix argument for the number of page delimiters to move."
163 (edt-check-prefix num
)
165 (error "Beginning of buffer")
168 (edt-line-to-top-of-window))))
170 (defun edt-page (num)
171 "Move in current direction to next page delimiter.
172 Accepts a positive prefix argument for the number of page delimiters to move."
174 (if (equal edt-direction-string edt-forward-string
)
175 (edt-page-forward num
)
176 (edt-page-backward num
)))
181 ;;; EDT defaults a section size to be 16 lines of its one and only
182 ;;; 24-line window. That's two-thirds of the window at a time. The
183 ;;; EDT SECT commands moves the cursor, not the window.
185 ;;; This emulation of EDT's SECT moves the cursor approximately two-thirds
186 ;;; of the current window at a time.
188 (defun edt-sect-forward (num)
189 "Move cursor forward two-thirds of a window.
190 Accepts a positive prefix argument for the number of sections to move."
192 (edt-check-prefix num
)
193 (edt-line-forward (* (* (/ (- (window-height) 1) 3) 2) num
)))
195 (defun edt-sect-backward (num)
196 "Move cursor backward two-thirds of a window.
197 Accepts a positive prefix argument for the number of sections to move."
199 (edt-check-prefix num
)
200 (edt-line-backward (* (* (/ (- (window-height) 1) 3) 2) num
)))
202 (defun edt-sect (num)
203 "Move in current direction a full window.
204 Accepts a positive prefix argument for the number windows to move."
206 (if (equal edt-direction-string edt-forward-string
)
207 (edt-sect-forward num
)
208 (edt-sect-backward num
)))
211 ;;; BEGINNING OF LINE
213 ;;; EDT's beginning-of-line command is not affected by current
214 ;;; direction, for some unknown reason.
216 (defun edt-beginning-of-line (num)
217 "Move backward to next beginning of line mark.
218 Accepts a positive prefix argument for the number of BOL marks to move."
220 (edt-check-prefix num
)
222 (forward-line (* -
1 num
))
225 (forward-line (* -
1 num
)))))
228 ;;; EOL (End of Line)
231 (defun edt-end-of-line-forward (num)
232 "Move forward to next end of line mark.
233 Accepts a positive prefix argument for the number of EOL marks to move."
235 (edt-check-prefix num
)
239 (defun edt-end-of-line-backward (num)
240 "Move backward to next end of line mark.
241 Accepts a positive prefix argument for the number of EOL marks to move."
243 (edt-check-prefix num
)
244 (end-of-line (1- num
)))
246 (defun edt-end-of-line (num)
247 "Move in current direction to next end of line mark.
248 Accepts a positive prefix argument for the number of EOL marks to move."
250 (if (equal edt-direction-string edt-forward-string
)
251 (edt-end-of-line-forward num
)
252 (edt-end-of-line-backward num
)))
257 ;;; This one is a tad messy. To emulate EDT's behavior everywhere in
258 ;;; the file (beginning of file, end of file, beginning of line, end
259 ;;; of line, etc.) it takes a bit of special handling.
261 ;;; The variable edt-word-entities contains a list of characters which
262 ;;; are to be viewed as distinct words where ever they appear in the
263 ;;; buffer. This emulates the EDT line mode command SET ENTITY WORD.
266 (defun edt-one-word-forward ()
267 "Move forward to first character of next word."
270 (error "End of buffer"))
274 (if (memq (following-char) edt-word-entities
)
279 (not (eq ?\
(char-syntax (following-char))))
280 (not (memq (following-char) edt-word-entities
)))
285 (eq ?\
(char-syntax (following-char)))
286 (not (memq (following-char) edt-word-entities
)))
289 (defun edt-one-word-backward ()
290 "Move backward to first character of previous word."
293 (error "Beginning of buffer"))
301 (eq ?\
(char-syntax (following-char)))
302 (not (memq (following-char) edt-word-entities
)))
304 (if (not (memq (following-char) edt-word-entities
))
308 (not (eq ?\
(char-syntax (preceding-char))))
309 (not (memq (preceding-char) edt-word-entities
)))
312 (defun edt-word-forward (num)
313 "Move forward to first character of next word.
314 Accepts a positive prefix argument for the number of words to move."
316 (edt-check-prefix num
)
318 (edt-one-word-forward)
319 (setq num
(1- num
))))
321 (defun edt-word-backward (num)
322 "Move backward to first character of previous word.
323 Accepts a positive prefix argument for the number of words to move."
325 (edt-check-prefix num
)
327 (edt-one-word-backward)
328 (setq num
(1- num
))))
330 (defun edt-word (num)
331 "Move in current direction to first character of next word.
332 Accepts a positive prefix argument for the number of words to move."
334 (if (equal edt-direction-string edt-forward-string
)
335 (edt-word-forward num
)
336 (edt-word-backward num
)))
342 (defun edt-character (num)
343 "Move in current direction to next character.
344 Accepts a positive prefix argument for the number of characters to move."
346 (edt-check-prefix num
)
347 (if (equal edt-direction-string edt-forward-string
)
349 (backward-char num
)))
354 ;;; When direction is set to BACKUP, LINE behaves just like BEGINNING
355 ;;; OF LINE in EDT. So edt-line-backward is not really needed as a
356 ;;; separate function.
358 (defun edt-line-backward (num)
359 "Move backward to next beginning of line mark.
360 Accepts a positive prefix argument for the number of BOL marks to move."
362 (edt-beginning-of-line num
))
364 (defun edt-line-forward (num)
365 "Move forward to next beginning of line mark.
366 Accepts a positive prefix argument for the number of BOL marks to move."
368 (edt-check-prefix num
)
371 (defun edt-line (num)
372 "Move in current direction to next beginning of line mark.
373 Accepts a positive prefix argument for the number of BOL marks to move."
375 (if (equal edt-direction-string edt-forward-string
)
376 (edt-line-forward num
)
377 (edt-line-backward num
)))
384 "Move cursor to the beginning of buffer."
386 (goto-char (point-min)))
393 "Move cursor to the end of buffer."
395 (goto-char (point-max))
396 (edt-line-to-bottom-of-window))
402 (defun edt-find-forward (&optional find
)
403 "Find first occurrence of a string in forward direction and save it."
406 (set 'search-last-string
(read-string "Search forward: ")))
407 (if (search-forward search-last-string
)
408 (search-backward search-last-string
)))
410 (defun edt-find-backward (&optional find
)
411 "Find first occurrence of a string in the backward direction and save it."
414 (set 'search-last-string
(read-string "Search backward: ")))
415 (search-backward search-last-string
))
418 "Find first occurrence of string in current direction and save it."
420 (set 'search-last-string
(read-string "Search: "))
421 (if (equal edt-direction-string edt-forward-string
)
423 (edt-find-backward t
)))
430 (defun edt-find-next-forward ()
431 "Find next occurrence of a string in forward direction."
434 (if (search-forward search-last-string nil t
)
435 (search-backward search-last-string
)
438 (error "Search failed: \"%s\"." search-last-string
))))
440 (defun edt-find-next-backward ()
441 "Find next occurrence of a string in backward direction."
443 (if (eq (search-backward search-last-string nil t
) nil
)
445 (error "Search failed: \"%s\"." search-last-string
))))
447 (defun edt-find-next ()
448 "Find next occurrence of a string in current direction."
450 (if (equal edt-direction-string edt-forward-string
)
451 (edt-find-next-forward)
452 (edt-find-next-backward)))
459 "Append this kill region to last killed region."
461 (edt-check-selection)
463 (kill-region (mark) (point))
464 (message "Selected text APPENDED to kill ring"))
470 (defun edt-delete-line (num)
471 "Delete from cursor up to and including the end of line mark.
472 Accepts a positive prefix argument for the number of lines to delete."
474 (edt-check-prefix num
)
477 (if (not (eq (preceding-char) ?
\n))
479 (setq edt-last-deleted-lines
480 (buffer-substring beg
(point)))
481 (delete-region beg
(point))))
487 (defun edt-delete-to-end-of-line (num)
488 "Delete from cursor up to but excluding the end of line mark.
489 Accepts a positive prefix argument for the number of lines to delete."
491 (edt-check-prefix num
)
495 (setq edt-last-deleted-lines
496 (buffer-substring beg
(point)))
497 (delete-region beg
(point))))
503 (defun edt-select-mode (arg)
504 "Turn EDT select mode off if ARG is nil; otherwise, turn EDT select mode on.
505 In select mode, selected text is highlighted."
508 (make-local-variable 'edt-select-mode
)
509 (setq edt-select-mode
'edt-select-mode-text
)
510 (setq rect-start-point
(window-point)))
512 (kill-local-variable 'edt-select-mode
)))
513 (force-mode-line-update))
516 "Set mark at cursor and start text selection."
518 (set-mark-command nil
))
521 "Cancel text selection."
530 "Deletes selected text but copies to kill ring."
532 (edt-check-selection)
533 (kill-region (mark) (point))
534 (message "Selected text CUT to kill ring"))
537 ;;; DELETE TO BEGINNING OF LINE
540 (defun edt-delete-to-beginning-of-line (num)
541 "Delete from cursor to beginning of line.
542 Accepts a positive prefix argument for the number of lines to delete."
544 (edt-check-prefix num
)
546 (edt-beginning-of-line num
)
547 (setq edt-last-deleted-lines
548 (buffer-substring (point) beg
))
549 (delete-region beg
(point))))
555 (defun edt-delete-word (num)
556 "Delete from cursor up to but excluding first character of next word.
557 Accepts a positive prefix argument for the number of words to delete."
559 (edt-check-prefix num
)
561 (edt-word-forward num
)
562 (setq edt-last-deleted-words
(buffer-substring beg
(point)))
563 (delete-region beg
(point))))
566 ;;; DELETE TO BEGINNING OF WORD
569 (defun edt-delete-to-beginning-of-word (num)
570 "Delete from cursor to beginning of word.
571 Accepts a positive prefix argument for the number of words to delete."
573 (edt-check-prefix num
)
575 (edt-word-backward num
)
576 (setq edt-last-deleted-words
(buffer-substring (point) beg
))
577 (delete-region beg
(point))))
583 (defun edt-delete-character (num)
584 "Delete character under cursor.
585 Accepts a positive prefix argument for the number of characters to delete."
587 (edt-check-prefix num
)
588 (setq edt-last-deleted-chars
589 (buffer-substring (point) (min (point-max) (+ (point) num
))))
590 (delete-region (point) (min (point-max) (+ (point) num
))))
596 (defun edt-delete-previous-character (num)
597 "Delete character in front of cursor.
598 Accepts a positive prefix argument for the number of characters to delete."
600 (edt-check-prefix num
)
601 (setq edt-last-deleted-chars
602 (buffer-substring (max (point-min) (- (point) num
)) (point)))
603 (delete-region (max (point-min) (- (point) num
)) (point)))
609 (defun edt-undelete-line ()
610 "Undelete previous deleted line(s)."
612 (point-to-register 1)
613 (insert edt-last-deleted-lines
)
614 (register-to-point 1))
620 (defun edt-undelete-word ()
621 "Undelete previous deleted word(s)."
623 (point-to-register 1)
624 (insert edt-last-deleted-words
)
625 (register-to-point 1))
631 (defun edt-undelete-character ()
632 "Undelete previous deleted character(s)."
634 (point-to-register 1)
635 (insert edt-last-deleted-chars
)
636 (register-to-point 1))
642 (defun edt-replace ()
643 "Replace marked section with last CUT (killed) text."
645 (exchange-point-and-mark)
647 (exchange-point-and-mark)
648 (delete-region beg
(point)))
655 (defun edt-advance ()
656 "Set movement direction forward.
657 Also, execute command specified if in Minibuffer."
659 (setq edt-direction-string edt-forward-string
)
660 (force-mode-line-update)
661 (if (string-equal " *Minibuf"
662 (substring (buffer-name) 0 (min (length (buffer-name)) 9)))
670 "Set movement direction backward.
671 Also, execute command specified if in Minibuffer."
673 (setq edt-direction-string edt-backward-string
)
674 (force-mode-line-update)
675 (if (string-equal " *Minibuf"
676 (substring (buffer-name) 0 (min (length (buffer-name)) 9)))
682 ;; This function is based upon Jeff Kowalski's case-flip function in his
685 (defun edt-change-case (num)
686 "Change the case of specified characters.
687 If text selection IS active, then characters between the cursor and mark are
688 changed. If text selection is NOT active, there are two cases. First, if the
689 current direction is ADVANCE, then the prefix number of character(s) under and
690 following cursor are changed. Second, if the current direction is BACKUP, then
691 the prefix number of character(s) before the cursor are changed. Accepts a
692 positive prefix for the number of characters to change, but the prefix is
693 ignored if text selection is active."
695 (edt-check-prefix num
)
697 (let ((end (max (mark) (point)))
698 (point-save (point)))
699 (goto-char (min (point) (mark)))
700 (while (not (eq (point) end
))
701 (funcall (if (<= ?a
(following-char))
702 'upcase-region
'downcase-region
)
703 (point) (1+ (point)))
705 (goto-char point-save
))
707 (if (string= edt-direction-string edt-backward-string
)
710 (funcall (if (<= ?a
(following-char))
711 'upcase-region
'downcase-region
)
712 (point) (1+ (point)))
714 (setq num
(1- num
))))))
720 (defun edt-define-key ()
721 "Assign an interactively-callable function to a specified key sequence.
722 The current key definition is saved in edt-last-replaced-key-definition.
723 Use edt-restore-key to restore last replaced key definition."
726 edt-key-definition-string
)
727 (setq edt-key-definition-string
728 (read-key-sequence "Press the key to be defined: "))
729 (if (string-equal "\C-m" edt-key-definition-string
)
730 (message "Key not defined")
732 (setq edt-function
(read-command "Enter command name: "))
733 (if (string-equal "" edt-function
)
734 (message "Key not defined")
736 (setq edt-last-replaced-key-definition
737 (lookup-key (current-global-map) edt-key-definition-string
))
738 (define-key (current-global-map)
739 edt-key-definition-string edt-function
)))))))
745 (defun edt-form-feed-insert (num)
746 "Insert form feed character at cursor position.
747 Accepts a positive prefix argument for the number of form feeds to insert."
749 (edt-check-prefix num
)
752 (setq num
(1- num
))))
758 (defun edt-tab-insert (num)
759 "Insert tab character at cursor position.
760 Accepts a positive prefix argument for the number of tabs to insert."
762 (edt-check-prefix num
)
765 (setq num
(1- num
))))
771 (defun edt-check-prefix (num)
772 "Indicate error if prefix is not positive."
774 (error "Prefix must be positive")))
780 (defun edt-check-selection ()
781 "Indicate error if EDT selection is not active."
782 (if (not edt-select-mode
)
783 (error "Selection NOT active")))
786 ;;;; ENHANCEMENTS AND ADDITIONS FOR EDT KEYPAD MODE
790 ;;; Several enhancements and additions to EDT keypad mode commands are
791 ;;; provided here. Some of these have been motivated by similar
792 ;;; TPU/EVE and EVE-Plus commands. Others are new.
798 (defun edt-change-direction ()
799 "Toggle movement direction."
801 (if (equal edt-direction-string edt-forward-string
)
809 (defun edt-toggle-select ()
810 "Toggle to start (or cancel) text selection."
820 (defun edt-sentence-forward (num)
821 "Move forward to start of next sentence.
822 Accepts a positive prefix argument for the number of sentences to move."
824 (edt-check-prefix num
)
827 (error "End of buffer"))
829 (forward-sentence num
)
830 (edt-one-word-forward))))
832 (defun edt-sentence-backward (num)
833 "Move backward to next sentence beginning.
834 Accepts a positive prefix argument for the number of sentences to move."
836 (edt-check-prefix num
)
839 (error "End of buffer"))
840 (backward-sentence num
)))
842 (defun edt-sentence (num)
843 "Move in current direction to next sentence.
844 Accepts a positive prefix argument for the number of sentences to move."
846 (if (equal edt-direction-string edt-forward-string
)
847 (edt-sentence-forward num
)
848 (edt-sentence-backward num
)))
854 (defun edt-paragraph-forward (num)
855 "Move forward to beginning of paragraph.
856 Accepts a positive prefix argument for the number of paragraphs to move."
858 (edt-check-prefix num
)
865 (setq num
(1- num
))))
867 (defun edt-paragraph-backward (num)
868 "Move backward to beginning of paragraph.
869 Accepts a positive prefix argument for the number of paragraphs to move."
871 (edt-check-prefix num
)
875 (if (eolp) (next-line 1))
876 (setq num
(1- num
))))
878 (defun edt-paragraph (num)
879 "Move in current direction to next paragraph.
880 Accepts a positive prefix argument for the number of paragraph to move."
882 (if (equal edt-direction-string edt-forward-string
)
883 (edt-paragraph-forward num
)
884 (edt-paragraph-backward num
)))
890 (defun edt-restore-key ()
891 "Restore last replaced key definition.
892 Definition is stored in edt-last-replaced-key-definition."
894 (if edt-last-replaced-key-definition
896 (let (edt-key-definition-string)
897 (set 'edt-key-definition-string
898 (read-key-sequence "Press the key to be restored: "))
899 (if (string-equal "\C-m" edt-key-definition-string
)
900 (message "Key not restored")
901 (define-key (current-global-map)
902 edt-key-definition-string edt-last-replaced-key-definition
))))
903 (error "No replaced key definition to restore!")))
909 (defun edt-window-top ()
910 "Move the cursor to the top of the window."
912 (let ((start-column (current-column)))
913 (move-to-window-line 0)
914 (move-to-column start-column
)))
920 (defun edt-window-bottom ()
921 "Move the cursor to the bottom of the window."
923 (let ((start-column (current-column)))
924 (move-to-window-line (- (window-height) 2))
925 (move-to-column start-column
)))
928 ;;; SCROLL WINDOW LINE
931 (defun edt-scroll-window-forward-line ()
932 "Move window forward one line leaving cursor at position in window."
936 (defun edt-scroll-window-backward-line ()
937 "Move window backward one line leaving cursor at position in window."
941 (defun edt-scroll-line ()
942 "Move window one line in current direction."
944 (if (equal edt-direction-string edt-forward-string
)
945 (edt-scroll-window-forward-line)
946 (edt-scroll-window-backward-line)))
951 ;;; Scroll a window (less one line) at a time. Leave cursor in center of
954 (defun edt-scroll-window-forward (num)
955 "Scroll forward one window in buffer, less one line.
956 Accepts a positive prefix argument for the number of windows to move."
958 (edt-check-prefix num
)
959 (scroll-up (- (* (window-height) num
) 2))
960 (edt-line-forward (/ (- (window-height) 1) 2)))
962 (defun edt-scroll-window-backward (num)
963 "Scroll backward one window in buffer, less one line.
964 Accepts a positive prefix argument for the number of windows to move."
966 (edt-check-prefix num
)
967 (scroll-down (- (* (window-height) num
) 2))
968 (edt-line-backward (/ (- (window-height) 1) 2)))
970 (defun edt-scroll-window (num)
971 "Scroll one window in buffer, less one line, in current direction.
972 Accepts a positive prefix argument for the number windows to move."
974 (if (equal edt-direction-string edt-forward-string
)
975 (edt-scroll-window-forward num
)
976 (edt-scroll-window-backward num
)))
979 ;;; LINE TO BOTTOM OF WINDOW
982 (defun edt-line-to-bottom-of-window ()
983 "Move the current line to the bottom of the window."
988 ;;; LINE TO TOP OF WINDOW
991 (defun edt-line-to-top-of-window ()
992 "Move the current line to the top of the window."
997 ;;; LINE TO MIDDLE OF WINDOW
1000 (defun edt-line-to-middle-of-window ()
1001 "Move window so line with cursor is in the middle of the window."
1009 (defun edt-goto-percentage (num)
1010 "Move to specified percentage in buffer from top of buffer."
1011 (interactive "NGoto-percentage: ")
1012 (if (or (> num
100) (< num
0))
1013 (error "Percentage %d out of range 0 < percent < 100" num
)
1014 (goto-char (/ (* (point-max) num
) 100))))
1020 (defun edt-fill-region ()
1021 "Fill selected text."
1023 (edt-check-selection)
1024 (fill-region (point) (mark)))
1027 ;;; INDENT OR FILL REGION
1030 (defun edt-indent-or-fill-region ()
1031 "Fill region in text modes, indent region in programming language modes."
1033 (if (string= paragraph-start
"$\\|\f")
1034 (indent-region (point) (mark) nil
)
1035 (fill-region (point) (mark))))
1038 ;;; MARK SECTION WISELY
1041 (defun edt-mark-section-wisely ()
1042 "Mark the section in a manner consistent with the major-mode.
1043 Uses mark-defun for emacs-lisp and lisp,
1044 mark-c-function for C,
1045 mark-fortran-subsystem for fortran,
1046 and mark-paragraph for other modes."
1052 (cond ((or (eq major-mode
'emacs-lisp-mode
)
1053 (eq major-mode
'lisp-mode
))
1055 (message "Lisp defun selected"))
1056 ((eq major-mode
'c-mode
)
1058 (message "C function selected"))
1059 ((eq major-mode
'fortran-mode
)
1060 (mark-fortran-subprogram)
1061 (message "Fortran subprogram selected"))
1063 (message "Paragraph selected"))))))
1070 "Copy selected region to kill ring, but don't delete it!"
1072 (edt-check-selection)
1073 (copy-region-as-kill (mark) (point))
1075 (message "Selected text COPIED to kill ring"))
1081 (defun edt-cut-or-copy ()
1082 "Cuts (or copies) selected text to kill ring.
1083 Cuts selected text if buffer-read-only is nil.
1084 Copies selected text if buffer-read-only is t."
1086 (if buffer-read-only
1091 ;;; DELETE ENTIRE LINE
1094 (defun edt-delete-entire-line ()
1095 "Delete entire line regardless of cursor position in the line."
1098 (edt-delete-line 1))
1104 (defun edt-duplicate-line (num)
1105 "Duplicate a line of text.
1106 Accepts a positive prefix argument for the number times to duplicate the line."
1108 (edt-check-prefix num
)
1109 (let ((old-column (current-column))
1111 (edt-delete-entire-line)
1115 (setq count
(1- count
)))
1116 (edt-line-forward num
)
1117 (move-to-column old-column
)))
1123 (defun edt-duplicate-word()
1124 "Duplicate word (or rest of word) found directly above cursor, if any."
1126 (let ((start (point))
1127 (start-column (current-column)))
1129 (move-to-column start-column
)
1130 (if (and (not (equal start
(point)))
1133 (if (and (equal ?
\t (preceding-char))
1134 (< start-column
(current-column)))
1136 (let ((beg (point)))
1137 (edt-one-word-forward)
1138 (setq edt-last-copied-word
(buffer-substring beg
(point))))
1140 (move-to-column start-column
)
1141 (insert edt-last-copied-word
))
1143 (if (not (equal start
(point)))
1145 (move-to-column start-column
)
1146 (error "Nothing to duplicate!")))))
1149 ;;; KEY NOT ASSIGNED
1152 (defun edt-key-not-assigned ()
1153 "Displays message that key has not been assigned to a function."
1155 (error "Key not assigned"))
1158 ;;; TOGGLE CAPITALIZATION OF WORD
1161 (defun edt-toggle-capitalization-of-word ()
1162 "Toggle the capitalization of the current word and move forward to next."
1164 (edt-one-word-forward)
1165 (edt-one-word-backward)
1167 (edt-one-word-backward)
1168 (edt-one-word-forward))
1171 ;;; ELIMINATE ALL TABS
1174 (defun edt-eliminate-all-tabs ()
1175 "Convert all tabs to spaces in the entire buffer."
1177 (untabify (point-min) (point-max))
1178 (message "TABS converted to SPACES"))
1181 ;;; DISPLAY THE TIME
1184 (defun edt-display-the-time ()
1185 "Display the current time."
1187 (set 'time-string
(current-time-string))
1188 (message "%s" time-string
))
1195 "Learn a sequence of key strokes to bind to a key."
1197 (if (eq defining-kbd-macro t
)
1199 (start-kbd-macro nil
)))
1205 (defun edt-remember ()
1206 "Store the sequence of key strokes started by edt-learn to a key."
1208 (if (eq defining-kbd-macro nil
)
1209 (error "Nothing to remember!")
1212 (let (edt-key-definition-string)
1213 (set 'edt-key-definition-string
1214 (read-key-sequence "Enter key for binding: "))
1215 (if (string-equal "\C-m" edt-key-definition-string
)
1216 (message "Key sequence not remembered")
1218 (set 'edt-learn-macro-count
(+ edt-learn-macro-count
1))
1219 (setq edt-last-replaced-key-definition
1220 (lookup-key (current-global-map)
1221 edt-key-definition-string
))
1222 (define-key (current-global-map) edt-key-definition-string
1223 (name-last-kbd-macro
1224 (intern (concat "last-learned-sequence-"
1225 (int-to-string edt-learn-macro-count
)))))))))))
1232 "Save current buffer, ask to save other buffers, and then exit Emacs."
1235 (save-buffers-kill-emacs))
1242 "Quit Emacs without saving changes."
1250 (defun edt-split-window ()
1251 "Split current window and place cursor in the new window."
1260 (defun edt-copy-rectangle ()
1261 "Copy a rectangle of text between mark and cursor to register."
1263 (edt-check-selection)
1264 (copy-rectangle-to-register 3 (region-beginning) (region-end) nil
)
1266 (message "Selected rectangle COPIED to register"))
1272 (defun edt-cut-rectangle-overstrike-mode ()
1273 "Cut a rectangle of text between mark and cursor to register.
1274 Replace cut characters with spaces and moving cursor back to
1277 (edt-check-selection)
1278 (setq edt-rect-start-point
(region-beginning))
1279 (picture-clear-rectangle-to-register (region-beginning) (region-end) 3)
1280 (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point
)
1281 (message "Selected rectangle CUT to register"))
1283 (defun edt-cut-rectangle-insert-mode ()
1284 "Cut a rectangle of text between mark and cursor to register.
1285 Move cursor back to upper left corner."
1287 (edt-check-selection)
1288 (setq edt-rect-start-point
(region-beginning))
1289 (picture-clear-rectangle-to-register (region-beginning) (region-end) 3 t
)
1291 (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point
)
1292 (message "Selected rectangle CUT to register"))
1294 (defun edt-cut-rectangle ()
1295 "Cut a rectangular region of text to register.
1296 If overwrite mode is active, cut text is replaced with whitespace."
1299 (edt-cut-rectangle-overstrike-mode)
1300 (edt-cut-rectangle-insert-mode)))
1306 (defun edt-paste-rectangle-overstrike-mode ()
1307 "Paste a rectangular region of text from register, replacing text at cursor."
1309 (picture-yank-rectangle-from-register 3))
1311 (defun edt-paste-rectangle-insert-mode ()
1312 "Paste previously deleted rectangular region, inserting text at cursor."
1314 (picture-yank-rectangle-from-register 3 t
))
1316 (defun edt-paste-rectangle ()
1317 "Paste a rectangular region of text.
1318 If overwrite mode is active, existing text is replace with text from register."
1321 (edt-paste-rectangle-overstrike-mode)
1322 (edt-paste-rectangle-insert-mode)))
1328 (defun edt-lowercase ()
1329 "Change specified characters to lower case.
1330 If text selection IS active, then characters between the cursor and
1331 mark are changed. If text selection is NOT active, there are two
1332 situations. If the current direction is ADVANCE, then the word under
1333 the cursor is changed to lower case and the cursor is moved to rest at
1334 the beginning of the next word. If the current direction is BACKUP,
1335 the word prior to the word under the cursor is changed to lower case
1336 and the cursor is left to rest at the beginning of that word."
1340 (downcase-region (mark) (point)))
1342 ;; Move to beginning of current word.
1348 (not (eq ?\
(char-syntax (preceding-char))))
1349 (not (memq (preceding-char) edt-word-entities
))
1350 (not (memq (following-char) edt-word-entities
)))
1351 (edt-one-word-backward))
1352 (if (equal edt-direction-string edt-backward-string
)
1353 (edt-one-word-backward))
1354 (let ((beg (point)))
1355 (edt-one-word-forward)
1356 (downcase-region beg
(point)))
1357 (if (equal edt-direction-string edt-backward-string
)
1358 (edt-one-word-backward)))))
1364 (defun edt-uppercase ()
1365 "Change specified characters to upper case.
1366 If text selection IS active, then characters between the cursor and
1367 mark are changed. If text selection is NOT active, there are two
1368 situations. If the current direction is ADVANCE, then the word under
1369 the cursor is changed to upper case and the cursor is moved to rest at
1370 the beginning of the next word. If the current direction is BACKUP,
1371 the word prior to the word under the cursor is changed to upper case
1372 and the cursor is left to rest at the beginning of that word."
1376 (upcase-region (mark) (point)))
1378 ;; Move to beginning of current word.
1384 (not (eq ?\
(char-syntax (preceding-char))))
1385 (not (memq (preceding-char) edt-word-entities
))
1386 (not (memq (following-char) edt-word-entities
)))
1387 (edt-one-word-backward))
1388 (if (equal edt-direction-string edt-backward-string
)
1389 (edt-one-word-backward))
1390 (let ((beg (point)))
1391 (edt-one-word-forward)
1392 (upcase-region beg
(point)))
1393 (if (equal edt-direction-string edt-backward-string
)
1394 (edt-one-word-backward)))))
1398 ;;; INITIALIZATION COMMANDS.
1402 ;;; Emacs version 19 X-windows key definition support
1404 (defvar edt-last-answer nil
1405 "Most recent response to edt-y-or-n-p.")
1407 (defun edt-y-or-n-p (prompt &optional not-yes
)
1408 "Prompt for a y or n answer with positive default.
1409 Optional second argument NOT-YES changes default to negative.
1410 Like emacs y-or-n-p, also accepts space as y and DEL as n."
1411 (message "%s[%s]" prompt
(if not-yes
"n" "y"))
1415 (let ((ans (read-char)))
1416 (cond ((or (= ans ?y
) (= ans ?Y
) (= ans ?\
))
1417 (setq edt-last-answer t
))
1418 ((or (= ans ?n
) (= ans ?N
) (= ans ?\C-?
))
1419 (setq edt-last-answer nil
))
1420 ((= ans ?
\r) (setq edt-last-answer
(not not-yes
)))
1422 (setq doit t
) (beep)
1423 (message "Please answer y or n. %s[%s]"
1424 prompt
(if not-yes
"n" "y")))))))
1427 (defun edt-load-xkeys (file)
1428 "Load the EDT X-windows key definitions FILE.
1429 If FILE is nil, try to load a default file. The default file names are
1430 ~/.edt-lucid-keys for Lucid emacs, and ~/.edt-gnu-keys for GNU emacs."
1431 (interactive "fX key definition file: ")
1433 (setq file
(expand-file-name file
)))
1435 (setq file
(expand-file-name edt-xkeys-file
)))
1437 (setq file
(expand-file-name "~/.edt-gnu-keys")))
1438 (edt-lucid-emacs19-p
1439 (setq file
(expand-file-name "~/.edt-lucid-keys"))))
1440 (cond ((file-readable-p file
)
1443 (switch-to-buffer "*scratch*")
1447 Ack!! You're running the Enhanced EDT Emulation under X-windows
1448 without loading an EDT X key definition file. To create an EDT X
1449 key definition file, run the edt-mapper.el program. But ONLY run
1450 it from an Emacs loaded without any of your own customizations
1451 found in your .emacs file, etc. Some user customization confuse
1452 the edt-mapper function. To do this, you need to invoke Emacs
1455 emacs -q -l edt-mapper.el
1457 The file edt-mapper.el includes these same directions on how to
1458 use it! Perhaps it's lying around here someplace. \n ")
1459 (let ((file "edt-mapper.el")
1462 (search-list (append (list (expand-file-name ".")) load-path
)))
1463 (while (and (not found
) search-list
)
1464 (setq path
(concat (car search-list
)
1465 (if (string-match "/$" (car search-list
)) "" "/")
1467 (if (and (file-exists-p path
) (not (file-directory-p path
)))
1469 (setq search-list
(cdr search-list
)))
1472 "Ah yes, there it is, in \n\n %s \n\n" path
))
1473 (if (edt-y-or-n-p "Do you want to run it now? ")
1475 (error "EDT Emulation not configured.")))
1477 (insert "Nope, I can't seem to find it. :-(\n\n")
1479 (error "EDT Emulation not configured.")))))))
1482 (defun edt-emulation-on ()
1483 "Turn on EDT Emulation."
1485 ;; If using MS-DOS or Windows, need to load edt-pc.el
1486 (if (memq system-type
'(ms-dos windows-nt
))
1487 (setq edt-term
"pc")
1488 (setq edt-term
(or (getenv "TERM") "")))
1489 ;; All DEC VT series terminals are supported by loading edt-vt100.el
1490 (if (string-equal "vt" (substring edt-term
0 (min (length edt-term
) 2)))
1491 (setq edt-term
"vt100"))
1492 ;; Load EDT terminal specific configuration file.
1493 (let ((term edt-term
)
1496 (not (load (concat "edt-" term
) t t
)))
1497 ;; Strip off last hyphen and what follows, then try again
1498 (if (setq hyphend
(string-match "[-_][^-_]+$" term
))
1499 (setq term
(substring term
0 hyphend
))
1501 ;; Override terminal-specific file if running X Windows. X Windows support
1502 ;; is handled differently in edt-load-xkeys
1503 (if (eq window-system
'x
)
1504 (edt-load-xkeys nil
)
1506 (error "Unable to load EDT terminal specific file for %s" edt-term
)))
1507 (setq edt-term term
))
1508 (setq edt-orig-transient-mark-mode transient-mark-mode
)
1509 (add-hook 'activate-mark-hook
1512 (edt-select-mode t
))))
1513 (add-hook 'deactivate-mark-hook
1516 (edt-select-mode nil
))))
1517 (if (load "edt-user" t t
)
1518 (edt-user-emulation-setup)
1519 (edt-default-emulation-setup)))
1521 (defun edt-emulation-off()
1522 "Select original global key bindings, disabling EDT Emulation."
1524 (use-global-map global-map
)
1525 (if (not edt-keep-current-page-delimiter
)
1526 (setq page-delimiter edt-orig-page-delimiter
))
1527 (setq edt-direction-string
"")
1528 (setq edt-select-mode-text nil
)
1530 (force-mode-line-update t
)
1531 (setq transient-mark-mode edt-orig-transient-mark-mode
)
1532 (message "Original key bindings restored; EDT Emulation disabled"))
1534 (defun edt-default-emulation-setup (&optional user-setup
)
1535 "Setup emulation of DEC's EDT editor."
1536 ;; Setup default EDT global map by copying global map bindings.
1537 ;; This preserves ESC and C-x prefix bindings and other bindings we
1538 ;; wish to retain in EDT emulation mode keymaps. It also permits
1539 ;; customization of these bindings in the EDT global maps without
1540 ;; disturbing the original bindings in global-map.
1541 (fset 'edt-default-ESC-prefix
(copy-keymap 'ESC-prefix
))
1542 (setq edt-default-global-map
(copy-keymap (current-global-map)))
1543 (define-key edt-default-global-map
"\e" 'edt-default-ESC-prefix
)
1544 (define-prefix-command 'edt-default-gold-map
)
1545 (edt-setup-default-bindings)
1546 ;; If terminal has additional function keys, the terminal-specific
1547 ;; initialization file can assign bindings to them via the optional
1548 ;; function edt-setup-extra-default-bindings.
1549 (if (fboundp 'edt-setup-extra-default-bindings
)
1550 (edt-setup-extra-default-bindings))
1551 ;; Variable needed by edt-learn.
1552 (setq edt-learn-macro-count
0)
1553 ;; Display EDT text selection active within the mode line
1554 (or (assq 'edt-select-mode minor-mode-alist
)
1555 (setq minor-mode-alist
1556 (cons '(edt-select-mode edt-select-mode
) minor-mode-alist
)))
1557 ;; Display EDT direction of motion within the mode line
1558 (or (assq 'edt-direction-string minor-mode-alist
)
1559 (setq minor-mode-alist
1561 '(edt-direction-string edt-direction-string
) minor-mode-alist
)))
1564 (setq edt-user-map-configured t
)
1565 (fset 'edt-emulation-on
(symbol-function 'edt-select-user-global-map
)))
1567 (fset 'edt-emulation-on
(symbol-function 'edt-select-default-global-map
))
1568 (edt-select-default-global-map))))
1570 (defun edt-user-emulation-setup ()
1571 "Setup user custom emulation of DEC's EDT editor."
1572 ;; Initialize EDT default bindings.
1573 (edt-default-emulation-setup t
)
1574 ;; Setup user EDT global map by copying default EDT global map bindings.
1575 (fset 'edt-user-ESC-prefix
(copy-keymap 'edt-default-ESC-prefix
))
1576 (setq edt-user-global-map
(copy-keymap edt-default-global-map
))
1577 (define-key edt-user-global-map
"\e" 'edt-user-ESC-prefix
)
1578 ;; If terminal has additional function keys, the user's initialization
1579 ;; file can assign bindings to them via the optional
1580 ;; function edt-setup-extra-default-bindings.
1581 (define-prefix-command 'edt-user-gold-map
)
1582 (fset 'edt-user-gold-map
(copy-keymap 'edt-default-gold-map
))
1583 (edt-setup-user-bindings)
1584 (edt-select-user-global-map))
1586 (defun edt-select-default-global-map()
1587 "Select default EDT emulation key bindings."
1589 (transient-mark-mode 1)
1590 (use-global-map edt-default-global-map
)
1591 (if (not edt-keep-current-page-delimiter
)
1593 (setq edt-orig-page-delimiter page-delimiter
)
1594 (setq page-delimiter
"\f")))
1595 (setq edt-default-map-active t
)
1597 (setq edt-select-mode-text
'edt-select-mode-string
)
1599 (message "Default EDT keymap active"))
1601 (defun edt-select-user-global-map()
1602 "Select user EDT emulation custom key bindings."
1604 (if edt-user-map-configured
1606 (transient-mark-mode 1)
1607 (use-global-map edt-user-global-map
)
1608 (if (not edt-keep-current-page-delimiter
)
1610 (setq edt-orig-page-delimiter page-delimiter
)
1611 (setq page-delimiter
"\f")))
1612 (setq edt-default-map-active nil
)
1614 (setq edt-select-mode-text
'edt-select-mode-string
)
1616 (message "User EDT custom keymap active"))
1617 (error "User EDT custom keymap NOT configured!")))
1619 (defun edt-switch-global-maps ()
1620 "Toggle between default EDT keymap and user EDT keymap."
1622 (if edt-default-map-active
1623 (edt-select-user-global-map)
1624 (edt-select-default-global-map)))
1626 ;; There are three key binding functions needed: one for standard keys
1627 ;; (used to bind control keys, primarily), one for Gold sequences of
1628 ;; standard keys, and one for function keys.
1630 (defun edt-bind-gold-key (key gold-binding
&optional default
)
1631 "Binds commands to a gold key sequence in the EDT Emulator."
1633 (define-key 'edt-default-gold-map key gold-binding
)
1634 (define-key 'edt-user-gold-map key gold-binding
)))
1636 (defun edt-bind-standard-key (key gold-binding
&optional default
)
1637 "Bind commands to a gold key sequence in the default EDT keymap."
1639 (define-key edt-default-global-map key gold-binding
)
1640 (define-key edt-user-global-map key gold-binding
)))
1642 (defun edt-bind-function-key
1643 (function-key binding gold-binding
&optional default
)
1644 "Binds function keys in the EDT Emulator."
1645 (catch 'edt-key-not-supported
1646 (let ((key-vector (cdr (assoc function-key
*EDT-keys
*))))
1647 (if (stringp key-vector
)
1648 (throw 'edt-key-not-supported t
))
1649 (if (not (null key-vector
))
1653 (define-key edt-default-global-map key-vector binding
)
1654 (define-key 'edt-default-gold-map key-vector gold-binding
))
1656 (define-key edt-user-global-map key-vector binding
)
1657 (define-key 'edt-user-gold-map key-vector gold-binding
))))
1658 (error "%s is not a legal function key name" function-key
)))))
1660 (defun edt-setup-default-bindings ()
1661 "Assigns default EDT Emulation keyboard bindings."
1663 ;; Function Key Bindings: Regular and GOLD.
1665 ;; VT100/VT200/VT300 PF1 (GOLD), PF2, PF3, PF4 Keys
1666 (edt-bind-function-key "PF1" 'edt-default-gold-map
'edt-mark-section-wisely t
)
1667 (edt-bind-function-key "PF2" 'edt-electric-keypad-help
'describe-function t
)
1668 (edt-bind-function-key "PF3" 'edt-find-next
'edt-find t
)
1669 (edt-bind-function-key "PF4" 'edt-delete-line
'edt-undelete-line t
)
1671 ;; VT100/VT200/VT300 Arrow Keys
1672 (edt-bind-function-key "UP" 'previous-line
'edt-window-top t
)
1673 (edt-bind-function-key "DOWN" 'next-line
'edt-window-bottom t
)
1674 (edt-bind-function-key "LEFT" 'backward-char
'edt-sentence-backward t
)
1675 (edt-bind-function-key "RIGHT" 'forward-char
'edt-sentence-forward t
)
1677 ;; VT100/VT200/VT300 Keypad Keys
1678 (edt-bind-function-key "KP0" 'edt-line
'open-line t
)
1679 (edt-bind-function-key "KP1" 'edt-word
'edt-change-case t
)
1680 (edt-bind-function-key "KP2" 'edt-end-of-line
'edt-delete-to-end-of-line t
)
1681 (edt-bind-function-key "KP3" 'edt-character
'quoted-insert t
)
1682 (edt-bind-function-key "KP4" 'edt-advance
'edt-bottom t
)
1683 (edt-bind-function-key "KP5" 'edt-backup
'edt-top t
)
1684 (edt-bind-function-key "KP6" 'edt-cut
'yank t
)
1685 (edt-bind-function-key "KP7" 'edt-page
'execute-extended-command t
)
1686 (edt-bind-function-key "KP8" 'edt-sect
'edt-fill-region t
)
1687 (edt-bind-function-key "KP9" 'edt-append
'edt-replace t
)
1688 (edt-bind-function-key "KP-" 'edt-delete-word
'edt-undelete-word t
)
1689 (edt-bind-function-key "KP," 'edt-delete-character
'edt-undelete-character t
)
1690 (edt-bind-function-key "KPP" 'edt-select
'edt-reset t
)
1691 (edt-bind-function-key "KPE" 'other-window
'query-replace t
)
1693 ;; VT200/VT300 Function Keys
1694 ;; (F1 through F5, on the VT220, are not programmable, so we skip
1695 ;; making default bindings to those keys.
1696 (edt-bind-function-key "FIND" 'edt-find-next
'edt-find t
)
1697 (edt-bind-function-key "INSERT" 'yank
'edt-key-not-assigned t
)
1698 (edt-bind-function-key "REMOVE" 'edt-cut
'edt-copy t
)
1699 (edt-bind-function-key "SELECT" 'edt-toggle-select
'edt-key-not-assigned t
)
1700 (edt-bind-function-key "NEXT" 'edt-sect-forward
'edt-key-not-assigned t
)
1701 (edt-bind-function-key "PREVIOUS" 'edt-sect-backward
'edt-key-not-assigned t
)
1702 (edt-bind-function-key "F6" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1703 (edt-bind-function-key "F7" 'edt-copy-rectangle
'edt-key-not-assigned t
)
1704 (edt-bind-function-key "F8"
1705 'edt-cut-rectangle-overstrike-mode
'edt-paste-rectangle-overstrike-mode t
)
1706 (edt-bind-function-key "F9"
1707 'edt-cut-rectangle-insert-mode
'edt-paste-rectangle-insert-mode t
)
1708 (edt-bind-function-key "F10" 'edt-cut-rectangle
'edt-paste-rectangle t
)
1709 ;; Under X, the F11 key can be bound. If using a VT-200 or higher terminal,
1710 ;; the default emacs terminal support causes the VT F11 key to seem as if it
1711 ;; is an ESC key when in emacs.
1712 (edt-bind-function-key "F11"
1713 'edt-key-not-assigned
'edt-key-not-assigned t
)
1714 (edt-bind-function-key "F12"
1715 'edt-beginning-of-line
'delete-other-windows t
) ;BS
1716 (edt-bind-function-key "F13"
1717 'edt-delete-to-beginning-of-word
'edt-key-not-assigned t
) ;LF
1718 (edt-bind-function-key "F14" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1719 (edt-bind-function-key "HELP" 'edt-electric-keypad-help
'edt-key-not-assigned t
)
1720 (edt-bind-function-key "DO" 'execute-extended-command
'edt-key-not-assigned t
)
1721 (edt-bind-function-key "F17" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1722 (edt-bind-function-key "F18" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1723 (edt-bind-function-key "F19" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1724 (edt-bind-function-key "F20" 'edt-key-not-assigned
'edt-key-not-assigned t
)
1726 ;; Control key bindings: Regular and GOLD
1728 ;; Standard EDT control key bindings conflict with standard Emacs
1729 ;; control key bindings. Normally, the standard Emacs control key
1730 ;; bindings are left unchanged in the default EDT mode. However, if
1731 ;; the variable edt-use-EDT-control-key-bindings is set to true
1732 ;; before invoking edt-emulation-on for the first time, then the
1733 ;; standard EDT bindings (with some enhancements) as defined here are
1735 (if edt-use-EDT-control-key-bindings
1737 (edt-bind-standard-key "\C-a" 'edt-key-not-assigned t
)
1738 (edt-bind-standard-key "\C-b" 'edt-key-not-assigned t
)
1739 ;; Leave binding of C-c as original prefix key.
1740 (edt-bind-standard-key "\C-d" 'edt-key-not-assigned t
)
1741 (edt-bind-standard-key "\C-e" 'edt-key-not-assigned t
)
1742 (edt-bind-standard-key "\C-f" 'edt-key-not-assigned t
)
1743 ;; Leave binding of C-g to keyboard-quit
1744 ; (edt-bind-standard-key "\C-g" 'keyboard-quit t)
1745 ;; Standard EDT binding of C-h. To invoke Emacs help, use
1746 ;; GOLD-C-h instead.
1747 (edt-bind-standard-key "\C-h" 'edt-beginning-of-line t
)
1748 (edt-bind-standard-key "\C-i" 'edt-tab-insert t
)
1749 (edt-bind-standard-key "\C-j" 'edt-delete-to-beginning-of-word t
)
1750 (edt-bind-standard-key "\C-k" 'edt-define-key t
)
1751 (edt-bind-gold-key "\C-k" 'edt-restore-key t
)
1752 (edt-bind-standard-key "\C-l" 'edt-form-feed-insert t
)
1753 ;; Leave binding of C-m to newline.
1754 (edt-bind-standard-key "\C-n" 'edt-set-screen-width-80 t
)
1755 (edt-bind-standard-key "\C-o" 'edt-key-not-assigned t
)
1756 (edt-bind-standard-key "\C-p" 'edt-key-not-assigned t
)
1757 (edt-bind-standard-key "\C-q" 'edt-key-not-assigned t
)
1758 ;; Leave binding of C-r to isearch-backward.
1759 ;; Leave binding of C-s to isearch-forward.
1760 (edt-bind-standard-key "\C-t" 'edt-display-the-time t
)
1761 (edt-bind-standard-key "\C-u" 'edt-delete-to-beginning-of-line t
)
1762 (edt-bind-standard-key "\C-v" 'redraw-display t
)
1763 (edt-bind-standard-key "\C-w" 'edt-set-screen-width-132 t
)
1764 ;; Leave binding of C-x as original prefix key.
1765 (edt-bind-standard-key "\C-y" 'edt-key-not-assigned t
)
1766 ; (edt-bind-standard-key "\C-z" 'suspend-emacs t)
1770 ;; GOLD bindings for a few Control keys.
1771 (edt-bind-gold-key "\C-g" 'keyboard-quit t
); Just in case.
1772 (edt-bind-gold-key "\C-h" 'help-for-help t
)
1773 (edt-bind-gold-key [f1] 'help-for-help t)
1774 (edt-bind-gold-key [help] 'help-for-help t)
1775 (edt-bind-gold-key "\C-\\" 'split-window-vertically t)
1777 ;; GOLD bindings for regular keys.
1778 (edt-bind-gold-key "a" 'edt-key-not-assigned t)
1779 (edt-bind-gold-key "A" 'edt-key-not-assigned t)
1780 (edt-bind-gold-key "b" 'buffer-menu t)
1781 (edt-bind-gold-key "B" 'buffer-menu t)
1782 (edt-bind-gold-key "c" 'compile t)
1783 (edt-bind-gold-key "C" 'compile t)
1784 (edt-bind-gold-key "d" 'delete-window t)
1785 (edt-bind-gold-key "D" 'delete-window t)
1786 (edt-bind-gold-key "e" 'edt-exit t)
1787 (edt-bind-gold-key "E" 'edt-exit t)
1788 (edt-bind-gold-key "f" 'find-file t)
1789 (edt-bind-gold-key "F" 'find-file t)
1790 (edt-bind-gold-key "g" 'find-file-other-window t)
1791 (edt-bind-gold-key "G" 'find-file-other-window t)
1792 (edt-bind-gold-key "h" 'edt-electric-keypad-help t)
1793 (edt-bind-gold-key "H" 'edt-electric-keypad-help t)
1794 (edt-bind-gold-key "i" 'insert-file t)
1795 (edt-bind-gold-key "I" 'insert-file t)
1796 (edt-bind-gold-key "j" 'edt-key-not-assigned t)
1797 (edt-bind-gold-key "J" 'edt-key-not-assigned t)
1798 (edt-bind-gold-key "k" 'edt-toggle-capitalization-of-word t)
1799 (edt-bind-gold-key "K" 'edt-toggle-capitalization-of-word t)
1800 (edt-bind-gold-key "l" 'edt-lowercase t)
1801 (edt-bind-gold-key "L" 'edt-lowercase t)
1802 (edt-bind-gold-key "m" 'save-some-buffers t)
1803 (edt-bind-gold-key "M" 'save-some-buffers t)
1804 (edt-bind-gold-key "n" 'next-error t)
1805 (edt-bind-gold-key "N" 'next-error t)
1806 (edt-bind-gold-key "o" 'switch-to-buffer-other-window t)
1807 (edt-bind-gold-key "O" 'switch-to-buffer-other-window t)
1808 (edt-bind-gold-key "p" 'edt-key-not-assigned t)
1809 (edt-bind-gold-key "P" 'edt-key-not-assigned t)
1810 (edt-bind-gold-key "q" 'edt-quit t)
1811 (edt-bind-gold-key "Q" 'edt-quit t)
1812 (edt-bind-gold-key "r" 'revert-buffer t)
1813 (edt-bind-gold-key "R" 'revert-buffer t)
1814 (edt-bind-gold-key "s" 'save-buffer t)
1815 (edt-bind-gold-key "S" 'save-buffer t)
1816 (edt-bind-gold-key "t" 'edt-key-not-assigned t)
1817 (edt-bind-gold-key "T" 'edt-key-not-assigned t)
1818 (edt-bind-gold-key "u" 'edt-uppercase t)
1819 (edt-bind-gold-key "U" 'edt-uppercase t)
1820 (edt-bind-gold-key "v" 'find-file-other-window t)
1821 (edt-bind-gold-key "V" 'find-file-other-window t)
1822 (edt-bind-gold-key "w" 'write-file t)
1823 (edt-bind-gold-key "W" 'write-file t)
1824 (edt-bind-gold-key "x" 'edt-key-not-assigned t)
1825 (edt-bind-gold-key "X" 'edt-key-not-assigned t)
1826 (edt-bind-gold-key "y" 'edt-emulation-off t)
1827 (edt-bind-gold-key "Y" 'edt-emulation-off t)
1828 (edt-bind-gold-key "z" 'edt-switch-global-maps t)
1829 (edt-bind-gold-key "Z" 'edt-switch-global-maps t)
1830 (edt-bind-gold-key "1" 'delete-other-windows t)
1831 (edt-bind-gold-key "!" 'edt-key-not-assigned t)
1832 (edt-bind-gold-key "2" 'edt-split-window t)
1833 (edt-bind-gold-key "@" 'edt-key-not-assigned t)
1834 (edt-bind-gold-key "3" 'edt-key-not-assigned t)
1835 (edt-bind-gold-key "#" 'edt-key-not-assigned t)
1836 (edt-bind-gold-key "4" 'edt-key-not-assigned t)
1837 (edt-bind-gold-key "$" 'edt-key-not-assigned t)
1838 (edt-bind-gold-key "5" 'edt-key-not-assigned t)
1839 (edt-bind-gold-key "%" 'edt-goto-percentage t)
1840 (edt-bind-gold-key "6" 'edt-key-not-assigned t)
1841 (edt-bind-gold-key "^" 'edt-key-not-assigned t)
1842 (edt-bind-gold-key "7" 'edt-key-not-assigned t)
1843 (edt-bind-gold-key "&" 'edt-key-not-assigned t)
1844 (edt-bind-gold-key "8" 'edt-key-not-assigned t)
1845 (edt-bind-gold-key "*" 'edt-key-not-assigned t)
1846 (edt-bind-gold-key "9" 'edt-key-not-assigned t)
1847 (edt-bind-gold-key "(" 'edt-key-not-assigned t)
1848 (edt-bind-gold-key "0" 'edt-key-not-assigned t)
1849 (edt-bind-gold-key ")" 'edt-key-not-assigned t)
1850 (edt-bind-gold-key " " 'undo 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 "_" 'edt-key-not-assigned t)
1865 (edt-bind-gold-key "=" 'goto-line 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 "}" 'edt-key-not-assigned t)
1871 (edt-bind-gold-key "`" 'what-line t)
1872 (edt-bind-gold-key "~" 'edt-key-not-assigned t)
1876 ;;; DEFAULT EDT KEYPAD HELP
1880 ;;; Upper case commands in the keypad diagram below indicate that the
1881 ;;; emulation should look and feel very much like EDT. Lower case
1882 ;;; commands are enhancements and/or additions to the EDT keypad
1883 ;;; commands or are native Emacs commands.
1886 (defun edt-keypad-help ()
1888 DEFAULT EDT Keypad Active
1890 F7: Copy Rectangle +----------+----------+----------+----------+
1891 F8: Cut Rect Overstrike |Prev Line |Next Line |Bkwd Char |Frwd Char |
1892 G-F8: Paste Rect Overstrike | (UP) | (DOWN) | (LEFT) | (RIGHT) |
1893 F9: Cut Rect Insert |Window Top|Window Bot|Bkwd Sent |Frwd Sent |
1894 G-F9: Paste Rect Insert +----------+----------+----------+----------+
1896 G-F10: Paste Rectangle
1898 F12: Begining of Line +----------+----------+----------+----------+
1899 G-F12: Delete Other Windows | GOLD | HELP | FNDNXT | DEL L |
1900 F13: Delete to Begin of Word | (PF1) | (PF2) | (PF3) | (PF4) |
1901 HELP: Keypad Help |Mark Wisel|Desc Funct| FIND | UND L |
1902 DO: Execute extended command +----------+----------+----------+----------+
1903 | PAGE | SECT | APPEND | DEL W |
1904 C-g: Keyboard Quit | (7) | (8) | (9) | (-) |
1905 G-C-g: Keyboard Quit |Ex Ext Cmd|Fill Regio| REPLACE | UND W |
1906 C-h: Beginning of Line +----------+----------+----------+----------+
1907 G-C-h: Emacs Help | ADVANCE | BACKUP | CUT | DEL C |
1908 C-i: Tab Insert | (4) | (5) | (6) | (,) |
1909 C-j: Delete to Begin of Word | BOTTOM | TOP | Yank | UND C |
1910 C-k: Define Key +----------+----------+----------+----------+
1911 G-C-k: Restore Key | WORD | EOL | CHAR | Next |
1912 C-l: Form Feed Insert | (1) | (2) | (3) | Window |
1913 C-n: Set Screen Width 80 | CHNGCASE | DEL EOL |Quoted Ins| !
1914 C-r: Isearch Backward +---------------------+----------+ (ENTER) |
1915 C-s: Isearch Forward | LINE | SELECT | !
1916 C-t: Display the Time | (0) | (.) | Query |
1917 C-u: Delete to Begin of Line | Open Line | RESET | Replace |
1918 C-v: Redraw Display +---------------------+----------+----------+
1919 C-w: Set Screen Width 132
1920 C-z: Suspend Emacs +----------+----------+----------+
1921 G-C-\\: Split Window | FNDNXT | Yank | CUT |
1922 | (FIND) | (INSERT) | (REMOVE) |
1923 G-b: Buffer Menu | FIND | | COPY |
1924 G-c: Compile +----------+----------+----------+
1925 G-d: Delete Window |SELECT/RES|SECT BACKW|SECT FORWA|
1926 G-e: Exit | (SELECT) |(PREVIOUS)| (NEXT) |
1927 G-f: Find File | | | |
1928 G-g: Find File Other Window +----------+----------+----------+
1931 G-k: Toggle Capitalization Word
1932 G-l: Downcase Region
1933 G-m: Save Some Buffers
1935 G-o: Switch to Next Window
1940 G-v: Find File Other Window
1942 G-y: EDT Emulation OFF
1943 G-z: Switch to User EDT Key Bindings
1944 G-1: Delete Other Windows
1946 G-%: Go to Percentage
1947 G- : Undo (GOLD Spacebar)
1952 (describe-function 'edt-keypad-help))
1954 (defun edt-electric-helpify (fun)
1955 (let ((name "*Help*"))
1956 (if (save-window-excursion
1957 (let* ((p (symbol-function 'print-help-return-message))
1958 (b (get-buffer name))
1959 (m (buffer-modified-p b)))
1960 (and b (not (get-buffer-window b))
1964 (message "%s..." (capitalize (symbol-name fun)))
1968 (set-buffer-modified-p t)))
1969 (fset 'print-help-return-message 'ignore)
1970 (call-interactively fun)
1971 (and (get-buffer name)
1972 (get-buffer-window (get-buffer name))
1974 (not (eq b (get-buffer name)))
1975 (not (buffer-modified-p b)))))
1976 (fset 'print-help-return-message p)
1977 (and b (buffer-name b)
1980 (set-buffer-modified-p m))))))
1981 (with-electric-help 'delete-other-windows name t))))
1983 (defun edt-electric-keypad-help ()
1984 "Display default EDT bindings."
1986 (edt-electric-helpify 'edt-keypad-help))
1988 (defun edt-electric-user-keypad-help ()
1989 "Display user custom EDT bindings."
1991 (edt-electric-helpify 'edt-user-keypad-help))
1994 ;;; EDT emulation screen width commands.
1996 ;; Some terminals require modification of terminal attributes when changing the
1997 ;; number of columns displayed, hence the fboundp tests below. These functions
1998 ;; are defined in the corresponding terminal specific file, if needed.
2000 (defun edt-set-screen-width-80 ()
2001 "Set screen width to 80 columns."
2003 (if (fboundp 'edt-set-term-width-80)
2004 (edt-set-term-width-80))
2005 (set-screen-width 80)
2006 (message "Screen width 80"))
2008 (defun edt-set-screen-width-132 ()
2009 "Set screen width to 132 columns."
2011 (if (fboundp 'edt-set-term-width-132)
2012 (edt-set-term-width-132))
2013 (set-screen-width 132)
2014 (message "Screen width 132"))
2018 ;;; edt.el ends here