
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by tralfaz!ove on Wed Oct 19 12:35:37 EST 1988
# Contents:  azmap.cmd bdata.cmd emacs.hlp emacs.key emacs.rc emacs.tut
 
echo x - azmap.cmd
sed 's/^@//' > "azmap.cmd" <<'@//E*O*F azmap.cmd//'
;	AZMAP.CMD:	MicroEMACS Macro file
;			to translate an AZTEC C .SYM map file into
;			the form needed to read it into ADDSYMS
;			to be used with Pheonix's PFIX plus (C) debugger
;
;			written 6/5/86 by Daniel Lawrence

beginning-of-file
newline
previous-line
replace-string "~n" "~n 0000:"
beginning-of-line
kill-to-end-of-line
newline
newline
newline
beginning-of-file
newline
insert-string "  Address         Publics by Name"
newline
set-mark
end-of-file
case-region-upper
beginning-of-file
replace-string "_~n" "~n"

@//E*O*F azmap.cmd//
chmod u=rw,g=r,o=r azmap.cmd
 
echo x - bdata.cmd
sed 's/^@//' > "bdata.cmd" <<'@//E*O*F bdata.cmd//'
;Create a block of DATA statements for a BASIC program
; within MicroEMACS 3.8

	insert-string "1000 DATA "
	set %linenum 1000

*nxtin
	update-screen		;make sure we see the changes
	set %data @"Next number[0 to end]: "
	!if &equal %data 0
		!goto finish
	!endif

	!if &greater $curcol 60
		2 delete-previous-character
		newline
		set %linenum &add %linenum 10
		insert-string &cat %linenum " DATA "
	!endif

	insert-string &cat %data ", "
	!goto nxtin

*finish

	2 delete-previous-character
	newline


@//E*O*F bdata.cmd//
chmod u=rw,g=r,o=r bdata.cmd
 
echo x - emacs.hlp
sed 's/^@//' > "emacs.hlp" <<'@//E*O*F emacs.hlp//'
=>		MicroEMACS 3.8 Help screens		(01/18/87)

	M-  means to use the <ESC> key prior to using another key
	^A  means to use the control key at the same time as the A key

^V or [Pg Dn]     Scroll down		M-< or <HOME>	Begining of file
^Z or [Pg Up]     Scroll up		M-> or <END>	End of file

-----------------------------------------------------------------------
=>		(1) MOVING THE CURSOR

^F  Forward character   M-F    Forward word		Keypad arrows
^B  Backward character  M-B    Backward word		are active!
^A  Front of line	M-G    Goto a line
^E  End of line		
^N  Next line		M-N    Front of paragraph
^P  Previous line	M-P    End of paragraph
-----------------------------------------------------------------------
=>		(2) DELETING & INSERTING

<--             Delete previous character
^D or <DELETE>  Delete next character
^C or <INSERT>  Insert a space
M-<--           Delete previous word
M-D             Delete next word
^K              Close (delete) to end of line
-----------------------------------------------------------------------
=>		(2a) MORE DELETING & INSERTING

<RETURN>   Insert a newline             <TAB>  Advance to next tab stop
^J         Insert a newline and indent  M-^W   Delete paragraph
^O         Open (insert) line
^W         Delete region between mark (set using M-<spacebar>) and cursor
M-W        Copy region to kill buffer
^X ^O      Delete blank lines around cursor
-----------------------------------------------------------------------
=>		(3) SEARCHING

^S	Search forward from cursor position.
^R	Reverse search from cursor position.
^X S	Forward incremental search
^X R	Reverse incremental search
<ALT> S	Search for the next occurence of the last string (IBM-PC only)
<ALT> R	Search for the last occurence of the last string (IBM-PC only)
-----------------------------------------------------------------------
=>		(4) REPLACING

M-R   Replace all instances of first typed-in string with second
          typed-in string.  End each string with ESC.
M-^R  Replace with query.  Answer with:
	^G  cancel			.   exit to entry point
	!   replace the rest		Y    replace & continue
	?   Get a list of options	N   no replacement & continue
-----------------------------------------------------------------------
=>		(5) CAPITALIZING & TRANSPOSING

M-U	UPPERCASE word
M-C	Capitalize word		^T	Transpose characters
M-L	lowercase word
^X ^L	lowercase region
^X ^U	uppercase region
^Q	Quote next entry, so that control codes may be entered into text
-----------------------------------------------------------------------
=>		(6) REGIONS & THE KILL BUFFER

M-<spacebar>	set MARK at current position
^X ^X		eXchange mark and cursor

A REGION will then be continuously-defined as the area between the mark and
the current cursor position.  The KILL BUFFER is the text which has been
most recently saved or deleted.
-----------------------------------------------------------------------
=>		(7) COPYING AND MOVING

^W  Delete (Wipe) region		M-W	copy region to KILL buffer
^Y  Yankback save buffer at cursor
Generally, the procedure for copying or moving text is:
    1)  Mark a REGION using M-<spacebar> at beginning and cursor at end.
    2)  Delete it (with ^W) or copy it (with M-W) into the KILL buffer.
    3)  Move the cursor to the desired location and yank it back (with ^Y).
-----------------------------------------------------------------------
=>		(8) MODES OF OPERATION
^X M	Add mode in buffer              M-M    Add global mode
^X ^M   Delete mode in buffer           M-^M   Delete global mode
OVER		Replaces (overwrites) rather than inserts characters
WRAP		Turns on word wrap (automatic carraige return).
VIEW		Allows viewing file without insertion and deletion.
CMODE		Automatic indenting for C program entry
EXACT/MAGIC	Changes how search and replace commands work (see next page)
-----------------------------------------------------------------------
=>		(9) SEARCH AND REPLACE MODES

