From:	ADVAX::"nat@drao.nrc.ca" "Natalie Prowse" 26-NOV-1990 18:59:23.98
To:	<ISIS08@ecostat.aau.dk>, <miller@ria.ccs.uwo.ca>, <alberto@pseudo.berkeley.edu>, <ROSS@bio-medical-physics.aberdeen.ac.uk>, <CAIRNS@upei.ca>, <davis@pacific.mps.ohio-state.edu>, <mike@elec.canterbury.ac.nz>, <FAUCONNE%FRSIM51.BITNET@cunyvm.cuny.edu>, <nreadwin@micrognosis.co.uk>, <DMH100@csc1.anu.oz.au>, <mats@efd.lth.se>, <GOLDICK@vulcan.psc.edu>, <peirce@gumby.cc.wmich.edu>, <NRA%ipg.ph.kcl.ac.uk@nsfnet-relay.ac.uk>, <arisia::EVERHART>
CC:	
Subj:	EVEP emulation: Part 3 of 5

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Mon, 26 Nov 90 18:57:25 EST
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.15) with UUCP
	id AA04421 for everhart; Mon, 26 Nov 90 18:56:27 -0500
Received: from relay.CDNnet.CA by mcnc.mcnc.org (5.59/MCNC/6-11-90)
	id AA08526; Mon, 26 Nov 90 18:21:42 -0500
	for arisia.dnet.ge.com!EVERHART
Received: by relay.CDNnet.CA (4.1/1.14)
	id AA02173; Mon, 26 Nov 90 14:34:26 PST
Date: 26 Nov 90 20:12 -0800
From: Natalie Prowse <nat@drao.nrc.ca>
To: <ISIS08@ecostat.aau.dk>, <miller@ria.ccs.uwo.ca>,
        <alberto@pseudo.berkeley.edu>,
        <ROSS@bio-medical-physics.aberdeen.ac.uk>, <CAIRNS@upei.ca>,
        <davis@pacific.mps.ohio-state.edu>, <mike@elec.canterbury.ac.nz>,
        <FAUCONNE%FRSIM51.BITNET@cunyvm.cuny.edu>,
        <nreadwin@micrognosis.co.uk>, <DMH100@csc1.anu.oz.au>,
        <mats@efd.lth.se>, <GOLDICK@vulcan.psc.edu>,
        <peirce@gumby.cc.wmich.edu>, <NRA%ipg.ph.kcl.ac.uk@nsfnet-relay.ac.uk>,
        <arisia::EVERHART>
Message-Id: <207*nat@drao.nrc.CA>
Subject: EVEP emulation: Part 3 of 5
 
