/* TEACH-EMACS-FUND-1, EMACSSRC>EMACS*, ENVIRONMENTS AND TOOLS, 06/30/86
/* Tutorial file for EMACS fundamental mode - file 1 of 4
/* Copyright (c) 1986, Prime Computer Inc., Natick, MA 01760


You are looking at Part 1 of the EMACS tutorial for fundamental mode.  As
stated in TEACH-EMACS-FUND-INSTRUCTIONS, please skip over the header at the
beginning of each tutorial file.

This module will teach you the following EMACS functions:

     Page movement
     Cursor movement
     Deleting characters and lines
     Getting and saving files
     Exiting to PRIMOS

Hold down the CONTROL key and press V to continue with this tutorial.




EMACS commands are generally prefixed by the CONTROL key or  the  ESCAPE  key.
Instead of  writing  out  ESCAPE  or CONTROL each time we want you to prefix a
character, we'll use the following abbreviations:

     {CTRL-char}   means hold  down  the  CONTROL  key  down  while  typing  a
                   character.
     {ESC}char     means press ESCAPE, release, and then press the character.

Thus, {CTRL-V} means hold the CONTROL key and press V.  You will often be asked
to type characters to see how they work;  don't  actually  do  this,  however,
until you see >> at the left of the screen.  For instance:

>> Now press {CTRL-V} to move to  the  next  screen.   (Go  ahead  and  do  it.
   Depress the CONTROL key and the V together).  NOTE:  From now on, you'll be
   expected to type {CTRL-V} whenever you finish reading a screen.

Notice that there is a 3 line overlap of text when you go from screen to screen.
This provides some continuity when you move 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
{CTRL-V}.  To move backward a screen, press {ESC}V.   (Type  ESCAPE  and  then
type V.)

>> Try typing {ESC}V and then {CTRL-V} to move back and forth a few times.

(If you want to leave the  tutorial  before  you've  come  to  its  end,  type
{CTRL-X} {CTRL-C}.   If  EMACS  prompts you, asking if it is OK to quit, just
enter "YES".)


Command Summary
---------------

The following commands are useful for viewing screens:

     {CTRL-V}         Move forward one screen
     {ESC}V           Move backward one screen
     {CTRL-L}         'Refresh' the current screen


>> Try {CTRL-L} now.  (You'll notice that it centers  the  screen  around  the
   line currently  containing  the cursor.)  If this happens to move this text
   off the screen, just do a {CTRL-V} to see it again.)


{CTRL-L} is also useful for refreshing the screen image if the screen has been
changed by a system message or a message from another user.  Later, you'll
learn other things to do with {CTRL-L}.


BASIC CURSOR CONTROL
____________________

Getting from screen to screen is useful, but how do you move the cursor  to  a
specific place  within  a given screen?  There are several ways.  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 {CTRL-Z}, {CTRL-B}, {CTRL-F}, and  {CTRL-N}  respectively)  move  the
cursor from its current position to a new place in the given direction.  Here,
in pictorial form, are the commands:

                            Previous line, {CTRL-Z}
                                    :
                                    :
   Backward, {CTRL-B} .... Current cursor position .... Forward, {CTRL-F}
                                    :
                                    :
                               Next line, {CTRL-N}

You'll probably find it easy to think of most of these by letter.  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.


>> Try typing a few {CTRL-N}s to bring the cursor down  to  this  line.   Move
   into the  line  with  {CTRL-F}s  and up with {CTRL-Z}s.  Now use these four
   commands to play around a little.  Try moving off the top  of  this  screen
   and see what happens.


Lines are separated by a single RETURN character.


>> Try {CTRL-B} at the beginning of a line.  Do a few more {CTRL-B}s.  Then do
   {CTRL-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.

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


>> Type a few {ESC}Fs  and  {ESC}Bs.   Intersperse  them  with  {CTRL-F}s  and
   {CTRL-B}s.


Notice the  parallel between {CTRL-F} and {CTRL-B} on one hand, and {ESC}F and
{ESC}B on the other hand.  Very often Escape commands are used for  operations
related to  English  text (e.g.  words, sentences, paragraphs) whereas Control
commands operate on characters and lines.

You should also know about two commands that work on whole lines.
  {Ctrl-A} moves you to the begining of the line, and
  {CTRL-E} moves you to the end of the line.
When you are editing text, you will use these two commands often.


>> Try a couple of {CTRL-A}s and then a couple of {CTRL-E}s.


{ESC}A and {ESC}E parallel {CTRL-A} and {CTRL-E}.  {ESC}A moves the cursor  to
the beginning  of  a  sentence.   {ESC}E  moves  the  cursor  to  the end of a
sentence.


>> Now go ahead and type {ESC}A and {ESC}E a few  times.   Type  {CTRL-A}  and
   {CTRL-E} again, too.  Notice the differences.


Two other  simple  cursor  motion  commands  are {ESC} < ("Escape Less-than"),
which moves to the beginning of the file, and {ESC} > ("Escape Greater-than"),
which moves to the end of the file.


>> Go ahead and try {ESC}> and {ESC}< now.  Since they will take you away from
   this screen, you'll have to remember this spot.  You can use  {CTRL-V}  and
   {ESC}V to  get back.  Later, you'll learn some faster ways to get back to a
   particular place in a file.


Command Summary
---------------

Here is a summary of the simple moving operations you've learned so far:

     {CTRL-F}   Move forward a character
     {CTRL-B}   Move backward a character

     {ESC}B     Move backward a word
     {ESC}F     Move forward a word

     {CTRL-N}   Move to next line
     {CTRL-Z}   Move to previous line

     {CTRL-A}   Move to beginning of line
     {CTRL-E}   Move to end of line

     {ESC}A     Move to beginning of sentence
     {ESC}E     Move to end of sentence

     {ESC}<     Go to beginning of file
     {ESC}>     Go to end of file


>> These are the most often used commands.  Try all of them again a few  times
   for practice.


ARGUMENTS
---------

There will be times when you will wish to execute a simple EMACS command more
than once.  This is done by preceding the command with what is called a
"numeric argument."  To specify an argument, just press {ESC} followed by a
number BEFORE you enter a command.  That command will then be done ARGUMENT
times.

For example, if you wanted to move the cursor forward 8 characters, you  would
type {ESC}8 {CTRL-F}.   If  you  wanted  to  move back 3 words, you would type
{ESC}3{ESC}B.


>> Try giving a suitable argument to {CTRL-N} or {CTRL-Z} to come as close  as
   you can to this line in one jump.


{CTRL-L}, (which  refreshes  the  screen),  can also be used with an argument.
However, it doesn't do what you  think  it  might.   {ESC}3  {CTRL-L}  doesn't
refresh the  screen three times -- that wouldn't make much sense.  Instead, it
moves the line containing the cursor to line 3 of your screen.


>> Type {ESC}0 {CTRL-L}, then {ESC}20 {CTRL-L}, and finally just {CTRL-L}.


POINT
-----

The location of the cursor in the text is called "point" in the EMACS
documentation.  Although the cursor appears to rest on a specific character, it
is actually "pointing" between that character and the one before it.
Therefore, point is actually located between two adjacent characters.  Most
EMACS commands take effect before or after point.


ABORTING COMMANDS
__________________

Aborting an ongoing EMACS command or session:  CTRL-P
_____________________________________________________

If you tell EMACS to do something and then decide you don't want it finished,
you can stop the action by pressing {CTRL-P}.  This interrupts your session,
rings the terminal bell, and displays this message:

Control-P typed.
To really Quit from EMACS, type Q
To return to EMACS and Abort the current command (if any), type A
To return to EMACS and Continue with no interruption, type C
Confirm your choice with the RETURN key.
Typing the RETURN key without making a choice is the same as Continue.
(If no EMACS command was executing when you typed Control-P,
 then Abort is the same as Continue.)
You may need to refresh the screen if you choose to re-enter EMACS.


Aborting an incompletely given EMACS command:  CTRL-G
_____________________________________________________

Some EMACS commands involve more than one keystroke - for example
{ESC}5{CTRL-F}.  You can interrupt EMACS in the middle of this sort of
command by typing {CTRL-G}. Try this now:


>> Type {ESC}100 to make a numeric argument of 100, then type {CTRL-G}.
   Now press {CTRL-F}.  How many characters does the cursor move?


INSERTING AND DELETING
______________________

If you  want  to  insert  text into your file, just type it.  EMACS interprets
normal printing characters, such as s, A, 7, *, etc., as text and inserts them
immediately at point.

To start a new line of text or to insert a blank line at point, type {RETURN}.
To insert a new line before point, press {CTRL-O}.

You can delete the last character you  inserted  by  typing  {BACKSPACE}.   It
deletes the character immediately before point.


>> Now go ahead and type a few characters  and  then  delete  them  by  typing
   {BACKSPACE}.  Don't  worry about this file being changed;  you won't affect
   the master tutorial.  This is just a copy.  (If you  didn't  make  a  copy,
   type {CTRL-P} immediately and read the file "TEACH-EMACS-FUND-INSTRUCTIONS".)


>> Try positioning the cursor at the beginning of a line ({CTRL-A}) and
   then press {CTRL-O}.  Notice how room is made for a new line to be
   entered.


Remember that most EMACS commands can be given a repeat count, or numeric
argument.  This includes characters which insert themselves, like those you
entered and then deleted above.


>> Try giving an argument to a character now -- type  {ESC}8 *  and  see  what
   happens.


You've now  learned how to insert text into a file in EMACS and the most basic
way of correcting errors.  You can delete text by  words  or  lines  as  well.
Here is a summary of the insert and delete operations:

     {CTRL-O}           Insert a new line before point

     {BACKSPACE}        Delete the character just before the cursor

     {CTRL-D}           Delete the next character after the cursor

     {ESC}{BACKSPACE}   Kill the word immediately before the cursor

     {ESC}D             Kill the next word after the cursor

     {CTRL-K}           Kill from the cursor position to end of line
                        (You will need two to get the following RETURN)

Note that a single {CTRL-K}, with point at the beginning of the line, will kill
the contents of the line (if any).  A second {CTRL-K} will delete the line
itself, and make all the other lines move up.


>> Now go ahead and try all of the deletion commands.   To make sure you don't
   delete instructions that you  haven't yet read, type {ESC}V once or twice
   and practice deleting text that you've already read.  Insert some new text
   of your own and practice deleting that, too.  The next tutorial file will
   show you how to restore deleted text.


FILES:  SAVING AND EXITING
--------------------------

Unless you save your editing changes in a file, they will not become permanent
once you exit EMACS.  The easiest way to save the data in a file is to type
{CTRL-X}{CTRL-S}.  This command saves your text in the file you're currently
working with.

To create  a  new  file  or  edit  an  old one once you're in EMACS, just type
{CTRL-X}{CTRL-F} followed by the name of the file you want to edit or create.
EMACS will then display the contents of that file (or a blank screen if you're
creating it)  on  your  screen.  You can use this command as often as you like
during one editing session to switch from file to file.

You can leave EMACS at any time by typing {CTRL-X}{CTRL-C}.  If you press
{CTRL-X}{CTRL-C} and you have not saved all edited buffers to the disk, EMACS
will query you to see if you really meant to exit without saving.  EMACS shows
you a list of your unsaved buffer(s) and asks:

   Above list of modified buffer(s) not saved to file(s).  Quit anyway?

If you do not wish to save the changed buffer(s) to disk, answer YES.  If you
merely forgot to save the file first and wish to save it, answer NO and then
save them.



Command Summary
---------------

These commands deal with files, saving, and exiting:


     {CTRL-X}{CTRL-F}   Finds or creates file you specify

     {CTRL-X}{CTRL-S}   Saves changes in current file

     {CTRL-X}{CTRL-C}   Exits EMACS and takes you back to PRIMOS


CONCLUSION
__________

This concludes "TEACH-EMACS-FUND-1".


>> To practice what you have just learned, use EMACS to create a new file
   of your own choosing.  Ideas:

           List the names of the people in your family.
           Write a letter to your previous manager that you will never send.
           Describe what you would do if you inherited 10 million dollars.


>> If you want to continue on to TEACH-EMACS-FUND-2 (or another file), type
   {CTRL-X}{CTRL-F} followed by TEACH-EMACS-FUND-2 (or the name of the other
   file) and {RETURN}.


>> If you want to get out of EMACS and back to PRIMOS, type  {CTRL-X}{CTRL-C}.
   If you see the message:
        "Above list of modified buffer(s) not saved to file(s).  Quit anyway?"
   Enter "YES".


END OF TEACH-EMACS-FUND-1