EXACT	Uppper/lower case is not ignored in searches
MAGIC   Regular pattern matching characters are active
    .   Matches any one character
    *   Matches any any number of the preceding character
    ^   Beginning of line        [ ]   Character class enclosure
    $   End of line              \     Quote next character
-----------------------------------------------------------------------
=>		(10) ON-SCREEN FORMATTING

^X F		Set fill column
Mn-<tab>	Set tab spacing to n charecters between tabs stops
M-Q		Format paragraph so that text lies between margins
^X =		Position report -- displays line number, char count,
                                   file size and character under cursor
M-^C		Count words/lines/chars in marked region
-----------------------------------------------------------------------
=>		(11) MULTIPLE WINDOWS

Many WINDOWS may be active at once on the screen.  All windows may show
different parts of the same buffer, or each may display a different one.
^X 2	Split the current window in two	^X O	Change to next window
^X 0    delete current window           ^X P    Change to previous window
^X 1	delete all other windows        M-^V    Page down next window
                                  	M-^Z	Page up other window
-----------------------------------------------------------------------
=>		(12) CONTROLLING WINDOWS AND THE SCREEN

^X ^    Enlarge current window   M-<n> ^X W   Resize window to <n> lines
^X ^Z   Shrink current window    M-<n> M-S    Change screen to <n> lines
^X ^N   Move window down         M-<n> M-T    Change screen to <n> columns
^X ^P   Move window up
M-^L    Reposition window
^L      Refresh the screen
-----------------------------------------------------------------------
=>		(13) MULTIPLE BUFFERS
A BUFFER is a named area containing a document being edited.  Many buffers
may be activated at once.
^X B	Switch to another buffer.  <CR> = use just-previous buffer
^X X	Switch to next buffer in buffer list
M-^N    Change name of current buffer
^X K	Delete a non-displayed buffer.
^X ^B	Display buffer directory in a window
-----------------------------------------------------------------------
=>		(14) READING FROM DISK

^X ^F	Find file; read into a new buffer created from filename.
	(This is the usual way to begin editing a new file.)
^X ^R	Read file into current buffer, erasing its previous contents.
	No new buffer will be created.
^X ^I	Insert file into current buffer at cursor's location.
^X ^V	Find a file to make current in VIEW mode
-----------------------------------------------------------------------
=>		(15) SAVING TO DISK

^X ^S	Save current buffer to disk
^X ^W	Write current buffer to disk
^X N    Change file name of current buffer
M-Z	Write out all changed buffers and exit MicroEMACS


-----------------------------------------------------------------------
=>		(16) ACCESSING THE OPERATING SYSTEM

^X !	Send one command to the operating system and return
^X @	Pipe DOS command results to buffer
^X #	Filter buffer through DOS filter program
^X C	Start a new command processor under MicroEMACS
^X D	Suspend MicroEMACS into the background (UNIX BSD4.2 only)
^X ^C	Exit MicroEMACS
-----------------------------------------------------------------------
=>		(17) KEY BINDINGS AND COMMANDS

M-K	Bind a key to a command        M-A  Describe a class of commands
M-^K	Unbind a key from a command
^X ?	Describe command bound to a key
M-X	Execute a named (and possibly unbound) command
{Describe-bindings}
	Display a list of all commands and key bindings to a buffer
-----------------------------------------------------------------------
=>		(18) COMMAND EXECUTION
Commands can be specified as command lines in the form:
	<optional repeat count> {command-name} <optional arguments>
{Execute-command-line}	execute a typed in command line
{Execute-buffer}	executes commands lines in a buffer
{Execute-file}		executes command lines from a file
{clear-message-line}	clears the message line during execution
   M-~			clears the change flag for a buffer
-----------------------------------------------------------------------
=>		(19) MACRO EXECUTION

^X (	Start recording keyboard macro
^X )	Stop recording keyboard macro
^X E	Execute keyboard macro
M-<n> {store-macro}	Start recording named macro
      !endm		Stop recording named macro
{execute-macro-n}	Execute macro n (where n is from 1 to 20)
-----------------------------------------------------------------------
=>		(20) SPECIAL KEYS

^G		Cancel current command and return to top level of processing.
^U or		Universal repeat.  May be followed by an integer (default = 4)
M-<digit>	and repeats the next command that many times.
M-X		Execute a named (and possibly unbound) command


@//E*O*F emacs.hlp//
chmod u=rw,g=r,o=r emacs.hlp
 