-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
X`009(insert "\n"))
X    (setq evep-last-deleted-lines
X`009  (buffer-substring beg (point)))
X    (delete-region beg (point))))
X
X(defun delete-to-eol (num)
X  "Delete text up to end of line.
XWith argument, delete up to to Nth line-end past point.
XThey are saved for the EVEP undelete-lines command."
X  (interactive "p")
X  (let ((beg (point)))
X    (forward-char 1)
X    (end-of-line num)
X    (setq evep-last-deleted-lines
X`009  (buffer-substring beg (point)))
X    (delete-region beg (point))))
X
X(defun delete-current-word (num)
X  "Delete one or specified number of words after point.
XThey are saved for the EVEP undelete-words command."
X  (interactive "p")
X  (let ((beg (point)))
X    (forward-word num)
X    (setq evep-last-deleted-words
X`009  (buffer-substring beg (point)))
X    (delete-region beg (point))))
X
X(defun delete-previous-word (num)
X  "Delete one or specified number of words before point.
XThey are saved for the EVEP undelete-words command."
X  (interactive "p")
X  (let ((beg (point)))
X    (forward-word (- num))
X    (setq evep-last-deleted-words
X`009  (buffer-substring (point) beg))
X    (delete-region beg (point))))
X
X(defun delete-current-char (num)
X  "Delete one or specified number of characters after point.
XThey are saved for the EVEP undelete-chars command."
X  (interactive "p")
X  (setq evep-last-deleted-chars
X`009(buffer-substring (point) (min (point-max) (+ (point) num))))
X  (delete-region (point) (min (point-max) (+ (point) num))))
X
X(defun delete-previous-char (num)
X  "Delete one or specified number of characters before point.
XThey are saved for the EVEP undelete-chars command."
X  (interactive "p")
X  (setq evep-last-deleted-chars
X`009(buffer-substring (max (point-min) (- (point) num)) (point)))
X  (delete-region (max (point-min) (- (point) num)) (point)))
X
X(defun undelete-lines ()
X  "Yank lines deleted by last EVEP line-deletion command."
X  (interactive)
X  (insert evep-last-deleted-lines))
X
X(defun undelete-words ()
X  "Yank words deleted by last EVEP word-deletion command."
X  (interactive)
X  (insert evep-last-deleted-words))
X
X(defun undelete-chars ()
X  "Yank characters deleted by last EVEP character-deletion command."
X  (interactive)
X  (insert evep-last-deleted-chars))
X
X(defun next-end-of-line (num)
X  "Move to end of line; if at end, move to end of next line.
XAccepts a prefix argument for the number of lines to move."
X  (interactive "p")
X  (forward-char)
X  (end-of-line num))
X
X(defun previous-end-of-line (num)
X  "Move EOL upward.
XAccepts a prefix argument for the number of lines to move."
X  (interactive "p")
X  (end-of-line (- 1 num)))
X
X(defun forward-to-word (num)
X  "Move to next word-beginning, or to Nth following word-beginning."
X  (interactive "p")
X  (forward-word (1+ num))
X  (forward-word -1))
X
X(defun backward-to-word (num)
X  "Move back to word-end, or to Nth word-end seen."
X  (interactive "p")
X  (forward-word (- (1+ num)))
X  (forward-word 1))
X
X(defun backward-line (num)
X  "Move point to start of previous line.
XPrefix argument serves as repeat-count."
X  (interactive "p")
X  (forward-line (- num)))
X
X(defun scroll-window-down (num)
X  "Scroll the display down a window-full.
XAccepts a prefix argument for the number of window-fulls to scroll."
X  (interactive "p")
X  (scroll-down (- (* (window-height) num) 2)))
X
X(defun scroll-window-up (num)
X  "Scroll the display up a window-full.
XAccepts a prefix argument for the number of window-fulls to scroll."
X  (interactive "p")
X  (scroll-up (- (* (window-height) num) 2)))
X
X(defun next-paragraph (num)
X  "Move to beginning of the next indented paragraph.
XAccepts a prefix argument for the number of paragraphs."
X  (interactive "p")
X  (while (> num 0)
X    (next-line 1)
X    (forward-paragraph)
X    (previous-line 1)
X    (if (eolp) (next-line 1))
X    (setq num (1- num))))
X
X(defun previous-paragraph (num)
X  "Move to beginning of previous indented paragraph.
XAccepts a prefix argument for the number of paragraphs."
X  (interactive "p")
X  (while (> num 0)
X    (backward-paragraph)
X    (previous-line 1)
X    (if (eolp) (next-line 1))
X    (setq num (1- num))))
X
X(defun move-to-beginning ()
X  "Move cursor to the beginning of buffer, but don't set the mark."
X  (interactive)
X  (goto-char (point-min)))
X
X(defun move-to-end ()
X  "Move cursor to the end of buffer, but don't set the mark."
X  (interactive)
X  (goto-char (point-max)))
X
X(defun goto-percent (perc)
X  "Move point to ARG percentage of the buffer."
X  (interactive "NGoto-percentage: ")
X  (if (or (> perc 100) (< perc 0))
X      (error "Percentage %d out of range 0 < percent < 100" perc)
X    (goto-char (/ (* (point-max) perc) 100))))
X
X(defun update-mode-line ()
X  "Make sure mode-line in the current buffer reflects all changes."
X  (set-buffer-modified-p (buffer-modified-p))
X  (sit-for 0))
X
X(defun advance-direction ()
X  "Set EVEP Advance mode so keypad commands move forward."
X  (interactive)
X  (setq evep-direction-string " ADVANCE")
X  (define-key function-keymap "\C-c" 'search-forward-next)  ; PF3
X  (define-key function-keymap "f" 'search-forward-next)  ; FIND
X  (define-key function-keymap "8" 'scroll-down) ; "8"
X  (define-key function-keymap "7" 'scroll-up)   ; "7"
X  (define-key function-keymap "1" 'beginning-of-line)  ; "1"
X  (define-key function-keymap "2" 'next-end-of-line) ; "2"
X  (define-key function-keymap "0" 'forward-line)     ; "0"
X  (update-mode-line))
X
X
X(defun backup-direction ()
X  "Set EVEP Backup mode so keypad commands move backward."
X  (interactive)
X  (setq evep-direction-string " BACKUP")
X
X  (define-key function-keymap "\C-c" 'search-reverse-next) ; PF3 `032
X  (define-key function-keymap "f" 'search-reverse-next) ; FIND
X  (define-key function-keymap "8" 'scroll-down) ; "8"
X  (define-key function-keymap "7" 'scroll-up)   ; "7"`032
X  (define-key function-keymap "1" 'backward-line)    ; "1"
X  (define-key function-keymap "2" 'previous-end-of-line) ; "2"
X  (define-key function-keymap "0" 'backward-line)    ; "0"
X  (update-mode-line))
X
X
X
X(defun change-direction ()
X  "Toggle direction so keypad commands work forwards/backwards."
X (interactive)
X (cond  ((string= evep-direction-string  " ADVANCE")
X`009 (backup-direction))
X`009((string= evep-direction-string " BACKUP")
X`009 (advance-direction))))
X
X
X
X(defun beginning-of-window ()
X  "Home cursor to top of window."
X  (interactive)
X  (move-to-window-line 0))
X
X(defun line-to-bottom-of-window ()
X  "Move the current line to the bottom of the window."
X  (interactive)
X  (recenter -1))
X
X
X
X(defun line-to-top-of-window ()
X  "Move the current line to the top of the window."
X  (interactive)
X  (recenter 0))
X
X(defun case-flip-character (num)
X  "Change the case of the character under the cursor.
XAccepts a prefix argument of the number of characters to invert."
X  (interactive "p")
X  (while (> num 0)
X    (funcall (if (<= ?a (following-char))
X`009`009 'upcase-region 'downcase-region)
X`009     (point) (1+ (point)))
X    (forward-char 1)
X    (setq num (1- num))))
X
X
X
X(defun toggle-wrap ()
X  "Toggle between wrapping and not wrapping long lines on the screen."
X  (interactive)
X  (setq truncate-lines (not truncate-lines))
X  (setq outstr "off.")
X  (if truncate-lines
X      (setq outstr "on."))
X  (message (concat "Wrapping of long lines is now " outstr)))
X
X(defun indent-or-fill-region ()
X  "Fill region in text modes, indent region in programming language modes."
X  (interactive)
X  (if (string= paragraph-start "`094$\\`124`094`012")
X      (indent-region (point) (mark) nil)
X    (fill-region (point) (mark))))
X
X(defun mark-section-wisely ()
X  "Mark the section in a manner consistent with the major-mode.
XUses mark-defun for emacs-lisp, lisp,
Xmark-c-function for C,
Xand mark-paragraph for other modes."
X  (interactive)
X  (cond  ((eq major-mode 'emacs-lisp-mode)
X`009  (mark-defun))
X`009 ((eq major-mode 'lisp-mode)
X`009  (mark-defun))
X`009 ((eq major-mode 'c-mode)
X`009  (mark-c-function))
X`009 (t (mark-paragraph))))
X
X
X;;; Key Bindings
X(defun evep-emulation-on ()
X "Begin simulating decs EVEP editor.
XCertain keys are rebound; including nearly all keypad keys.
XUse \\`091evep-emulation-off`093 to undo all rebindings except the keypad ke
Vys.
XNote that this function does not work if called directly from the .emacs fil
Ve.
XInstead, the .emacs file should do (setq term-setup-hook 'evep-emulation-on)
XThen this function will be called at the time when it will work."
X  (interactive)
X  (advance-direction)
X  (evep-bind-gold-keypad)`009;Must do this *after* $TERM.el is loaded
X  (setq evep-mode-old-c-\\ (lookup-key global-map "\C-\\"))
X  (global-set-key "\C-\\" 'quoted-insert)
X  (setq evep-mode-old-delete (lookup-key global-map "\177"))
X  (global-set-key "\177" 'delete-previous-char)      ;"Delete"
X  (setq evep-mode-old-lisp-delete (lookup-key emacs-lisp-mode-map "\177"))
X  (define-key emacs-lisp-mode-map "\177" 'delete-previous-char) ;"Delete"
X  (define-key lisp-mode-map "\177" 'delete-previous-char) ;"Delete"
X  (setq evep-mode-old-linefeed (lookup-key global-map "\C-j"))
X  (global-set-key "\C-j" 'delete-previous-word)           ;"LineFeed"
X  (setq find-file-hooks (list 'initial-file-load))
X  (define-key esc-map "?" 'apropos))     ;"<ESC>?"
X
X(defun evep-emulation-off ()
X  "Return from EVEP emulation to normal Emacs key bindings.
XThe keys redefined by \\`091evep-emulation-on`093 are given their old defini
Vtions."
X  (interactive)
X  (setq evep-direction-string nil)
X  (global-set-key "\C-\\" evep-mode-old-c-\\)
X  (global-set-key "\177" evep-mode-old-delete)`009`009;"Delete"
X  (define-key emacs-lisp-mode-map "\177" evep-mode-old-lisp-delete) ;"Delete
V"
X  (define-key lisp-mode-map "\177" evep-mode-old-lisp-delete) ;"Delete"
X  (global-set-key "\C-j" evep-mode-old-linefeed))           ;"LineFeed"
X
X
X
X(define-key function-keymap "k" 'delete-to-cutbuffer)`009;REMOVE
X(define-key function-keymap "I" 'yank-from-cutbuffer)`009;INSERT
X(define-key function-keymap "u" 'previous-line)`009`009;Up arrow
X(define-key function-keymap "d" 'next-line)`009`009;down arrow
X(define-key function-keymap "l" 'backward-char)`009`009;right arrow
X(define-key function-keymap "r" 'forward-char)`009`009;left arrow
X(define-key function-keymap "h" 'beginning-of-window)`009;home
X(define-key function-keymap "\C-a" 'GOLD-prefix)`009;PF1 ("gold")
X(define-key function-keymap "\C-b" 'move-to-beginning) ;"PF2" - "TOP of file
V"
X(define-key function-keymap "\C-d" 'delete-current-line);PF4
X(define-key function-keymap "9" 'kill-region)`009; CUT "9" keypad key
X(define-key function-keymap "-" 'delete-current-word)
X(define-key function-keymap "3" 'upcase-word)
X(define-key function-keymap "4" 'forward-to-word)
X(define-key function-keymap "5" 'backward-to-word)
X(define-key function-keymap "," 'delete-current-char)
X(define-key function-keymap "." 'redraw-display)        ;REFRESH
X(define-key function-keymap "e"  'query-replace)        ; ENTER key query-re
Vplace
X(define-key function-keymap "6" 'other-window)`009`009;kp6 - other window
X
X(setq GOLD-map (make-keymap))
X(fset 'GOLD-prefix GOLD-map)
X
X(defvar GOLD-map nil
X   "GOLD-map maps the function keys on the VT100 keyboard preceeded
Xby the PF1 key.  GOLD is the ASCII the 7-bit escape sequence <ESC>OP.")
X
X(defun define-keypad-key (keymap function-keymap-slot definition)
X  (let ((function-key-sequence (function-key-sequence function-keymap-slot))
V)
X    (if function-key-sequence
X`009(define-key keymap function-key-sequence definition))))
X
X;;Bind GOLD/Keyboard keys
X
X(define-key GOLD-map "\C-g"  'keyboard-quit)            ; just for safety
X(define-key GOLD-map "\177" 'delete-window)             ;"Delete"
X(define-key GOLD-map "\C-h" 'delete-other-windows)      ;"BackSpace"
X(define-key GOLD-map "\C-m" 'newline-and-indent)        ;"Return"
X(define-key GOLD-map "%" 'goto-percent)                 ; "%"
X(define-key GOLD-map "=" 'goto-line)                    ; "="
X(define-key GOLD-map "`096" 'what-line)                    ; "`096"
X
X; GOLD letter combinations:
X(define-key GOLD-map "b" 'buffer-menu)                  ; "b"
X(define-key GOLD-map "B" 'buffer-menu)                  ; "B"
X(define-key GOLD-map "d" 'dired)                        ; "d"
X(define-key GOLD-map "D" 'dired)                        ; "D"
X(define-key GOLD-map "e" 'call-last-kbd-macro)          ; "e"
X(define-key GOLD-map "E" 'call-last-kbd-macro)          ; "E"
X(define-key GOLD-map "f" 'occur)                        ; "f"
X(define-key GOLD-map "F" 'occur)                        ; "F"
X(define-key GOLD-map "i" 'insert-file)                  ; "i"
X(define-key GOLD-map "I" 'insert-file)                  ; "I"
X(define-key GOLD-map "k" 'kill-buffer)`009`009`009       ; "k"
X(define-key GOLD-map "K" 'kill-buffer)`009`009`009       ; "K"
X(define-key GOLD-map "l" 'goto-line)                           ; "l"
X(define-key GOLD-map "L" 'goto-line)                           ; "L"
X(define-key GOLD-map "m" 'save-some-buffers)`009`009       ; "m"
X(define-key GOLD-map "M" 'save-some-buffers)`009`009       ; "m"
X(define-key GOLD-map "n" 'next-window)                         ; "n"
X(define-key GOLD-map "N" 'next-window)                         ; "N"
X(define-key GOLD-map "o" 'switch-to-buffer-other-window)       ; "o"
X(define-key GOLD-map "O" 'switch-to-buffer-other-window)       ; "O"
X(define-key GOLD-map "p" 'fill-paragraph-and-align)            ; "p"
X(define-key GOLD-map "P" 'fill-paragraph-and-align)            ; "P"
X(define-key GOLD-map "r" 'end-kbd-macro)                       ; "r"
X(define-key GOLD-map "R" 'end-kbd-macro)                       ; "R"
X(define-key GOLD-map "s" 'save-buffer)                         ; "s"
X(define-key GOLD-map "S" 'save-buffer)                         ; "S"
X(define-key GOLD-map "u" 'undo)`009`009`009`009       ; "u"
X(define-key GOLD-map "U" 'undo)`009`009`009`009       ; "U"
X(define-key GOLD-map "v" 'find-file-other-window)              ; "v"
X(define-key GOLD-map "V" 'find-file-other-window)              ; "V"
X(define-key GOLD-map "W" 'toggle-wrap)                         ; "w"
X(define-key GOLD-map "w" 'toggle-wrap)                         ; "w"
X(define-key GOLD-map "1" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
+-+-+-+-+-+-+-+-  END  OF PART 3 +-+-+-+-+-+-+-+-
