From:	ADVAX::"nat@drao.nrc.ca" "Natalie Prowse" 26-NOV-1990 18:57:05.71
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 4 of 5

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Mon, 26 Nov 90 18:55:05 EST
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.15) with UUCP
	id AA04379 for everhart; Mon, 26 Nov 90 18:54:11 -0500
Received: from relay.CDNnet.CA by mcnc.mcnc.org (5.59/MCNC/6-11-90)
	id AA08409; Mon, 26 Nov 90 18:15:41 -0500
	for arisia.dnet.ge.com!EVERHART
Received: by relay.CDNnet.CA (4.1/1.14)
	id AA02260; Mon, 26 Nov 90 14:36:33 PST
Date: 26 Nov 90 20:14 -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: <208*nat@drao.nrc.CA>
Subject: EVEP emulation: Part 4 of 5
 
-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+
X(define-key GOLD-map "2" 'map-buffer-to-key)                ; like "eve-plus
V" does
X(define-key GOLD-map "3" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "4" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "5" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "6" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "7" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "8" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "9" 'map-buffer-to-key)                       ; like "e
Vve-plus" does
X(define-key GOLD-map "0" 'buffer-menu)                       ; like emacs do
Ves
X
X
X;Bind GOLD/Keypad keys
X(defun evep-bind-gold-keypad ()
X  (define-keypad-key GOLD-map ?u 'line-to-top-of-window) ;"up-arrow"
X  (define-keypad-key GOLD-map ?d 'line-to-bottom-of-window) ;"down-arrow"
X  (define-keypad-key GOLD-map ?l 'shift-screen-left) ;"left-arrow"
X  (define-keypad-key GOLD-map ?r 'shift-screen-right) ;"right-arrow"
X  (define-keypad-key GOLD-map ?f 'search-forward-query) ; GOLD-FIND - find a
Vll occurences
X  (define-keypad-key GOLD-map ?k 'append-to-cutbuffer) ;GOLD-REMOVE (append
V to paste buffer)
X  (define-keypad-key GOLD-map ?\C-a 'mark-section-wisely) ;Gold     "PF1"
X  (define-keypad-key GOLD-map ?\C-c 'search-forward-query) ;"GOLD-PF3"`032
X  (define-keypad-key GOLD-map ?\C-d 'undelete-lines) ;Und Line "PF4"
X  (define-keypad-key GOLD-map ?0 'open-line-above) ;Open L   "0"
X  (define-keypad-key GOLD-map ?3 'downcase-word) ;  GOLD-3"
X  (define-keypad-key GOLD-map ?4 'insert-file) ;  GOLD-4"
X  (define-keypad-key GOLD-map ?5 'find-file) ;  GOLD-5"
X  (define-keypad-key GOLD-map ?2 'delete-to-eol) ;Del EOL  "2"
X  (define-keypad-key GOLD-map ?1 'write-file) ;Copy     "1"
X  (define-keypad-key GOLD-map ?\C-b 'move-to-end) ;Bottom   "Gold-PF2"
X  (define-keypad-key GOLD-map ?6 'nat-toggle-window)  ; "Gold-6"
X  (define-keypad-key GOLD-map ?7 'execute-extended-command) ;Command  "7"
X  (define-keypad-key GOLD-map ?8 'set-mark-comand) ;SELECT     "8"
X  (define-keypad-key GOLD-map ?9 'yank-from-cutbuffer) ;Replace  "9"
X  (define-keypad-key GOLD-map ?- 'undelete-words) ;UND word "-"
X  (define-keypad-key GOLD-map ?, 'undelete-chars) ;UND Char ","
X  (define-keypad-key GOLD-map ?. 'redraw-display) ;Reset Window "."
X  (define-keypad-key GOLD-map ?e 'start-kbd-macro)) ;"ENTER" - like LEARN
X
X;; Make direction of motion show in mode line
X;; while EVEP emulation is turned on.
X;; Note that the keypad is always turned on when in Emacs.
X
X(or (assq 'evep-direction-string minor-mode-alist)
X    (setq minor-mode-alist (cons '(evep-direction-string evep-direction-stri
Vng)
X`009`009`009`009 minor-mode-alist)))
X(initial-file-load)
X(display-time)
X
X
X
X
X
X
X
$ CALL UNPACK EVEP.EL;1 577530906
$ create/nolog 'f'
X;;!emacs
X;;
X;; FILE:         par-align.el
X;; SUMMARY:      Improved paragraph fill, left-align and justify functions
X;; USAGE:        GNU Emacs Lisp Library
X;;
X;; AUTHOR:       Bob Weiner, Applied Research, Motorola, Inc.
X;; E-MAIL:       USENET:  weiner@novavax.UUCP
X;; ORIG-DATE:    14-Apr-89
X;; LAST-MOD:      6-Jun-90 at 02:01:00 by Bob Weiner
X;;
X;; Copyright (C) 1989 Bob Weiner and Free Software Foundation, Inc.
X;; Available for use and distribution under the same terms as GNU Emacs.
X;;
X;; This file is not yet part of GNU Emacs.
X;;
X;; DESCRIPTION: `032
X;;
X;;   This package allows GNU Emacs paragraph commands to deal more
X;;   reasonably with indented text and embedded comments.  It lets you
X;;   realign and set the fill prefix on one line of a paragraph, e.g. the
X;;   first, and then have all the other lines match up when you fill the
X;;   paragraph.
X;;  `032
X;;   An auto-justify minor mode similar to auto-fill from jka@hpfcso.HP.COM
X;;   (Jay Adams) is also included.  Use the 'auto-justify-mode' command to
X;;   toggle it on and off.
X;;
X;;
X;;   I think the 'fill-paragraph-and-align' command eliminates the need for
X;;   Kyle Jones, 'C Comment Edit' package.  Additionally, there is no need
X;;   to edit in a special buffer.
X;;  `032
X;;   If you set the fill-prefix to some value, then set it to nil (set it at
X;;   the beginning of a line) and then fill the paragraph, the old
X;;   fill-prefix will be stripped off and the paragraph will be filled
X;;   properly with no prefix.  Then just add the new fill-prefix, if any,
X;;   that you want and refill again.
X;;  `032
X;;   If you have ever tried to fill Emacs Lisp documentation strings or
X;;   embedded comments, you know that all you get is an ugly mess.  You end
X;;   up having to fill after putting blank lines at the beginning and end.
X;;   Now you can fill properly without making any inline changes.  The fill
X;;   routines do not fill the first line of documentation strings since it i
Vs
X;;   used by the apropos commands and may intentionally be short.
X;;  `032
X;;   The fill and movement commands also recognize multiple paragraphs
X;;   within a single comment stretch, just like the ones you see in this
X;;   description text.  Just remember to set the fill prefix properly, just
X;;   as you normally would for the fill-paragraph command.
X;;  `032
X;;   When filling a region, fill-prefix-prev (old fill prefix) can be
X;;   replaced by fill-prefix throughout the entire region before each
X;;   paragraph is filled.  Simply call the 'fill-region-and-align-all'
X;;   command.
X;;  `032
X;;   Always fill with point before some of the text to be filled.  If you
X;;   try to fill when point is on a line following all of the text to be
X;;   filled, the next paragraph may be filled by mistake, e.g. when filling
X;;   with point near the end of a comment string.
X;;
X;;   C comments of the form (with any number of '*' chars):
X;;   /*
X;;    * <text>
X;;    * <text>
X;;    */
X;;   are filled well.
X;;
X;;   Multiple line C comments of the form:
X;;   /*        */
X;;   /*        */
X;;   are not filled well, so don't use them.  If you have some already, you
X;;   can convert them to the kind above with the
X;;   'c-comment-make-prefix-only' command found in this package.
X;;
X;;   Comments in UNIX shell scripts of the form (with any number of '#' char
Vs):
X;;   #
X;;   # <text>
X;;   # <text>
X;;   #
X;;   are filled well if the first line of the file begins with a pattern tha
Vt
X;;   matches the regular expression "`094#!/bin/`091ck`093?sh" as shell scri
Vpts should.
X;;
X;;   Fortran comments of the form:
X;;   C
X;;   C <text>
X;;   C <text>
X;;   C
X;;   are filled well.
X;;
X;;   The commands bound immediately below do all of this work.
X;;
X;; DESCRIP-END.
X
X
X;; Suggested key bindings
X;;
X(global-set-key "\M-j" 'fill-paragraph-and-align)
X(global-set-key "\C-x\C-j" 'fill-region-and-align-all)
X(define-key text-mode-map "\C-x\C-j" 'fill-region-and-align)
X(define-key indented-text-mode-map "\C-x\C-j" 'fill-region-and-align)
X;;(define-key outline-mode-map "\C-x\C-j" 'fill-region-and-align)
X
X;; The next two functions are suitable as replacements for the standard
X;; paragraph movement commands if you want them to recognize paragraph
X;; boundaries the way the fill functions below do.
X;;
X;; Suggested key bindings
X;;
X;;(global-set-key "\M-n" 'forward-para)
X;;(global-set-key "\M-p" 'backward-para)
X
X(defun forward-para (&optional arg)
X  "Move forward to end of paragraph.  With ARG, do it arg times.
XA line which  paragraph-start  matches either separates paragraphs,
Xif  paragraph-separate  matches it also, or is the first line of a paragraph
V.
XA paragraph end is the beginning of a line which is not part of the paragrap
Vh
Xto which the end of the previous line belongs, or the end of the buffer."
X  (interactive "p")
X  (paragraph-filter 'forward-paragraph arg))
X
X(defun backward-para (&optional arg)
X  "Move backward to start of paragraph.  With ARG, do it arg times.
XA paragraph start is the beginning of a line which is a first-line-of-paragr
Vaph
Xor which is ordinary text and follows a paragraph-separating line, except
Xif the first real line of a paragraph is preceded by a blank line,
Xthe paragraph starts at that blank line.
XSee forward-paragraph for more information."
X  (interactive "p")
X  (or arg (setq arg 1))
X  (paragraph-filter 'forward-paragraph (- arg)))
X
X
X(defconst fill-prefix-prev nil
X  "Previous string inserted at front of new line during filling, or nil for
V none.
XSetting this variable automatically makes it local to the current buffer.")
X(make-variable-buffer-local 'fill-prefix-prev)
X
X;; Redefine this function so that it sets 'fill-prefix-prev' also.
X(defun set-fill-prefix ()
X  "Set the fill-prefix to the current line up to point.
XAlso sets fill-prefix-prev to previous value of fill-prefix.
XFilling expects lines to start with the fill prefix and reinserts the fill
Xprefix in each resulting line."
X  (interactive)
X  (setq fill-prefix-prev fill-prefix
X`009fill-prefix (buffer-substring
X`009`009      (save-excursion (beginning-of-line) (point))
X`009`009      (point)))
X  (if (equal fill-prefix-prev "")
X      (setq fill-prefix-prev nil))
X  (if (equal fill-prefix "")
X      (setq fill-prefix nil))
X  (if fill-prefix
X      (message "fill-prefix: \"%s\"" fill-prefix)
X    (message "fill-prefix cancelled")))
X
X(defun fill-paragraph-and-align (justify-flag)
X  "Fill current paragraph.  Prefix arg JUSTIFY-FLAG means justify as well.
XDoes not alter fill prefix on first line of paragraph.  Any whitespace
Xseparated version of the fill-prefix, or fill-prefix-prev when fill-prefix i
Vs
Xnil, at the beginning of lines is deleted before the fill is performed.  Thi
Vs
Xaligns all lines in a paragraph properly after the fill-prefix is changed.
XWorks well within text, singly delimited C comments, Lisp comments and
Xdocumentation strings, and Fortran comments."
X  (interactive "P")
X  (paragraph-filter 'fill-para-align justify-flag))
X
X(defun fill-region-and-align-all (justify-flag)
X  "Fill each line in region.  Prefix arg JUSTIFY-FLAG means justify as well.
XReplace any whitespace separated version of fill-prefix-prev with fill-prefi
Vx
Xin all lines of region.  This aligns all lines throughout the region properl
Vy
Xafter the fill-prefix is changed.  Works well within text, singly delimited
V C
Xcomments, UNIX shell scripts, Lisp comments and documentation strings, and
XFortran comments.
XSee also documentation for fill-region-and-align."
X  (interactive "P")
X  (paragraph-filter 'fill-region-align justify-flag t))
X
X(defun fill-region-and-align (justify-flag &optional align-all)
X  "Fill each line in region.  Prefix arg JUSTIFY-FLAG means justify as well.
XOptional ALIGN-ALL non-nil means replace fill-prefix-prev with fill-prefix i
Vn
Xall lines of region, otherwise, does not alter prefix in paragraph separator
Xlines and first lines of paragraphs.
XAny whitespace separated version of fill-prefix, or fill-prefix-prev when
Xfill-prefix is nil, at the beginning of appropriate lines is removed before
V the
Xfill is performed.  This aligns all lines in a paragraph properly after the
Xfill-prefix is changed.  Works well within text, singly delimited C comments
V,
XUNIX shell scripts, Lisp comments and documentation strings, and Fortran com
Vments."
X  (interactive "P")
X  (paragraph-filter 'fill-region-align justify-flag align-all))
X
X(defun paragraph-filter (func arg1 &optional arg2)
X;;;                         LISP          C            Fortran        Eiffel
X;;;                         ------------------------------------------------
V--
X;;; comment-start           ";"           "/* "        nil (`094`091Cc*`093)
V   "--"    `032
X;;; comment-start-skip      ";+ *"        "/\\*+ *"    "!`091 \t`093*"
V      "--+`091 \t`093*"
X;;; comment-end             "" (`091`094J`094L`093)   " */"        "" (`094J
V)        "" (`094J)
X;;;
X  (let* ((*lsp* (or (eq major-mode 'emacs-lisp-mode)
X`009`009 (eq major-mode 'lisp-interaction-mode)
X`009`009 (eq major-mode 'scheme-mode)
X`009`009 (eq major-mode 'lisp-mode)))
X`009 (*txt* (or (eq major-mode 'text-mode)
X`009`009    (eq major-mode 'indented-text-mode)
X`009`009    (eq major-mode 'texinfo-mode)
X`009`009    (eq major-mode 'scribe-mode)
X`009`009    (eq major-mode 'outline-mode)
X`009`009    (eq major-mode 'picture-mode)))
X`009 (extra-para-sep
X`009   (concat "`094"
X`009`009   ;; Don't change the '?' in the following lines to a '+', it
X`009`009   ;; will break certain fill boundary conditions.
X`009`009   (if (eq major-mode 'fortran-mode) "`091cC*`093?")
X`009`009   "`091 \t`093*\\("
X`009`009   (cond ((and (< (point-min) 2) (> (point-max) 10)
X`009`009`009       (string-match "`094#!/bin/`091ck`093?sh"
X`009`009`009`009       (buffer-substring 1 11)))
X`009`009`009  "#*")
X`009`009`009 ;; Don't change the '?' in the following lines to a '+', it
X`009`009`009 ;; will break certain fill boundary conditions.
X`009`009`009 (comment-start-skip
X`009`009`009   (concat "\\(" comment-start-skip "\\)?")))
X`009`009   (if (eq major-mode 'c-mode) "\\`124\*+/?")
X`009`009   "\\)`091 \t`093*$"
X`009`009   (if *lsp* "\\`124`094`091 \t`093*\\(`091`091(`093\\`124\"\\)")
X`009`009   ;; For Interleaf TPS, texinfo and Scribe markup documents
X`009`009   (if *txt* "\\`124`094`091@<`093")
X`009`009   ))
X`009 (paragraph-separate
X`009   (concat paragraph-separate "\\`124" extra-para-sep))
X`009 (paragraph-start
X`009   (concat paragraph-start "\\`124" extra-para-sep)))
X    (if arg2
X`009(funcall func arg1 arg2)
X      (funcall func arg1))))
X
X(defun fill-region-align (justify-flag &optional align-all)
X  (if align-all
X      (replace-fill-str fill-prefix-prev fill-prefix))
X  (save-excursion
X    (let ((end (max (point) (mark))))
X      (goto-char (min (point) (mark)))
X      (while (and (not (eobp)) (< (point) end))
X`009(fill-para-align justify-flag align-all)
X`009(forward-paragraph)
X`009;; Forward to real paragraph end if not in lisp mode
X`009(or *lsp* (re-search-forward (concat "\\'\\`124" paragraph-separate)))))
V))
X
X(defun fill-para-align (justify-flag &optional leave-prefix)
X  (save-excursion
X    (end-of-line)
X    ;; Backward to para begin
X    (re-search-backward (concat "\\`096\\`124" paragraph-separate))
X    (forward-line (if (looking-at extra-para-sep) 2 1))
X    (let ((region-start (point)))
+-+-+-+-+-+-+-+-  END  OF PART 4 +-+-+-+-+-+-+-+-