echo x - emacs.key
sed 's/^@//' > "emacs.key" <<'@//E*O*F emacs.key//'
		Default Key Bindings for MicroEmacs 3.8b	(01/22/87)
		========================================

 ^A   Move to start of line           ESC A   Apropos (list some commands)
 ^B   Move backward by characters     ESC B   Backup by words
 ^C   Insert space                    ESC C   Initial capitalize word
 ^D   Forward delete                  ESC D   Delete forward word
 ^E   Goto end of line                ESC E   Reset Encryption Key
 ^F   Move forward by characters      ESC F   Advance by words
 ^G   Abort out of things             ESC G   Go to a line
 ^H   Backward delete                 
 ^I   Insert tab/Set tab stops
 ^J   Insert CR-LF, then indent                     
 ^K   Kill forward                    ESC K   Bind Key to function
 ^L   Refresh the screen              ESC L   Lower case word
 ^M   Insert CR-LF                    ESC M   Add global mode
 ^N   Move forward by lines           ESC N   Goto End paragraph
 ^O   Open up a blank line            
 ^P   Move backward by lines          ESC P   Goto Begining of paragraph
 ^Q   Insert literal                  ESC Q   Fill current paragraph
 ^R   Search backwards                ESC R   Search and replace
 ^S   Search forward                  ESC S   Suspend MicroEMACS (BSD4.2 only)
 ^T   Transpose characters
 ^U   Repeat command four times       ESC U   Upper case word
 ^V   Move forward by pages           ESC V   Move backward by pages
 ^W   Kill region                     ESC W   Copy region to kill buffer
 ^Y   Yank back from killbuffer       ESC X   Execute named command
 ^Z   Move backward by pages          ESC Z   Save all buffers and exit

 ESC ^C   Count words in region       ESC ~   Unmark current buffer
 ESC ^F   Goto matching fence         ESC !   Reposition window
 ESC ^H   Delete backward word        ESC <   Move to start of buffer
 ESC ^K   Unbind Key from function    ESC >   Move to end of buffer
 ESC ^L   Reposition window           ESC .   Set mark
 ESC ^M   Delete global mode          ESC ?   Fetch HELP file to buffer
 ESC ^N   Rename current buffer       ESC space    Set mark
 ESC ^R   Search & replace w/query    ESC rubout   Delete backward word
 ESC ^S   Change screen rows              rubout   Backward delete
 ESC ^T   Change screen columns
 ESC ^V   Scroll next window down
 ESC ^W   Delete Paragraph
 ESC ^Z   Scroll next window up

 ^X ?   Describe a key             ^X !   Run 1 command in a subjob
 ^X =   Show the cursor position   ^X @   Pipe DOS command to buffer
 ^X ^   Enlarge display window     ^X #   Filter buffer thru DOS filter
 ^X 0   Delete current window      ^X (   Begin macro
 ^X 1   Delete other windows       ^X )   End macro
 ^X 2   Split current window
                                   ^X A   Set variable value
 ^X ^B   Display buffer list       ^X B   Switch a window to a buffer
 ^X ^C   Exit MicroEMACS           ^X C   Start a new command processer
                                   ^X D   Suspend MicroEMACS (BSD4.2 only)
                                   ^X E   Execute macro
 ^X ^F   Find file                 ^X F   Set fill column
 ^X ^I   Insert file
                                   ^X K   Delete buffer
 ^X ^L   Lower case region
 ^X ^M   Delete Mode               ^X M   Add a mode
 ^X ^N   Move window down          ^X N   Rename current filename
 ^X ^O   Delete blank lines        ^X O   Move to the next window
 ^X ^P   Move window up            ^X P   Move to the previous window
 ^X ^R   Get a file from disk      ^X R   Incremental reverse search
 ^X ^S   Save current file         ^X S   Incremental forward search
 ^X ^U   Upper case region
 ^X ^V   View file
 ^X ^W   Write a file to disk      ^X W   resize Window
 ^X ^X   Swap "." and mark         ^X X   Use next buffer
 ^X ^Z   Shrink window             ^X Z   Enlarge display window

Only under PCDOS:
 <ALT>-S Hunt forward        SHIFT <F1> - <F10>
 <ALT>-R Hunt backward           Execute macroes 1 - 10

Some unbound commands:
======================
execute-buffer		execute a buffer od command lines
execute-command-line	execute a command line (n <command> <args>)
execute-file		execute a file of command lines
execute-named-command	execute a command by name (w/command completion)
execute-macro-[1-40]	execute macroes 1 thru 40
describe-bindings	pull the list of current bindings into a window
hunt-forward		find next occurance of search string
hunt-backward		find last occurance of search string

Usable Modes
============
WRAP     Lines going past right margin "wrap" to a new line
VIEW     Read-Only mode where no modifications are allowed
CMODE    Change behavior of some commands to work with C better
EXACT    Exact case matching on search strings
OVER     Overwrite typed characters instead of inserting them
CRYPT    Current buffer will be encrypted on write, decrypted on read
MAGIC    Use regular expresion matching in searches

WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK	Sets foreground color
white/cyan/magenta/yellow/blue/red/green/black	Sets background color

MAGIC MODE special characters
=============================
^	Anchor search at beginning of line
$	Anchor search at end of line
@.	Match any character except <NL>
*	Match zero or more of the preceeding character
[]	Match a class of characters ([a-z] would be all alphabetics)
\	Take next literally

@//E*O*F emacs.key//
chmod u=rw,g=r,o=r emacs.key
 
echo x - emacs.rc
sed 's/^@//' > "emacs.rc" <<'@//E*O*F emacs.rc//'
;	EMACS.RC:	Startup file for MicroEMACS 3.8
;
;			This file is executed everytime the
;			editor is entered

; If you screen "SNOWS", uncomment this line
;	set $flicker "TRUE"

;	***** Rebind the Function key group

bind-to-key search-forward		FN;
bind-to-key search-reverse		FN<
bind-to-key hunt-forward		FN=
bind-to-key hunt-backward		FN>
bind-to-key next-window			FN?
bind-to-key execute-macro		FN@
bind-to-key find-file			FNA
bind-to-key execute-file		FNB
bind-to-key save-file			FNC
bind-to-key exit-emacs			FND

bind-to-key apropos			FNV
bind-to-key describe-key		FNW
bind-to-key fill-paragraph		FNX
bind-to-key shell-command		FN\
bind-to-key i-shell			FN]

;	set screen colors
add-global-mode "blue"

;	toggle function key window off
1 store-macro
	save-window
	1 next-window
	!if &sequal "Function Keys" $cbufname
		delete-window
	!endif
	bind-to-key execute-macro-14 FNT
!force	restore-window
	write-message "[Function key window OFF]"
!endm

;	toggle function key window back on
14 store-macro
	1 next-window
	!if &sequal $cbufname "emacs.hlp"
		execute-macro-11
	!endif
	!if &not &sequal $cbufname "Function Keys"
		1 split-current-window
		select-buffer "Function Keys"
		add-mode "red"
!force		5 resize-window
		beginning-of-file
	!endif
	bind-to-key execute-macro-1 FNT
	2 next-window
	write-message "[Function key window ON]"
