Emacs/EDT hybrid
Lynn Olson
lynno at tektronix.UUCP
Tue Feb 14 16:05:45 AEST 1984
[sacrificial first line for hungry relay sites]
This file eases the pain for VMS users making the transition onto
a UNIX system, provided that the system has the James Gosling's CMU Emacs
installed. This .emacs_pro file combines the keypad characteristics of the
DEC EDT editor with the flexibility of the Emacs editor. The keypad
controls windows, cut-and-pastes, cursor motion, deletes, undeletes, and
a multistep UNDO function. It does require a VT-100 or similar ANSI X3.64
terminal to generate appropriate escape sequences from the keypad.
The file replaces the default .emacs_pro file with the material below.
;This .emacs_pro file maps the keypad of a VT-Series terminal into a command
;set resembling the DEC EDT (tm) editor. Most of the unshifted functions are
;unaltered - removing only three EDT functions, PAGE, CHAR, and ENTER. These
;are redefined into Paragraph, Window, and Newline-and-Indent.
;BackSpace is used in the usual UNIX (tm) fashion to delete previous
;characters, leaving the Delete key to serve as the Beginning-of-Line. This is
;the reverse of the DEC EDT editor, true, but is preferable to having different
;delete keys in and out of Emacs. LineFeed is used for the EDT function of
;delete-previous-word.
;
;The shifted GOLD/Keys are mostly unaltered, with SPECINS replaced
;by ^\, UND W and UND C replaced by UND LWC. SUBS and RESET are eliminated.
;All of these keys are redefined as:
;
;SPECINS -> : Copy Mark/Dot Region
;UND W -> : Split Window
;UND C -> : Visit Buffer
;SUBS -> : Visit File
;RESET -> : Exchange Mark/Dot
;
; New commands are GOLD/GOLD, which turns on the new-undo function.
;Other new commands are GOLD/keyboard pairs, which are mapped as follows:
;
;GOLD/up-arrow : Current line to top of window.
;GOLD/down-arrow: Current line to bottom of window.
;GOLD/left-arrow: Backward sentence.
;GOLD/right-arrow: Forward sentence.
;GOLD/- : Goto percentage of buffer.
;GOLD/= : Goto line number.
;GOLD/` : Display line number and character number.
;GOLD/p : Delete selected buffer.
;GOLD/[ : Delete Mark/Dot region to selected buffer.
;GOLD/] : Paste selected buffer at dot.
;GOLD/BackSpace : Delete other windows.
;GOLD/Delete : List Buffers.
;GOLD/ \ : Capitalize word.
;GOLD/LineFeed : Delete-next-word. (Deletes fragments, unlike Del W).
;
; The following commands alter the Emacs default key map. Aside from
;these changes, all other Emacs commands retain the documented bindings.
;
; Delete : Beginning-of-Line.
; LineFeed : Delete-Previous-Word.
; ^A : Enlarge current window.
; ^Q : Reserved for X-ON flow control.
; ^S : Reserved for X-OFF flow control.
; ^Z : Extended-Command, with prompts for different exits.
; ^_ : Pause-Emacs. (Type "fg" to restore paused Emacs.)
;
;
(defun
;This deletes the entire current line and allows chaining
;similar to the ^K (kill-to-end-of-line) function. The
;(chained) text is put in the Line buffer and retrieved by
;the GOLD/Und LWC keys.
;
(delete-current-line
(beginning-of-line)
(set-mark)
(next-line)
(if (= -48 (previous-command))
(progn
(append-region-to-buffer "Line\040buffer")
(erase-region)
)
(delete-region-to-buffer "Line\040buffer")
)
(setq this-command -48)
)
;
;This allows the Del EOL to have a chaining feature similar to
;the Del L function above. It is chained with Del W and Del C.
;
(delete-to-eol
(if (eolp)
(progn
(set-mark)
(next-line)
(end-of-line)
(exchange-dot-and-mark)
)
(progn
(set-mark)
(end-of-line)
(exchange-dot-and-mark)
)
)
(if (= -48 (previous-command))
(progn
(append-region-to-buffer "Line\040buffer")
(erase-region)
)
(delete-region-to-buffer "Line\040buffer")
)
(setq this-command -48)
)
;
;This deletes the current word. It may be chained with Del L,
;Del EOL, previously deleted words, or previously deleted characters.
;The words are parked in the Line buffer.
(delete-current-word
(forward-word)
(forward-word)
(backward-word)
(set-mark)
(backward-word)
(if (= -48 (previous-command))
(progn
(append-region-to-buffer "Line\040buffer")
(erase-region)
)
(delete-region-to-buffer "Line\040buffer")
)
(setq this-command -48)
)
;
;This deletes the current character. It may be chained with Del L,
;Del EOL, previously deleted words, or previously deleted characters.
;The characters are parked in the Line buffer.
(delete-current-character
(set-mark)
(forward-character)
(exchange-dot-and-mark)
(if (= -48 (previous-command))
(progn
(append-region-to-buffer "Line\040buffer")
(erase-region)
)
(delete-region-to-buffer "Line\040buffer")
)
(setq this-command -48)
)
;
;Undelete Lines, Words, and Characters.
(undelete-line
(yank-buffer "Line\040buffer")
)
;
;Move EOL downward if key is pressed repeatedly.
(repeat-end-of-line
(if (= -12 (previous-command))
(next-line)
)
(end-of-line)
(setq this-command -12)
)
;
;Move BOL downward if key is pressed repeatedly.
(repeat-beginning-of-line
(if (= -10 (previous-command))
(next-line)
)
(beginning-of-line)
(setq this-command -10)
)
;
;Alternate between capitalize-word and lowercase-word.
(capitalize-or-lower
(if (= -6 (previous-command))
(progn (case-word-lower) (setq this-command -3))
(progn (case-word-capitalize) (setq this-command -6))
)
)
;
;APPEND function. Append mark-dot region to Kill buffer.
(append-to-killbuffer
(append-region-to-buffer "Kill\040buffer")
(message "Appended.")
(send-string-to-terminal "\e#>")
)
;
;GOLD/COPY. Copy mark-dot region to Kill buffer.
(copy-to-killbuffer
(delete-to-killbuffer)
(yank-from-killbuffer)
(message "Copied.")
(send-string-to-terminal "\e#>")
)
;
;WORD in the Advance mode.
(next-word
(forward-word)
(forward-word)
(backward-word)
)
;
;Scrolls the display and the cursor.
(scroll-cursor-up
(scroll-one-line-up)
(next-line)
)
(scroll-cursor-down
(scroll-one-line-down)
(previous-line)
)
;
;Puts the cursor at the beginning of indented paragraphs.
(next-paragraph
(next-line)
(forward-paragraph)
(previous-line)
(if (eolp) (next-line))
)
(previous-paragraph
(backward-paragraph)
(previous-line)
(if (eolp) (next-line))
)
;
;Set EDT Advance mode for cursor keys.
(advance-direction
(setq global-mode-string "ADVANCE >>>>>>")
(bind-to-key "search-forward" "\eOR")
(bind-to-key "next-page" "\eOx")
(bind-to-key "next-paragraph" "\eOw")
(bind-to-key "next-word" "\eOq")
(bind-to-key "next-window" "\eOs")
(bind-to-key "scroll-cursor-up" "\eOp")
)
;
;Set EDT Backup mode for cursor keys.
(backup-direction
(setq global-mode-string " <<<<<< BACKUP")
(bind-to-key "search-reverse" "\eOR")
(bind-to-key "previous-page" "\eOx")
(bind-to-key "previous-paragraph" "\eOw")
(bind-to-key "backward-word" "\eOq")
(bind-to-key "previous-window" "\eOs")
(bind-to-key "scroll-cursor-down" "\eOp")
)
;
;Invokes "execute-extended-command" with suggested exit commands.
(ctrl-Z-command
(execute-extended-command
(arg 1 "To exit: quit, exit, or all. To return: novalue. Type command: ")
)
)
;
;CONTROL-SHIFT-^ function. Switches to the original buffer,
;writes this to a file, resets VT-Series keypad application mode,
;and exits Emacs.
(exit
(switch-to-buffer (argv 1))
(write-current-file)
(send-string-to-terminal "\e>")
(exit-emacs)
)
;
;Exit and reset VT-Series keypad application mode.
(all
(delete-buffer "Line\040buffer")
(send-string-to-terminal "\e>")
(write-file-exit)
)
;
;Exit and reset VT-Series keypad application mode.
(quit
(if (< (recursion-depth) 1)
(send-string-to-terminal "\e>")
)
(exit-emacs)
)
;Pause Emacs and reset keypad application mode. Set when
;Emacs is restarted.
(pause
(send-string-to-terminal "\e>")
(pause-emacs)
(send-string-to-terminal "\e=")
)
)
;Here's an improved version of line-to-bottom-of-window based on Hans
;Koomen's message of 30 Jul 83:
(error-occurred ; window-width is already defined in some versions
(defun (window-width 79)))
(defun
(line-to-bottom-of-window lines2skip chars2skip physlines
(setq chars2skip (- (window-width) 1))
(setq lines2skip (window-height))
(setq physlines (+ 1 (/ (- (current-column) 2) chars2skip)))
(setq lines2skip (- lines2skip physlines))
(save-excursion
(while (> lines2skip 0)
(previous-line)
(end-of-line)
(setq physlines (+ 1 (/ (- (current-column) 2) chars2skip)))
(setq lines2skip (- lines2skip physlines)))
(if (< lines2skip 0)
(next-line))
(line-to-top-of-window)
)
)
)
(load "goto.ml")
(load "aton.ml")
(load "misc.ml")
(setq unlink-checkpoint-files 1)
(setq scroll-step 1)
(setq track-eol-on-^N-^P 0)
(setq quick-redisplay 1)
(setq default-right-margin 79)
(setq default-case-fold-search 1)
(setq default-mode-line-format " %[%p of: %b%* |%m| %M%]")
(setq wrap-long-lines 1)
(setq backup-before-writing 1)
(setq backup-by-copying-when-linked 1)
(setq silently-kill-processes 1)
(setq unlink-checkpoint-files 1)
(setq ctlchar-with-^ 1)
;Mask off X-ON, X-OFF codes and bind keyboard control-keys
(bind-to-key "enlarge-window" "\001") ;"ctrl-A"
(bind-to-key "delete-previous-word" "\012") ;"LineFeed"
(bind-to-key "novalue" "\021") ;X-ON control code
(bind-to-key "novalue" "\023") ;X-OFF control code
(bind-to-key "ctrl-Z-command" "\032") ;"ctrl-Z"
(bind-to-key "quote-character" "\034") ;"ctrl-\"
(bind-to-key "exit" "\036") ;"ctrl-shift-^"
(bind-to-key "pause" "\037") ;"ctrl-shift-_"
(bind-to-key "repeat-beginning-of-line" "\177") ;"Delete"
(bind-to-key "quit" "\^C") ;Depart Emacs & reset keypad.
(bind-to-key "quit" "\^X\^C") ;As above.
(bind-to-key "all" "\^X\^F") ;Save all buffers and depart.
;Bind keyboard arrow keys
(bind-to-key "previous-line" "\e[A") ;"up-arrow"
(bind-to-key "next-line" "\e[B") ;"down-arrow"
(bind-to-key "backward-character" "\e[D") ;"left-arrow"
(bind-to-key "forward-character" "\e[C") ;"right-arrow"
;Bind keypad keys
(bind-to-key "describe-key" "\eOQ") ;HELP "PF2"
(bind-to-key "delete-current-line" "\eOS") ;DEL L "PF4"
(bind-to-key "append-to-killbuffer" "\eOy") ;APPEND "9"
(bind-to-key "delete-current-word" "\eOm") ;DEL W "-"
(bind-to-key "advance-direction" "\eOt") ;ADV "4"
(bind-to-key "backup-direction" "\eOu") ;BAK "5"
(bind-to-key "delete-to-killbuffer" "\eOv") ;CUT "6"
(bind-to-key "delete-current-character" "\eOl") ;DEL C ","
(bind-to-key "repeat-end-of-line" "\eOr") ;EOL "2"
(bind-to-key "set-mark" "\eOn") ;SELECT "."
(bind-to-key "newline-and-indent" "\eOM") ;ENTER "ENTER"
;Bind GOLD/Keyboard keys
(bind-to-key "delete-other-windows" "\eOP\010") ;"BackSpace"
(bind-to-key "delete-next-word" "\eOP\012") ;"LineFeed"
(bind-to-key "goto-percent" "\eOP\055") ;"-"
(bind-to-key "goto-line" "\eOP\075") ;"="
(bind-to-key "delete-buffer" "\eOP\160") ;"p"
(bind-to-key "delete-region-to-buffer" "\eOP\133") ;"["
(bind-to-key "capitalize-or-lower" "\eOP\134") ;"\"
(bind-to-key "yank-buffer" "\eOP\135") ;"]"
(bind-to-key "display-line-number" "\eOP\140") ;"`"
(bind-to-key "list-buffers" "\eOP\177") ;"Delete"
(bind-to-key "line-to-top-of-window" "\eOP\e[A") ;"up-arrow"
(bind-to-key "line-to-bottom-of-window" "\eOP\e[B") ;"down-arrow"
(bind-to-key "backward-sentence" "\eOP\e[D") ;"left-arrow"
(bind-to-key "forward-sentence" "\eOP\e[C") ;"right-arrow"
;Bind GOLD/Keypad keys
(bind-to-key "new-undo" "\eOP\eOP") ;Gold "PF1"
(bind-to-key "describe-command" "\eOP\eOQ") ;Help "PF2"
(bind-to-key "aton" "\eOP\eOR") ;Find "PF3"
(bind-to-key "undelete-line" "\eOP\eOS") ;Und LWC "PF4"
(bind-to-key "execute-extended-command" "\eOP\eOw") ;Command "7"
(bind-to-key "justify-paragraph" "\eOP\eOx") ;Fill "8"
(bind-to-key "query-replace-string" "\eOP\eOy") ;Replace "9"
(bind-to-key "split-current-window" "\eOP\eOm") ;Split Wind "-"
(bind-to-key "end-of-file" "\eOP\eOt") ;Bottom "4"
(bind-to-key "beginning-of-file" "\eOP\eOu") ;Top "5"
(bind-to-key "yank-from-killbuffer" "\eOP\eOv") ;Paste "6"
(bind-to-key "pop-to-buffer" "\eOP\eOl") ;Visit Buffer ","
(bind-to-key "case-word-invert" "\eOP\eOq") ;Chgcase "1"
(bind-to-key "delete-to-eol" "\eOP\eOr") ;Del EOL "2"
(bind-to-key "copy-to-killbuffer" "\eOP\eOs") ;Copy "3"
(bind-to-key "newline-and-backup" "\eOP\eOp") ;Open L "0"
(bind-to-key "exchange-dot-and-mark" "\eOP\eOn");Mark/Dot "."
(bind-to-key "visit-file" "\eOP\eOM") ;Visit-File "ENTER"
;Set VT-Series keypad application mode, initialize direction, and
;prevent the two temporary buffers from being checkpointed.
(send-string-to-terminal "\e=")
(advance-direction)
(save-excursion
(switch-to-buffer "Line\040buffer")
(setq needs-checkpointing 0)
(switch-to-buffer "Kill\040buffer")
(setq needs-checkpointing 0)
)
;
; <insert-^L> ----------------------------------------------------
; E M A C S / E D T K E Y P A D
;+---------------+---------------+---------------+---------------+
;| GOLD | HELP KEY | FIND | DEL LINE |
;| ---- | -------- | ---- | -------- |
;| Undo | Help Command |Find in Context| Und L, W, C |
;+---------------+---------------+---------------+---------------+
;| PARAGRAPH | SECT | APPEND | DEL WORD |
;| --------- | ---- | ------ | -------- |
;| Command | Fill Para | Query-Replace | Split Window |
;+---------------+---------------+---------------+---------------+
;| ADVANCE | BACKUP | CUT | DEL CHAR |
;| ------- | ------ | --- | -------- |
;| Bottom | Top | Paste | Visit Buffer |
;+---------------+---------------+---------------+---------------+
;| WORD | EOL | WINDOW | |
;| ---- | --- | ------ | |
;| Chgcase | Delete-EOL | Copy | <CR> Indent |
;+---------------+---------------+---------------+ ----------- |
;| LINE SCROLL | SELECT | Visit File |
;| ------------ | ------ | |
;| Open Line | Swap Mark/Dot | |
;+-------------------------------+---------------+---------------+
;
;
; K E Y B O A R D
; +---------------+---------------+---------------+---------------+
; | ^ | v | <---- | ----> |
; | ----- | ----- | ----- | ----- |
; | Line-to-Top |Line-to-Bottom |Begin Sentence | End Sentence |
; +---------------+---------------+---------------+---------------+
; | - | = | ` | BACK SPACE |
; | ----- | ----- | ----- | ---------- |
; | Goto Percent | Goto Line # | Show Line # |Del Other Wind |
;+---------------+---+-----------+---+-----------+---+---+-----------+---+
;| P | [ | ] | | DEL (now BOL) |
;| ----- | ----- | ----- | | ------------- |
;| Delete Buffer | Cut-to-Buffer |Paste-from-Buff| | List Buffers |
;+---------------+---------------+---------------+ +---------------+
; | \ |
;Ctrl-X-C :Quit & discard changes. | ----- |
;Ctrl-Shift-^ :Exit & file original buffer. |Capitalize Word|
;Ctrl-X-F :All buffers are filed; exit Emacs. +---------------+
; | LF (RUBOUT W) |
;Ctrl-A :Enlarge Window | ------------ |
;Ctrl-L :Redraw Display | Del-to-W-End |
;Ctrl-T :Transpose Characters +---------------+
;Ctrl-Z :Exit
;
;Ctrl-X-I :Insert File at Dot
;Ctrl-X-W :Write Named File with current buffer
;
;ESC-? :Apropos Command
;ESC-r :Replace String (all occurances in buffer)
;
;Query-Replace :Type "n" to skip over, <space> to change, Ctrl-G to exit.
; <insert ^L> ------------------------------------------------------------
;DEC, VMS, VT-100, and EDT are trademarks of Digital Equipment Corporation.
;UNIX is a trademark of American Telephone & Telegraph.
;
;Hacked by Lynn Olson at Tektronix on tekcrd on about 2/7/84.
; ------------------------------------------------------------------------
More information about the Comp.sources.unix
mailing list