lynno@tektronix.UUCP (Lynn Olson ) (02/24/84)
; [Sacrificial first line for incompetent relay sites] ; Here's a revised version of the CMU-Emacs EDT simulator sent ;out a couple of weeks ago. I cranked in some changes in response to ;reactions from the technical writers in our group, and cleaned up some ;bugs. It outwardly resembles the DEC EDT editor, as before, and makes full ;use of the VT-100/ANSI X3.64 keypad. Perhaps the nicest change is mapping ;the "shell" command into the keypad; this comes in handy for messing around ;with directories, then leaving the shell-window. ; ; Lynn Olson, now on tekfdi (Spectrum Analyzers), on 2/17/83. ;This .emacs_pro file maps the keypad of a VT-1xx terminal into a command ;set resembling the DEC EDT (tm) editor. Most of the unshifted functions are ;unaltered - removing only two EDT functions, PAGE and ENTER. These ;are redefined into PARAGRAPH and ENTER WINDOW. ;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: ;UND W -> : Visit Buffer ;UND C -> : Visit File ;SUBS -> : Visit Shell ;SPECINS -> : Copy Mark/Dot Region ;RESET -> : Reset Window (return to window associated ; with initial file) ; New commands are GOLD/GOLD, which exchanges the dot and the mark. ;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 : List Buffers. ;GOLD/Delete : Delete Window. ;GOLD/ \ : Split Window. ;GOLD/LineFeed : Capitalize Word. ;GOLD/ <CR> : Indent Newline. ;GOLD/ <space> : Undo; press <space> to continue undoing. ; (This also works in the shell window.) ; 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. ; ^Q : Reserved for X-ON flow control. ; ^S : Reserved for X-OFF flow control. ; ^Z : Extended-Command, with prompts for different exits. ; ^_ : Pause-Emacs. (Unix command "fg" will restart 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 LineBuffer 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 "LineBuffer") (erase-region) ) (delete-region-to-buffer "LineBuffer") ) (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 "LineBuffer") (erase-region) ) (delete-region-to-buffer "LineBuffer") ) (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 LineBuffer. (delete-current-word (set-mark) (forward-word) (if (= -48 (previous-command)) (progn (append-region-to-buffer "LineBuffer") (erase-region) ) (delete-region-to-buffer "LineBuffer") ) (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 LineBuffer. (delete-current-character (set-mark) (forward-character) (exchange-dot-and-mark) (if (= -48 (previous-command)) (progn (append-region-to-buffer "LineBuffer") (erase-region) ) (delete-region-to-buffer "LineBuffer") ) (setq this-command -48) ) ; ;Undelete Lines, Words, and Characters. (undelete-line (yank-buffer "LineBuffer") ) ; ;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 uppercase-word. (capitalize-or-upper (if (= -6 (previous-command)) (progn (case-word-upper) (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#>");Perform keyclick. ) ; ;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#>");Perform keyclick. ) ; ;Reset Window to the initial file used at Emacs' invocation. (reset-window (switch-to-buffer (argv 1)) (delete-other-windows) ) ;WORD in the Advance mode. (next-word (forward-word) (forward-word) (backward-word) ) ; ;Scrolls the display and the cursor. (scroll-cursor-up (beginning-of-line) (next-line) (scroll-one-line-up) ) (scroll-cursor-down (beginning-of-line) (previous-line) (scroll-one-line-down) ) ; ;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 "forward-character" "\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 "backward-character" "\eOs") (bind-to-key "scroll-cursor-down" "\eOp") ) ; ;Ctrl-L function. Redraw display and set keypad application mode. (redraw-crt-set-keypad (send-string-to-terminal "\e=") (redraw-display) ) ; ;Invokes "execute-extended-command" with suggested exit commands. (ctrl-Z-command (execute-extended-command (arg 1 "To exit: exit, quit, or all. To return: novalue. Type command: ") ) ) ; ;^X-^A function. Switches to the initial 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) ) ; ;^X-^F function. Reset VT-Series keypad application mode & exit. (all (switch-to-buffer "LineBuffer") (delete-buffer "LineBuffer") (send-string-to-terminal "\e>") (write-file-exit) ) ; ;^X-^C or ^C function. Reset VT-Series keypad application mode & quit. (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=") (setq unlink-checkpoint-files 1) ) ;Displays line number, character number, and total characters. ;This MLISP function is from "misc.ml". (display-line-number orig page line pagetop (save-excursion (setq orig (dot)) (beginning-of-file) (setq page 1) (setq pagetop (dot)) (while (& (! (error-occurred (search-forward "\^L"))) (<= (dot) orig)) (setq page (+ page 1)) (setq pagetop (dot)) ) (goto-character pagetop) (setq line 1) (while (& (! (error-occurred (search-forward "\n"))) (<= (dot) orig)) (setq line (+ line 1)) ) ) (message "Line " line (if (> page 1) (concat " in page " page) "" ) ", " (- (dot) 1) " of " (buffer-size) " characters" ) ) ) ; ATON -- line oriented "fly-by" search capability for Unix-Emacs. ; By Jeff Shrager and Duane Williams: CMU. ; ATON prompts for an argument which is string to be located in the ; current buffer. It makes a list of all the lines in that buffer ; that contain the specified string and then leaves the user in recursive ; edit in that list. The user should place himself on some line of the ; file/list and then use ^C to end recursive edit mode. This will cause ; him to be repositioned in the original buffer at the line selected ; from the summary list. If the string entered is nil then THE EXACT ; SAME summary list is used. It will not reflect changes in the file ; made since the last use of ATON and the cursor will be placed at the ; NEXT location. This is useful for stepping through located lines ; rapidly in order. (defun (aton-lines-in-buffer count (save-excursion (beginning-of-file) (setq count 0) (while (!(eobp)) (next-line) (setq count (+ count 1)) ) ) count ) (aton-current-line line-number (save-excursion (save-restriction (set-mark) (beginning-of-file) (narrow-region) (setq line-number (aton-lines-in-buffer)) (exchange-dot-and-mark) (if (bolp) (setq line-number (+ 1 line-number))) ) ) line-number ) (aton s ln l tracking done rebuild-summary (setq s (get-tty-string "Search for: ")) ; get search string (if (!= "" s) (setq rebuild-summary 1)) (setq tracking track-eol-on-^N-^P) ; remember prev value (setq track-eol-on-^N-^P 0) ; dont track eol (if rebuild-summary (save-excursion ; setup temp buffer (pop-to-buffer "String Search") (erase-buffer) (setq checkpoint-frequency 0) ; no CKP files needed ) ) (save-excursion (beginning-of-file) (set-mark) ; init for narrow-region (setq ln 0) ; init accumulator (setq done 0) (if rebuild-summary (while (! done) (if (error-occurred (search-forward s)) (setq done 1) (progn (end-of-line) ; to pick up entire line (narrow-region) ; dont count lines twice (setq ln (+ ln (aton-current-line))) (set-mark) ; copy line to temp buffer (beginning-of-line) (setq l (region-to-string)) (save-excursion (pop-to-buffer "String Search") (insert-string (concat ln ". " l)) (newline) ) (widen-region) ; continue through file (next-line) (set-mark) ; reset for narrow-region ) ) ) ) (pop-to-buffer "String Search") ; show user the results (if rebuild-summary (previous-line) (next-line) ) (delete-other-windows) (setq buffer-is-modified 0) (if (= 0 (aton-lines-in-buffer)) (error-message "Can't find it")) (message "Use ^C to expand to the selected line.") (recursive-edit) (beginning-of-line) (search-forward ".") (backward-character) (set-mark) (beginning-of-line) (setq ln (region-to-string)) ) (setq track-eol-on-^N-^P tracking) ; restore old value (goto-line ln) (delete-other-windows) ) ) ;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") (setq scroll-step 1) (setq track-eol-on-^N-^P 0) (setq ctlchar-with-^ 1) (setq quick-redisplay 1) (setq wrap-long-lines 1) (setq default-right-margin 79) (setq default-case-fold-search 1) (setq default-mode-line-format " %[%p of: %b%* |%m| %M%]") (setq backup-before-writing 1) (setq backup-by-copying-when-linked 1) (setq silently-kill-processes 1) (setq unlink-checkpoint-files 1) ;Mask off X-ON, X-OFF codes and bind keyboard control-keys (bind-to-key "delete-previous-word" "\012") ;"LineFeed" (bind-to-key "redraw-crt-set-keypad" "\014") ;"ctrl-L" (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 "enlarge-window" "\036") ;"ctrl-shift-^" (bind-to-key "pause" "\037") ;"ctrl-shift-_" (bind-to-key "repeat-beginning-of-line" "\177") ;"Delete" (bind-to-key "exit" "\^X\^A") ;File initial buffer & exit. (bind-to-key "quit" "\^C") ;Depart Emacs & reset keypad. (bind-to-key "quit" "\^X\^C") ;Depart Emacs & reset keypad. (bind-to-key "all" "\^X\^F") ;File all buffers and exit. ;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 "next-window" "\eOM") ;ENTER "ENTER" ;Bind GOLD/Keyboard keys (bind-to-key "list-buffers" "\eOP\010") ;"BackSpace" (bind-to-key "capitalize-or-upper" "\eOP\012") ;"Linefeed" (bind-to-key "newline-and-indent" "\eOP\015") ;"Return" (bind-to-key "new-undo" "\eOP\040") ;"Spacebar" (bind-to-key "goto-percent" "\eOP\055") ;"-" (bind-to-key "goto-line" "\eOP\075") ;"=" (bind-to-key "delete-region-to-buffer" "\eOP\133") ;"[" (bind-to-key "split-current-window" "\eOP\134") ;"\" (bind-to-key "yank-buffer" "\eOP\135") ;"]" (bind-to-key "display-line-number" "\eOP\140") ;"`" (bind-to-key "delete-buffer" "\eOP\160") ;"p" (bind-to-key "delete-window" "\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 "exchange-dot-and-mark" "\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 "pop-to-buffer" "\eOP\eOm") ;Visit Buffer "-" (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 "visit-file" "\eOP\eOl") ;Visit File "," (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 "reset-window" "\eOP\eOn") ;Reset Window "." (bind-to-key "shell" "\eOP\eOM") ;Visit Shell "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 "LineBuffer") (setq needs-checkpointing 0) (switch-to-buffer "Kill\040buffer") (setq needs-checkpointing 0) ) ; ; <insert ^L here> ; E M A C S / E D T K E Y P A D ;+---------------+---------------+---------------+---------------+ ;| GOLD | HELP KEY | FIND | DEL LINE | ;| ---- | -------- | ---- | -------- | ;| Swap Dot-Mark | Help Command |Find in Context| Und L, W, C | ;+---------------+---------------+---------------+---------------+ ;| PARAGRAPH | SECT | APPEND | DEL WORD | ;| --------- | ---- | ------ | -------- | ;| Command | Fill Para | Query-Replace | Visit Buffer | ;+---------------+---------------+---------------+---------------+ ;| ADVANCE | BACKUP | CUT | DEL CHAR | ;| ------- | ------ | --- | -------- | ;| Bottom | Top | Paste | Visit File | ;+---------------+---------------+---------------+---------------+ ;| WORD | EOL | CHAR | | ;| ---- | --- | ---- | | ;| Chgcase | Delete-EOL | Copy | ENTER WINDOW | ;+---------------+---------------+---------------+ ------------ | ;| LINE SCROLL | SELECT | Visit Shell | ;| ------------ | ------ | | ;| Open Line | Reset Window | | ;+-------------------------------+---------------+---------------+ ; ; ; 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 # | List Buffers | ;+---------------+---+-----------+---+-----------+---+---+-----------+---+ ;| P | [ | ] | | DEL (now BOL) | ;| ----- | ----- | ----- | | ------------- | ;| Delete Buffer | Cut-to-Buffer |Paste-from-Buff| | Del Window | ;+---------------+---------------+---------------+ +---------------+ ; | \ | ;Ctrl-X-A :EXIT & file initial buffer. | ----- | ;Ctrl-X-C :QUIT & discard changes. | Split Window | ;Ctrl-X-F :ALL buffers are filed; exit Emacs. +---------------+ ; | LF (RUBOUT W) | ;Ctrl-^ :Enlarge Window. | ------------- | ;Ctrl-G :Abort Command. |Capitalize Word| ;Ctrl-L :Redraw Display. +---------------+ ;Ctrl-T :Transpose Characters. ;Ctrl-Z :Exit. ; ;Ctrl-X-I :Insert File at Dot. ;Ctrl-X-W :Write Named File from current buffer. ; ;ESC-? :Apropos Command. ;ESC-r :Replace String (all occurances in buffer). ; ;GOLD/ <space> :UNDO; press <space> to continue, any other key to stop. ;GOLD/ <CR> :Indent Newline with indentation level of previous line. ;GOLD/ Replace :Type "n" to skip over, <space> to change, Ctrl-G to exit. ; <insert ^L here> ; N O T E S ; ; To use the FIND function repeatedly, give it the string it wants ;for the first time; the next time FIND is pressed, just press <CR>, ;and FIND will look for the same thing as before. ; ; GOLD/ <space>, the UNDO function, has the interesting ability to ;reverse the action of the UNDO function. To try this, type a sequence of ;numbers such as "1234567890". Press GOLD/ <space>, then hit the <space> ;bar several times. This will leave the string of numbers looking like ;this: "12345". Now, press <GOLD>/ <space> and hit the <space> bar several ;times. The string of numbers will grow larger again, reversing the action ;of the previous "undos". This property can be handy in overcoming the ;ill effects of leaving too much undone. ; ; Visit Shell opens a window with a shell running in it. The shell ;window executes Unix commands by either typing them out or moving the ;the dot to a previous command-line and pressing <CR>. If you want to ;leave the shell window, use Enter Window or Reset Window. If you press ;Visit Shell again, the previous commands and responses will still be there. ;The dialogue in the shell window may be cut and pasted into other buffers, ;allowing you to capture the exact syntax of commands. The shell buffer ;is cleaned up when you leave Emacs. ; ; If Emacs is invoked without a filename, it recalls the previous ;file and the state of the screen. However, ^X-^A and GOLD/Reset Window ;will not work. Exit with ^X-^F instead, and use GOLD/Delete to remove ;unwanted windows. ; ;DEC, VMS, VT-100, and EDT are trademarks of Digital Equipment Corporation. ;UNIX is a trademark of American Telephone & Telegraph.