!endm

;	Enter Help
2 store-macro
	1 next-window		;Make sure the function key window isn't up!
	!if &sequal $cbufname "Function Keys"
		delete-window
		bind-to-key execute-macro-14 FNT
	!endif
	help
	8 resize-window
	bind-to-key execute-macro-12 FNI
	bind-to-key execute-macro-13 FNQ
	bind-to-key execute-macro-11 FNU
	bind-to-key execute-macro-15 ^XO
	bind-to-key execute-macro-15 ^XP
	bind-to-key execute-macro-15 FN?
	add-mode "red"
	beginning-of-file
	2 forward-character
	clear-message-line
!endm

;	Exit Help
11 store-macro
	bind-to-key previous-page FNI
	bind-to-key next-page FNQ
	bind-to-key execute-macro-2 FNU
	bind-to-key next-window ^XO
	bind-to-key previous-window ^XP
	bind-to-key next-window FN?
	delete-window
	clear-message-line
!endm

;	don't allow these commands from within the HELP screen
15	store-macro
	write-message "[Use F2 to exit HELP]!!"
!endm

;	last help page
12 store-macro
	beginning-of-line
	search-reverse "=>"
	1 redraw-display
!endm

;	next help page
13 store-macro
	beginning-of-line
	2 forward-character
	search-forward "=>"
	1 redraw-display
!endm

;	reformat indented paragraph

6 store-macro
	write-message "                    [Fixing paragraph]"
	kill-region
	2 split-current-window
	select-buffer "[temp]"
	yank
	beginning-of-file
	replace-string "~n	" "~n"
	write-message "                    [Fixing paragraph]"
	66 set-fill-column
	write-message "                    [Fixing paragraph]"
	fill-paragraph
	77 set-fill-column
	beginning-of-file
	handle-tab
	replace-string ~n "~n	"
	write-message "                    [Fixing paragraph]"
	end-of-file
	2 delete-previous-character
	beginning-of-file
	set-mark
	write-message "                    [Fixing paragraph]"
	end-of-file
	kill-region
	unmark-buffer
	delete-window
	yank
	delete-buffer "[temp]"
	write-message "                    [Fixed paragraph]"
!endm

;	indent region

7 store-macro
	write-message "                    [Indenting region]"
	kill-region
	2 split-current-window
	select-buffer "[temp]"
	yank
	beginning-of-file
	handle-tab
	replace-string "~n" "~n	"
	end-of-file
	4 delete-previous-character
	beginning-of-file
	set-mark
	write-message "                    [Indenting region]"
	end-of-file
	kill-region
	unmark-buffer
	delete-window
	yank
	delete-buffer "[temp]"
	write-message "                    [Region Indented]"
!endm

;	undent region

8 store-macro
	write-message "                    [Undenting region]"
	kill-region
	2 split-current-window
	select-buffer "[temp]"
	yank
	beginning-of-file
	delete-next-character
	replace-string "~n	" "~n"
	end-of-file
	2 delete-previous-character
	beginning-of-file
	set-mark
	write-message "                    [Undenting region]"
	end-of-file
	kill-region
	unmark-buffer
	delete-window
	yank
	delete-buffer "[temp]"
	write-message "                    [Region undented]"
!endm

;	bring up the function key window

	1 split-current-window
	select-buffer "Function Keys"
	add-mode "red"
	5 resize-window
	insert-string "f1 search      f2 search back | F1 toggle function list F2 toggle help file~n"
	insert-string "f3 hunt        f4 hunt back   | F3 find command/apropos F4 describe key~n"
	insert-string "f5 next window f6 exec macro  | F5 reformat paragraph   F6 ref undented region~n"
	insert-string "f7 find file   f8 exec file   | F7 indent region        F8 undent region~n"
	insert-string "f9 save file  f10 exit emacs  | F9 execute DOS command F10 shell up~n"
	beginning-of-file
	unmark-buffer
	next-window
@//E*O*F emacs.rc//
chmod u=rw,g=r,o=r emacs.rc
 
echo x - emacs.tut
sed 's/^@//' > "emacs.tut" <<'@//E*O*F emacs.tut//'
You are looking at the MicroEMACS tutorial.  Comments on this document may
be referred to Daniel Lawrance.

NOTE:  This tutorial attempts to help you "learn by doing".  The characters
       ">>" at the left margin of your screen indicate directions for you to
       try using a command.

EMACS commands generally involve the CONTROL key (sometimes labelled CTRL
or CTL) or the META key (generally labelled ESCAPE).  Rather than write out
CONTROL or META each time we want you to prefix a character, we'll use the
following abbreviations:

   ^<chr>    Hold the CONTROL key while pressing the character <chr>.
             Thus, ^F would be:  hold the CONTROL key and press F.

>>  Now type ^V (View Next Screen) to move to the next screen.
    Remember:  hold the CONTROL key and press V.

   ESC-<chr>  Press the ESCAPE key and release it, then press the
              character <chr>.  Note:  The command will have the
              same meaning for upper or lower case characters (<chr>).

IMPORTANT NOTE:  If you must exit at some point, type ^X^C.

For the time being, you'll be expected to type ^V whenever you finish reading
the current screen.

Note that there is an overlap when going from screen to screen; this provides
some continuity when moving through the file.

The first thing that you need to know is how to move around from place to
place in the file.  You already know how to move forward a screen with ^V.
To move back a screen, type ^Z.

>>  Try typing ^Z and then ^V to move back and forth between screens a few
    times.


SUMMARY
-------

The following commands are useful for viewing screens:

     ^V       Move forward one screen
     ^Z       Move back one screen
     ESC-^L   Clear screen and redisplay everything, putting the text
              near the cursor at the center of the screen.

