davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (07/31/87)
After getting function keys working with MicroEMACS in Xenix, I started writing macros to perform various functions. The most notible was "filter-region", to allow passing a small part of a file through a filter (such as rot13 ;-), scrolling a half window at a time, deleting to end of file, and closing a file (window, buffer, and all). If you are running any version 3.8x the following may be added to input.c after the meta has been recognized and the next character read (getcmd procedure): >> /* code for ANSI keystrokes */ >> if (c == '[') >> { /* get an extended escape sequence */ >> c = get1key(); >> return (SPEC | c); >> } ---------------- Xenix .emacsrc file ---------------- ; ; MicroEMACS startup file for Xenix ; ; Bill Davidsen - Jul 30 1987 ; ; ---------------- initialization set $debug "FALSE" set $discmd "FALSE" ; ---------------- bindings ;; arrow keys bind-to-key next-line FNB ; CsrDn bind-to-key previous-line FNA ; CsrUp bind-to-key forward-character FNC ; CsrRt bind-to-key backward-character FND ; CsrLf ;; keypad bind-to-key beginning-of-file FNH ; Home bind-to-key end-of-file FNF ; End bind-to-key next-page FNG : PgDn bind-to-key previous-page FNI ; PgUp ;; function keys bind-to-key next-buffer FNN ; F2 bind-to-key previous-word FNO ; F3 bind-to-key next-word FNP ; F4 bind-to-key beginning-of-line FNQ ; F5 bind-to-key end-of-line FNR ; F6 bind-to-key execute-macro FNV ; F10 bind-to-key previous-paragraph FNa ; Shift-F3 bind-to-key next-paragraph FNb ; Shift-F4 ; ---------------- defined macros and bindings ;; filter-region 1 store-macro ; read the command first, before disabling display set %cmd @"Filter command: " ; Set the options wanted ; set $debug "TRUE" set $discmd "FALSE" ; extract the original region kill-region 2 split-current-window ; create a new buffer and put the region in it select-buffer "[temp]" yank unmark-buffer ; execute the command filter-buffer %cmd ; pick up the entire file beginning-of-file set-mark end-of-file delete-blank-lines kill-region ; mark the buffer clean, delete and remove it unmark-buffer delete-window delete-buffer "[temp]" ; put the new data back yank ; reset the options set $discmd "TRUE" set $debug "FALSE" !endm bind-to-key execute-macro-1 FNM ; F1 ;; kill to end of buffer 2 store-macro set $discmd "FALSE" set-mark end-of-file kill-region set $discmd "TRUE" !endm bind-to-key execute-macro-2 FNZ ; Shift-F2 ;; delete line 3 store-macro beginning-of-line 1 kill-to-end-of-line !endm bind-to-key execute-macro-3 FNY ; Shift-F1 ;; enhanced next-line-and-indent 4 store-macro end-of-line newline-and-indent !endm bind-to-key execute-macro-4 FNL ; Ins ;; close window 5 store-macro set %cwindow $cbufname ; if several windows, just close this one, ; otherwise pull the next buffer into this window set %dispsize &sub $pagelen 2 !if &less $wline %dispsize delete-window !else !force next-buffer !endif ; if status was bad there is no next buffer !if $status ; this is just a place holder !else write-message "[ can't delete last buffer ]" !return !endif ; attempt to close the buffer - will ask if changes !force delete-buffer %cwindow !if $status write-message &cat "closed buffer " %cwindow !else select-buffer %cwindow write-message &cat "[ " &cat %cwindow " not deleted ]" !endif !endm bind-to-key execute-macro-5 FNd ; Shift-F6 ;; forward half window 6 store-macro set %hl &div $wline 2 !if &less %hl 2 set %hl 2 !endif %hl move-window-down !endm bind-to-key execute-macro-6 FNT ; F8 ;; back half window 7 store-macro set %hl &div $wline 2 !if &less %hl 2 set %hl 2 !endif %hl move-window-up !endm bind-to-key execute-macro-7 FNS ; F8 ;; make-current-top 9 store-macro 1 redraw-display !endm bind-to-key execute-macro-9 M-, ; ESC-, ;; make-current-last 8 store-macro $wline redraw-display !endm bind-to-key execute-macro-8 M-. ; Esc-. ; ---------------- wrapup set $discmd "TRUE" -- bill davidsen (wedu@ge-crd.arpa) {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me