/* TEACH-EMACS-SUI-1, EMACSSRC>EMACS*, ENVIRONMENTS AND TOOLS, 06/30/86
/* Tutorial file for EMACS "standard user interface" (SUI) 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 the standard interface
(alias SUI).  As stated in TEACH-EMACS-SUI-INSTRUCTIONS, please skip
over the header at the beginning of each tutorial file.


The standard interface uses the function keys on your terminal which are
defined by a template that fits over the keys.  Make sure you have a template
before beginning this exercise.  If you don't, press CONTROL P to exit.



Press the {NEXT SCREEN} key (or {NEXT PAGE} if using a PT45 terminal)
to continue with this tutorial.



This module will teach you the following EMACS functions:

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

You will often be asked to enter 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 {NEXT SCREEN} to move to  the  next  screen.   (Go  ahead  and
   do  it.)  NOTE:  From now on, you'll be expected to press {NEXT SCREEN}
   whenever you finish reading a screen.



Most of the EMACS functions that this exercise will teach you can be
performed by using the function keys.  These keys will be noted in this
tutorial as follows:

     {key name}    means press the key with this name on the template

Thus, {NEXT SCREEN} means to press the key labelled NEXT SCREEN (or press
{NEXT PAGE} if using a PT45 terminal).

Note:  The PT45 template uses a few key names that are different.  This tutorial
will identify the differences the first time the key function is introduced.


Some EMACS commands are 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  pressing a
                   character.
     {ESC}char     means press ESCAPE, release, and then enter the character.

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
{NEXT SCREEN}.  To move backward a screen, press {PREV SCREEN} (or {PREV PAGE}
on the PT45 template).


>> Try pressing {PREV SCREEN} and then {NEXT SCREEN} to move back and forth a
   few times.

(If you want to leave the  tutorial  before  you've  come  to  its  end,  press
{QUIT EMACS} (or {EXIT} on the PT45 template).  (If  EMACS  prompts you,
asking if it is OK to quit, just enter "YES".)


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

The following commands are useful for viewing screens:

                                                     PT45 template
     {NEXT SCREEN}    Move forward one screen         {NEXT PAGE}
     {PREV SCREEN}    Move backward one screen        {PREV PAGE}
     {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 {NEXT SCREEN} 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
(the most basic) is  to  use  the  commands  previous,  backward,
forward, and  next.   As  you  can imagine, these commands (which are given to
EMACS by using the directional arrows) are executed by using the keys labelled
{UP}, {LEFT}, {RIGHT}, and {DOWN} 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, {UP}
                                    :
                                    :
Backward, {LEFT} .... Current cursor position .... Forward, {RIGHT}
                                    :
                                    :
                           Next line, {DOWN}

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 pressing a few {DOWN}s to bring the cursor down  to  this  line.
   Move into the  line  with  {RIGHT}s  and up with {UP}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 {LEFT} at the beginning of a line.  Do a few more {LEFT}s.
   Then do {RIGHT}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.
The key {CHAR/WORD} (or {WORD/CHAR} on the PT45 template) changes the meaning
of the directional arrows.  When this key is pressed, the EMACS mode line (the
first line in the white area) includes the word "word".   For example,
pressing {CHAR/WORD} changes to word mode and then pressing {RIGHT} moves
forward a word.  {LEFT} moves back a word.  EMACS will remain in WORD mode
until the {CHAR/WORD} key is pressed again.  "word" disappears from the mode
line.  This key switches between accessing words and characters.


>> Press {CHAR/WORD} and then press a few {RIGHT}s and {LEFT}s.
   Notice that the cursor moves one word at a time.
   Press {CHAR/WORD} again and press a few {RIGHT}s and {LEFT}s.
   Notice that the cursor now moves a character at a time again.


You may find a need to position the cursor in the upper left most corner
of the screen.  This position is referred to as the "home" position.  To
accomplish this, simply press the {HOME} key.


>> Try pressing the {HOME} key now.


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


>> Try a couple of {BEGIN LINE}s and then a couple of {END LINE}s.


Two other  simple  cursor  motion  commands  are {TOP FILE}
which moves to the beginning of the file, and {END FILE}
which moves to the end of the file (or {TOP OF FILE} and {END OF FILE} on the
PT45 template).


>> Go ahead and try {TOP FILE} and {END FILE} now.  Since they will take
   you away from this screen, you'll have to remember this spot.  You can use
   {NEXT SCREEN} and {PREV SCREEN} 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:

                                                            PT45 Template
     {CHAR/WORD}     To switch between moving by words or    {WORD/CHAR}
                     by characters

     {RIGHT}         Move forward a character or word
     {LEFT}          Move backward a character or word
     {DOWN}          Move to next line
     {UP}            Move to previous line

     {HOME}          Move cursor to home position
     {BEGIN LINE}    Move to beginning of line
     {END LINE}      Move to end of line

     {TOP FILE}      Go to beginning of file                 {TOP OF FILE}
     {END FILE}      Go to end of file                       {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
enter {ESC}8{RIGHT}.   If  you  wanted  to  move back 3 words, you would
insure that the {CHAR/WORD} key was in "word" mode and enter {ESC}3{LEFT}.


>> Try giving a suitable argument to {UP} or {DOWN} 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.


>> Enter {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{RIGHT}.  You can interrupt EMACS in the middle of this sort of
command by pressing {CTRL-G}. Try this now:


>> Enter {ESC}100 to make a numeric argument of 100, then press {CTRL-G}.
   Now press {RIGHT}.  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, press {RETURN}.
To insert a new line before point, press {OPEN LINE} (or {INSERT LINE} on the
PT45 template).

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


>> Now go ahead and enter a few characters  and  then  delete them by pressing
   {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,
   press {CTRL-P} immediately and read the file "TEACH-EMACS-SUI-INSTRUCTIONS".)


>> Try positioning the cursor at the beginning of a line ({BEGIN LINE}) and
   then press {OPEN LINE}.  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 -- enter  {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:

                                                             PT45 template
     {OPEN LINE}        Insert a new line before point       {INSERT LINE}

     {BACKSPACE}        Delete the character just before
                        the cursor (or the WORD if you are in
                        word mode)

     {DELETE FORWARD}   Delete the character at point (or    {DELETE CHAR}
                        the WORD if you are in word mode)

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

     {DELETE LINE}      Delete (kill) the entire line no matter where the
                        cursor appears on the line

Deleting a line causes the line to disappear and the text following that line
to move up.  Don't forget that you can use the {ESC}count prefix with these
commands as well.  For example, to delete 10 lines, enter {ESC}10{DELETE LINE}

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, press {PREV SCREEN} 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
when you exit EMACS.  The easiest way to save the changes in a file is to press
{SAVE FILE}.  (On the PT45, this is not marked on the template...use the
{LOCAL} key.  Please add the label for the SAVE key on your template.)  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 press
{FIND FILE} followed by the name of the file you want to edit or create.
(The PST100 and PT45 templates have this key labelled {GET FILE}.  Please mark
your template to read {FIND FILE} instead.)  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 pressing {QUIT EMACS}.  If you press
{QUIT EMACS} and you have not saved all edited files 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:

                                                            PT45 template
     {FIND FILE}        Finds or creates file you specify    {GET FILE}

     {SAVE FILE}        Saves changes in current file        {LOCAL}

     {QUIT EMACS}       Exits EMACS and takes you back to    {EXIT}
                        PRIMOS



CONCLUSION
__________

This concludes "TEACH-EMACS-SUI-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-SUI-2  (or  another  file),
   press {FIND FILE} followed  by TEACH-EMACS-SUI-2 (or the name of the other
   file) and {RETURN}.


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



END OF TEACH-EMACS-SUI-1