>>  Find the cursor and remember what text is near it.  Type an ESC-^L.
    Find the cursor again and see what text is near it now.


BASIC CURSOR CONTROL
--------------------

Getting from screen to screen is useful, but how do you reposition yourself
within a given screen to a specific place?  There are several ways you can
do this.  One way (not the best, but the most basic) is to use the commands
previous, backward, forward and next.  As you can imagine these commands
(which are given to EMACS as ^P, ^B, ^F, and ^N  respectively) move the
cursor from where it currently is to a new place in the given direction.
Here, in a more graphical form, are the commands:

                          Previous line, ^P
                                  :
                                  :
   Backward, ^B .... Current cursor position .... Forward, ^F
                                  :
                                  :
                          Next line, ^N

You'll probably find it easy to think of these by letter.  P for previous,
N for next, B for backward and F for forward.  These are the basic cursor
positioning commands and you'll be using them ALL the time so it would be
of great benefit if you learn them now.

>>  Do a few ^N's to bring the cursor down to this line.

>>  Move into the line with ^F's and then up with several ^P's.  Note what
    ^P does when the cursor is in the middle of the line.

>>  Try ^B at the beginning of a line.  Note what happened to the cursor.
    Do a few more ^B's.  Then do ^F's back to the end of the line and beyond.

When you go off the top or bottom of the screen, the text beyond the edge is
shifted onto the screen so that your instructions can be carried out while
keeping the cursor on the screen.

>>  Move the cursor off the bottom of the screen with ^N's and see what
    happens.  Note the new position of the cursor.

If moving by characters is too slow, you can move by words.  ESC-F moves
forward a word and ESC-B moves back a word.

>>  Type a few ESC-F's and ESC-B's.  Intersperse them with ^F's and ^B's.

Notice the parallel between ^F and ^B on the one hand, and ESC-F and ESC-B on
the other hand.  Very often META characters are used for operations related
to English text whereas CONTROL characters operate on the basic textual units
that are independent of what you are editing (characters, lines, etc.).

Two other commands which are useful are ^A and ^E.  These commands move the
cursor to the beginning (^A) and the end (^E) of the line.

>>  Try a couple of ^A's, and then a couple of ^E's.  Note that the cursor
    does not move when either of these commands is repeated continuously.

Two other simple cursor motion commands are ESC-< (less than), which moves
to the beginning of the file, and ESC-> (greater than), which moves to the
end of the file.  If you need the shift key to type a "<", then you must
also use the shift key to type ESC-<.  Otherwise, you would be typing ESC-, .

The location of the cursor within the text is also called "point".  To
paraphrase, the cursor shows on the screen where point is located in the
text.

Here is a summary of simple moving operations, including the word and
line moving commands:

     ^F        Move forward a character
     ^B        Move back a character

     ESC-F     Move forward a word
     ESC-B     Move back a word

     ^N        Move to next line
     ^P        Move to previous line

     ESC-N     Move to next paragraph
     ESC-P     Move to previous paragraph

     ^A        Move to beginning of line
     ^E        Move to end of line

     ESC-<     Go to beginning of file
     ESC->     Go to end of file

>>  Try all of these commands now a few times for practice as these are
    the most often used commands.  Since the last two will take you away
    from this screen, use ^V's and ^Z's to return here.

Like all other commands in EMACS, these commands can be given arguments
which cause them to be executed repeatedly.  The way you give a command
a repeat count is by pressing META (ESC) and then the number before you
enter the command.  As a special case, typing ^U is equivalent to ESC-4.

For instance, ESC-8 ^F moves forward eight characters.

>>  Try giving a suitable argument to ^N or ^P to come as close as you
    can to this line in one jump.

This also applies to the screen moving commands, ^V and ^Z.  When given
an argument, they scroll the screen up or down by that many screens.

>>  Try typing ESC-3 ^V now.

If you would like to scroll up, you can give an argument to ^Z.


ABORTING COMMANDS
-----------------

The EMACS command used to abort any command which requests input is
^G.  For example, you can use ^G to discard a numeric argument or at
the beginning of a command that you don't want to finish.

>>  Type ESC-100 to make a numeric argument of 100, then type ^G.
    Now type ^F.  How many characters does it move?  If you have
    typed an ESC by mistake, you can get rid of it with ^G^G.


ERRORS
------
Sometimes you may do something which EMACS doesn't allow.  If it is
something simple, such as typing a CONTROL key sequence which is not
associated with any command, EMACS will just beep at you.  Otherwise,
EMACS will also display an informative error message at the bottom of
the screen.

Some versions of EMACS do not have all the features described in this
tutorial implemented yet.  If you come across such an unimplemented
feature, you may get an error message when you try to use it.  Just
press any cursor movement key and proceed to the next section of the
tutorial.


NOTE:  Several of the exercises in the following sections allow you to use
       options which will make changes to this tutorial. Do no worry about
       these changes affecting the tutorial - this is only a copy of the
       master tutorial and you will not be instructed to save the changes
       made to it.


CURSOR KEYS
-----------

The cursor keypad, usually located on the right side of the keyboard,
has been bound to some of the more useful screen movement commands.
The mappings are as follows:

     Cursor-Right    ^F        Move forward a character
     Cursor-Left     ^B        Move back a character


     ^Cursor-Right   ESC-F     Move forward a word
     ^Cursor-Left    ESC-B     Move back a word


     Cursor-Down     ^N        Move to next line
     Cursor-Up       ^P        Move to previous line


     Pg-Dn           ^V        Move to next screen
     Pg-Up           ^Z        Move to previous screen


     Home            ESC-<     Go to beginning of file
     End             ESC->     Go to end of file


     Insert          ^C        Insert single space
     Delete          ^D        Delete current character

A map of the keypad layout looks something like this:

                   -------------------------------------------------
                   | 7             | 8             | 9             |
                   | Home          | ^             | Pg Up         |
                   |        ESC-<  | |         ^P  |           ^Z  |
                   -------------------------------------------------
                   | 4             | 5             | 6             |
                   | <--       ^B  |               | -->       ^F  |
                   -------------------------------------------------
                   | 1             | 2             | 3             |
                   | End           | |             | Pg Dn         |
                   |        ESC->  | v         ^N  |           ^V  |
       -------------------------------------------------------------
       | 0                           | .                           |
       | Insert                  ^C  | Delete                  ^D  |
       -------------------------------------------------------------

>>  Practice using the cursor keypad.


MODE LINE
---------

The line above the function key display at the bottom of the screen
is referred to as the "communication line".  This is where EMACS
interactively communicates with you.  Later you will see how EMACS
prompts you for information on this line, such as to initiate a
search.  EMACS can report things to you on this line as well.

>>  Type ^X= and see what appears in the communication line. Don't worry
    about what all this information means - it is just an example of how
    EMACS lets you know more about the file you are editing.

The line immediately above the communication line is referred to as the
"mode line".  The mode line looks something like

=* MicroEMACS 3.7 () == emacs.tut == File: emacs.tut ===========================

This is a very useful "information" line.

  -  The asterisk (star) indicates that changes have been made to the file.
     Immediately after opening or saving a file, there is no star.

  -  Any words inside the parentheses indicate the "modes" EMACS is
     currently in.  Modes will be discussed in the next section.

  -  The string following the () is the buffername, i.e., the name EMACS
     gives to the buffer, and it is usually related to the filename.

  -  The string following "File:" is the name of the file you are
     currently editing.

>>  Look at the mode line and identify the items discussed above.


MODES
-----

Listed within the parentheses are the "modes" which are associated with
the current buffer.  Modes are a feature of EMACS which assist in the
editing of different languages, i.e., C, and text.  Presently, there are
no modes associated with this buffer.  This means EMACS will do exactly
what you think it will when using it - no "bonuses".  You can find out
more about the current buffer and mode status by typing ^X^B.  Refer to
the EMACS manual for a further discussion of buffers and modes.

As you become more familiar with EMACS and the use of buffers, "mode"
takes on additional meaning.  When more than one buffer is in use, a
mode is referred to as "local" or "global".  These terms indicate how a
mode will affect the current buffer and other existing or to be added
buffers.

A "local" mode is valid only within the scope of the current buffer.
Other existing buffers and buffers which will be added are not affected
by local modes.

The commands to add and delete local modes are

     ^XM       Add a local mode
     ^X^M      Delete a local mode

Each of the above commands will prompt you for a mode.  To activate
(deactivate) a mode, type the name of a valid (active) mode (refer to
EMACS manual for a complete list of the valid modes) and follow it by
pressing <Return>, the carriage-return key.

>>  Type ^XM WRAP - note the change in the mode line.  Move the cursor
    to a blank line on this screen and begin typing the sequence "asdf ".
    Continue typing this sequence and note what happens when the right
    margin is encountered.

The previous exercise allowed you to enter text with the "WRAP" mode
active.  As you can see, "WRAP" instructs EMACS to break between words
when a line gets too long.  However, in order for this mode to be
effective, spaces must be inserted between words.

The right margin is usually set at 72 characters but it can be changed.
To change the margin type ESC nn ^XF where "nn" is the column number of
the new right-hand margin.

>>  Type ESC 40 ^XF.  Then begin typing "asdf " and notice where the
    line now breaks.  To return to the default right-hand margin, type
    ESC 72 ^XF.

>>  Type ^X^M WRAP to "turn off" the local mode "WRAP".

A "global" mode affects only those buffers which will be ADDED after the
"add/delete global mode" command is executed - not the current or other
existing buffers.  Currently there is no global mode set.

The commands to add and delete global modes are

     ESC-M     Add a global mode
     ESC-^M    Delete a global mode

Note:  All modes can be local.  However, global modes allow you to
       activate those modes which usually apply to most of the buffers
       in use.

As with local modes, each of the above commands will prompt you for
a mode.  To activate (deactivate) a mode, enter the name of a valid
(active) mode.

>>  Type ESC-M OVER.  This mode tells EMACS to write over the text on
    the current line.  Is there any change in the mode line? Now move to
    the line of "asdf " you entered and start typing.  Note that nothing
    happens.  Remember that global modes affect only those modes which
    will be added - not those already existing.

>>  Type ESC-^M OVER to "turn off" the global overwrite mode.


INSERTING AND DELETING
----------------------

If you want to type text, just start typing.  Characters which you
can see, such as A, 7, *, etc. are taken by EMACS as text and are
immediately inserted.  Type <Return> to insert a line separator,
i.e., a single linefeed character.

You can delete the last character you typed by typing either <Delete>
or ^H.  On some keyboards, there is a dedicated key for creating a ^H.
If so, it is usually labelled as either "Backspace" or "<--".  <Delete>
is a key on the keyboard, which may be labelled "Rubout" instead of
"Delete" on some terminals.  More generally, <Delete> deletes the
character immediately before the current cursor position.

>>  Now type a few characters and then delete them by typing <Delete>
    a few times.

>>  Now start typing text until you reach the right margin, then continue
    to type.  When a line of text gets too big for one line on the screen,
    the line of text is "continued" off the edge of the screen.  The dollar
    sign at the right margin indicates a line which has been continued.
    EMACS scrolls the line over so you can see what you are editing.  The
    "$" at the left or right edge of the screen indicates that the current
    line extends off in that direction.

This concept is easier to understand by doing rather than by reading about
it so it is suggested that the following exercises be done.

>>  The following line actually goes off the edge.  Try typing enough ESC-F's
    so that you move off the right hand end of this line.  This is a long line of text.  Note the "$" at each edge.  Keep typing ESC-F's and watch where EMACS decides to scroll the line.  Now, type ESC-B's until EMACS decides to scroll the line again.

>>  Go to the line you entered which the text continued off the edge of
    the screen.  Use ^D's to delete the text until the text line fits on
    one screen line again.  The continuation "$" will go away.

>>  Move the cursor to the beginning of a line and type <Delete>.  This
    deletes the line separator before the line and merges the line onto
    the previous line.  The resulting line may be too long to fit on the
    screen, in which case it has a continuation indicator.

>>  Press <Return> to insert the separator again.

Internally, EMACS will allow you to have lines of nearly any length, limited
only by the amount of memory available.  Externally, however, EMACS can only
read or write lines, to or from a file, which are less than or equal to 255
characters.

Remember that most EMACS commands can be given a repeat count.  Note that
this includes characters which insert themselves.

>>  Try that now -- type ESC-8 * and see what happens.

If you want to insert spaces in a line, type ^C.

>>  Move to a line and move the cursor with ^F's; then insert spaces with ^C.
    Use ^D to remove the spaces.

If you want to create a blank line between two lines, move to the second
of the two lines and type ^O.

>>  Try moving to a line and typing ^O now.

You've now learned the most basic way of typing something in EMACS and
correcting errors.  You can delete characters, words or lines as well.
Here is a summary of the delete operations:

     <Delete>      Delete the character just before the cursor
     ^H            Delete the character just before the cursor
     ^D            Delete the character the cursor is under

     ESC-<Delete>  Kill the word immediately before the cursor
     ESC-^H        Kill the word immediately before the cursor
     ESC-D         Kill the word from the cursor position

     ^K            Kill from the cursor position to end of line

Notice that <Delete> and ^D vs ESC-<Delete> and ESC-D extend the parallel
started by ^F and ESC-F (well, <Delete> isn't really a control character,
but let's not worry about that).

Now suppose you kill something, and then you decide that you want to get
it back?  Well, whenever you kill something bigger than a character, EMACS
saves it for you.  To yank it back, use ^Y.  Note that you don't have to
be in the same place to do ^Y.  This is a good way to move text around.
Also note the difference between "Killing" and "Deleting" - "Killed" text
can be yanked back, and "Deleted" text cannot.  Generally, the commands
that can destroy a lot of text save it, while the ones that attack only
one character do not save it.

>>  Type ^N a couple times to position the cursor at some line on this
    screen.  Now kill that line with ^K.

Note that a single ^K kills the contents of the line, and a second ^K
kills the line itself, and makes all the other lines move up.  If you
give ^K a repeat count, it kills that many lines AND their contents.

The text that has just disappeared is saved so that you can retrieve it.
To retrieve the last killed text and put it where the cursor currently
is, type ^Y.

>>  Try it.  Type ^Y to yank the text back.

Think of ^Y as if you were yanking something back that someone took away
from you.  Notice that if you do several ^K's in a row the text that is
killed is all saved together so that one ^Y will yank all of the lines.

>>  Try it.  Type ^K several times.

>>  To retrieve that killed text:  Type ^Y.  Move the cursor down a few
    lines and type ^Y again.  You now know how to copy text.

What do you do if you have some text you want to yank back, and then
you kill something else?  ^Y would yank the more recent kill.

>>  Kill a line, move around, kill another line.  Then do ^Y to get back
    the second killed line.


SEARCHING
---------

EMACS can do searches for strings (these are groups of contiguous
characters or words) either forward through the file or backward
through it.

>>  Now type ^S to start a search.  Type the word "cursor", then ESC.

>>  Type ^S ESC to find the next occurrence of "cursor".

The ^S starts a search that looks for any occurrence of the search
string AFTER the current cursor position.  But what if you want to
search for something earlier in the text?  To do this one should
type ^R for Reverse search.  Everything that applies to ^S applies
to ^R except that the direction of the search is reversed.


TEXT REPLACEMENT
----------------

>>  Move the cursor to the blank line two lines below this one.
    Then type ESC-R changed ESC altered ESC .

    Notice how this line has changed; you have replaced the word
    "changed" with "altered" wherever it occurs in the file after
    the cursor.  After all the substitutions have been made or
    the end of file has been reached, a message informing you of
    the number of substitutions which have been made appears in
    the communication line.

The more customary command for replacing strings is the interactive
command query-replace-search (ESC-^R), which has several options.  In
essence, it shows each occurrence of the first string and asks you if
you want to replace it or not.  Type a "?" when it asks to replace the
string to list the various options for query-replace-search.  For a
more detailed discussion of this command refer to the EMACS manual.


FILES
-----

In order to make the text changes permanent, you must save them to a file.
If you do not save them, the changes will "disappear" when you leave EMACS.
As you make changes, i.e., corrections, deletions, insertions, etc., they
are actually written to a "scratch" copy of the file and the changes to
this file will not affect the "master" copy of the file until a file save
is specified. This allows you to decide if changes made to the file should
be made permanent or discarded.

Remember:  The file name appears on the mode line.

=* MicroEMACS 3.7 () == emacs.tut == File: emacs.tut ===========================
                                     ---------------

The commands for finding and saving files are unlike the other commands
you have learned so far in that they consist of two characters - a ^X
followed by another character which specifies the file command to be
executed.

To find a file, type ^X^F.  EMACS will then prompt you from the
communication line for the name of the file.  In response to the prompt,
type the file name followed by a <Return> to indicate the file name has
been entered.  This command will tell EMACS to go find this file and
load it.  Its contents will then be displayed on the screen and you will
be able to edit the file's contents.

To save any changes made to the file, type ^X^S.  This tells EMACS to
create a new version of the file which includes the changes you have
made.  When the save is complete, the number of lines saved will be
displayed in the communication line.

If you edit a file and at some point decide to quit (i.e., ^X^C) without
saving the changes, EMACS will remind you that changes have been made to
the file and ask you if you really want to quit.  Enter "N" to return to
EMACS or "Y" to exit EMACS without saving the changes.

To create a file, just edit it "as if" it already existed.  Then start
typing in the text.  When you ask to "save" the file, EMACS will really
create the file with the text that you have entered.  From then on, you
can consider yourself to be editing an existing file.

It is not easy for you to test editing a file and continue with the
tutorial.  But you can always come back into the tutorial by starting
it over and skipping forward.  So, when you feel ready, you should
try editing a file named "FOO", putting some text in it, and saving
it; then exit EMACS and look at the file to be sure that it worked.


EXTENDING THE COMMAND SET
-------------------------

There are many, many more EMACS commands than could possibly be put on all
the CONTROL and META characters.  EMACS gets around this with the X (eXtend)
command.  There are two forms of this command:

     ^X       Character eXtend.  Followed by one character.
     ESC-X    Named command eXtend.  Followed by a long name.

These are commands that are generally useful but used less than the commands
you have already learned about.  You have already seen two of them: the file
commands ^X^F to Find and ^X^S to Save.  Another example is the command to
tell EMACS that you'd like to stop editing.  The command to do this is ^X^C.

There are many ^X commands.  Right now, the most helpful ones will be

     ^X^F   Find file.
     ^X^S   Save file.
     ^X^C   Quit EMACS.  This does not save your files automatically;
              however, if your files have been modified, EMACS asks if
              you really want to quit.  The standard way to save and
              exit is ^X^S ^X^C.

Named eXtended commands are commands which are used even less frequently,
or commands which are used only in certain modes.  These commands are
usually called "functions".  An example is the function "apropos", which
prompts for a keyword and then gives the names of all the functions that
are apropos for that keyword.  When you type ESC-X, EMACS prompts you from
the communication line with ":" and you should type the name of the
function you wish to call; in this case, "apropos".  Just type "apr<Space>"
and EMACS will complete the name.  EMACS will ask you for a keyword or
phrase and you type the string that you want information on.

>>  Type ESC-X, followed by "apropos<Return>" or "apr<Space>".  Then
    type "file" followed by a <Return>.  Note: ESC-A is equivalent to
    the ECS-X "apropos" command.

>>  To remove the "window" that was added, type ^X0 (zero).


FUNCTION KEYS
-------------

By now, you should be familiar with the format and meaning of some of
the more common CONTROL and META commands.  Because several of these
commands are used frequently, they have been bound to the function
keys, which are usually located on the left-hand side of the keyboard
and labelled F1..F10.  By pressing the appropriate function key, one
can replace several keystrokes with a single keystroke, thus saving
you time as you become familiar with their use.

The highlighted portion at the top of the screen lists the commands
which are associated with each function key.  Each function key supports
two commands specified by fn or Fn where n = 1, 2,...10.  The default
commands are represented by fn and are defined on the left side of the
screen; these commands are executed by pressing the appropriate function
key.  The secondary commands are represented by Fn and are defined on
the right side of the screen; these commands are executed by pressing
the <Shift> key and the appropriate function key at the same time.

>>  Press f1 would ESC.  Note the position of the cursor - "would"
    was located just as if ^S would ESC had been entered.  Enter
    ^S would ESC to see for yourself.

>>  Press F1 (<Shift> f1).  Note the different appearance of the screen.
    You have toggled the function key list, i.e., "turned it off".  To
    "turn it on", press F1 again.

>>  Try using some of the other function keys to become familiar with
    their use.  NOTE:  Do NOT use f9 with this file as it would save
    any changes you may have made while using the tutorial.


GETTING MORE HELP
-----------------

In this tutorial we have tried to supply just enough information to get
you started using EMACS.  There is so much available in EMACS that it
would be impossible to explain it all here.  However, you may want to
learn more about EMACS since it has numerous desirable features that you
don't know about yet.

The most basic HELP feature is the describe-key function which is
available by typing ^X? and then a command character.  EMACS prints
one line in the communication line to tell what function is bound
to that key.

>>  Type ^X?^P.  The message in the communication line should
    be something like "^P is bound to previous-line".

NOTE:  Multi-character commands such as ^X^Z and ESC-V are also
       allowed after ^X? .

###  The describe-command function does not work - December 1986  ###
###  Skip to the next section                                     ###

The describe-command function (ESC-?) will prompt for the name of a
function and print out the section from the manual about that command.
When you are finished reading it, type a space or a ^G (quit) to bring
your text back on the screen.

Now let's get more information about the previous-line command.

>>  Type ESC-?^P.  When you are finished reading the output, type <Space>.

The "name of the function" is important for people who are customizing
EMACS.  It is what appears in the EMACS CHART as the documentation for
the command character.


CONCLUSION
----------

Remember:  To EXIT use ^X^C.

This tutorial is meant to be understandable to all new users, so if
you found something unclear, don't sit and blame yourself - complain!

You'll probably find that if you use EMACS for a few days you won't be
able to give it up.  Initially it may give you trouble.  But remember,
this is the case with any editor, especially one that can do many, many
things - and EMACS can do practically everything.


ACKNOWLEDGEMENTS
----------------

This is a modified version of the "JOVE Tutorial" by Jonathan Payne
(19 January 86).  That document was in turn a modified version of
the tutorial "Teach-Emacs" from MIT as modified by Steve Zimmerman
at CCA-UNIX (31 October 85).

Update - February 1986 by Dana Hoggatt.

Update - December 1986 by Kim Leburg.
@//E*O*F emacs.tut//
chmod u=rw,g=r,o=r emacs.tut
 
exit 0
