/* TEACH-EMACS-SUI-3, EMACSSRC>EMACS*, ENVIRONMENTS AND TOOLS, 06/30/86
/* Tutorial file for EMACS "standard user interface" (SUI) mode - file 3 of 4
/* Copyright (c) 1986, Prime Computer Inc., Natick, MA 01760


You are looking at Part 3 of the EMACS tutorial for the standard interface.
This module will teach you the following EMACS functions:

     File management
     Buffer management
     Window management
     Overlay mode

This tutorial  assumes  that  you  have mastered the basic EMACS commands
discussed in TEACH-EMACS-SUI-1 & 2.  If you don't feel comfortable using those
commands, you should go back to TEACH-EMACS-SUI-1 or 2 and practice with
them for a while.

Note:  This tutorial follows the  conventions of TEACH-EMACS-SUI-1 -- you are
expected to press {NEXT SCREEN} when you come to the end of each screen and
follow all instructions preceded by ">>".


Remember that you can use  the  search  commands  to  refer  to  the  "Command
Summary" sections if you want information about commands quickly.


BUFFERS
_______

One of  EMACS' nicest features is its ability to control more than one file at
a time.  It does this by using multiple  buffers.   A  buffer  is  a  sort  of
working environment set aside for you to use to edit text.  Each file you edit
is placed  in  a buffer.  Although you can only edit one buffer at a time, you
can switch to a different one as often as you like.

Each buffer in EMACS has a name, which is always displayed in  parentheses  at
the bottom  of your screen.  The name of the buffer you're working with now is
called  "TEACH-EMACS-SUI-3".  If you look  down at the bottom of your screen,
you will see it in parentheses.

EMACS buffers generally have the same names as the files they contain.  If you
look down  at  the  bottom  of  your screen again, you'll see that is the case
right now.  The full Prime pathname which describes  this  file  is  displayed
next to the name of the buffer.


The Mode Line
-------------

The area  of  the  screen  that gives you information about your current EMACS
buffer is called the mode line.  As you go along,  you'll  discover  that  the
mode line  gives  you all sorts of information about what's going on in EMACS.

The number following the word "EMACS" on the mode line tells you  the  version
of EMACS  that  you're using.  An asterisk (*) in the mode line tells you that
the current buffer contains modified text that hasn't been saved to a file.

>> To demonstrate, simply press the space bar to insert a space.  Notice that
the asterisk now appears in the mode line.  The asterisk appears no matter how
insignificant the change may seem.

If you don't specify a filename when you start up EMACS, it puts  you  into  a
buffer it  calls  "main".   Otherwise, it puts you into a buffer with the same
name as the file you specified.


Switching to a New Buffer
-------------------------

To switch to or create a new buffer, you can use the {CTRL-X}B command.   This
command prompts  you for a buffer name.  It is similar to the {FIND FILE}
command described in "TEACH-EMACS-SUI-1", but it lets you choose the name of
the buffer instead of automatically assigning it a name.  This way, you can work
with two different versions of the same file.

Another good thing about creating a buffer yourself is that it doesn't have to
contain a permanent file.  You can use buffers for  different  purposes  while
you're in EMACS without having to worry about a file.

Try {CTRL-X}B  now.   Remember,  that  since  it  switches  you to a different
buffer, these instructions will disappear from your screen.  When you're ready
to come back to this buffer to continue with the tutorial, you'll have to press
{CTRL-X}B again, followed by the buffer name "TEACH-EMACS-SUI-3" and {RETURN},
to get back.  (As a time-saving hint, {CTRL-X}B{RETURN} will return you to the
LAST buffer you were working with.)


>> Go ahead and type {CTRL-X}B.  When you're prompted for a buffer name, type
   in the  name  NEW  and confirm with {RETURN}.  Once you get to your new
   buffer, insert some text and play around with it for awhile.  When you're
   ready to  come  back  to  this tutorial, type:

     {CTRL-X}B{RETURN}

Notice that EMACS remembered your place when you came  back  to  this  buffer.
This is very useful when you start switching around to many different buffers.


Getting a List of Buffers
-------------------------

When you don't remember the names of all the buffers you've been working with,
you can  use  the  {CTRL-X}{CTRL-B}  command.  It lists all the buffers you've
used so far, the files they contain, whether or not they contain unsaved text,
and how many lines long they are.  Try this command now.


>> Press {CTRL-X}{CTRL-B} and watch a list of buffers appear at the top of your
   screen.  (It will disappear with your next command.)


If TEACH-EMACS-SUI-3 is the only file you've been working with since
you invoked EMACS, it will be the only one listed. If you've worked with any
others, they will be listed as well.

FILES
_____

When you  work  with a file in EMACS, you are not really working with the file
itself.  Instead, you are working with a copy of the file EMACS has placed  in
a buffer.   As was mentioned in TEACH-EMACS-SUI-1, you must save your text in a
file if you want to keep it permanently.  If you don't save your changes,  the
original version  of  the file remains unchanged.  Once you save your changes,
they become the new version of the file.


Saving Text in Files
--------------------

You already know about {SAVE FILE} which automatically saves the text  in
your buffer  in  the current file.  There is one other command you should know
as well.

{WRITE FILE} saves the text in your buffer in a file you specify.

Try using {WRITE FILE} now.  The buffer "new"  that  you  created  earlier
should have  some  text  in  it that hasn't yet been saved in a file.  You can
switch to that buffer to try {WRITE FILE}:


>> Go ahead and type {CTRL-X}B new {RETURN}.  Remember that you'll have to type
   it again (without needing to specify "new") to get back to this buffer.
   When you get to your NEW buffer, press {WRITE FILE} and use any filename
   you like to save your text.  We'll assume you chose the name "NEW" for this
   file.


Inserting Files
---------------

At times you may need to include a copy of an existing file into your buffer.
When you press {INSERT FILE} EMACS will prompt you for the filename.  The
entire contents of the selected file are inserted into your buffer at point.
This action does not change the buffer name in the mode line or the pathname of
the file you're editing.


>> Since you have just written a file called NEW, position yourself somewhere
   in your TEACH-EMACS-SUI-3 buffer and enter {INSERT FILE} NEW {RETURN}.
   Notice that your new file is simply inserted into the buffer at point.


Creating Files
---------------

You  can  put a copy of a file in a buffer, or create a new file, by using
the {FIND FILE} command that you learned in TEACH-EMACS-SUI-1.  This  command
automatically gives the buffer the same name as the file.

If you  already have an empty buffer and you want to put a file in it, you can
use {CTRL-X}{CTRL-R}.


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

These commands are related to working with files and buffers:


     {FIND FILE}       Finds or creates file you specify and puts it in a
                       buffer with the same name.

     {CTRL-X}B         Finds or  creates  buffer  you  specify.   Buffer   may
                       contain file with a different name.

     {CTRL-X}{CTRL-R}  Reads file you specify into current buffer

     {CTRL-X}{CTRL-B}  Lists all buffers used during current editing session

     {WRITE FILE}      Saves text in file you specify.

     {INSERT FILE}     Insert a copy of file at point in current buffer.

     {SAVE FILE}       Saves text in current file.

     {QUIT EMACS}      Exits EMACS and  takes  you  back  to  PRIMOS  command
                       level (or {EXIT} on the PT45 template).


MULTIPLE WINDOWS
----------------

In EMACS,  it is possible to see the contents of two different buffers on your
screen at one time by using two windows.   To  divide  your  screen  into  two
windows, all you have to do is press {2 FILE ON/OFF} (or TWO FILE MODE ON/OFF}
on a PT45 template) which divides your screen in half horizontally by  placing
a dotted line across the middle of your screen.  The top window displays the
contents of your current buffer. The  bottom  window displays a new, empty
buffer called "alternate".

After you  press  {2 FILE ON/OFF},  the cursor moves to the bottom window,
making the buffer in that window the current buffer.  Any EMACS commands  you
then  press will take effect in that window only.

If you  decide  you  want  to edit the text in the top window, you can use the
{OTHER FILE} command to move the cursor to the "other" window.  When you  want
to work with the text in the bottom window again, {OTHER FILE} will again move
you to the other window.

You can use any EMACS commands you like when you  use  two  windows  with  the
restriction that  you  can only work with one buffer at a time.  Try using two
windows now:


>> Press {2 FILE ON/OFF} and watch this file move to the  top  of  the
   screen  only.  Then press {OTHER FILE} to make the top window the current
   window.  If these instructions disappear, use {NEXT SCREEN} until they
   appear.


Notice that before you pressd {OTHER FILE}, the mode line read  "alternate"  to
describe the buffer in window two.  As soon as you moved to the top window, it
changed to reflect the new current buffer.



>> Now move the cursor to window 2 again using {OTHER FILE}.  Then type
   {CTRL-X}B followed by "new" {RETURN} to move the buffer called "new" into
   window  2, making it the current buffer.  Don't forget to use {OTHER FILE}
   to move to the top window when you need to read these instructions.


Notice that  the  mode  line has changed again.  It now reads "new" to reflect
the current buffer.


>> Play around with the text  in  the  two  windows  for  awhile.   Try  using
   different EMACS  commands.   Press {WRITE FILE} to save the text in the
   buffer "new" under any name you choose.  Then put a different  buffer  into
   the bottom window using {FIND FILE} or {CTRL-X}B.


>> When you're ready to get back to one window again, move the cursor  to  the
   top window.  Then press the {2 FILE ON/OFF} key.  Notice that the
   {2 FILE ON/OFF} key switches between one and two windows.

This file will take up the entire screen again.  If you had left the cursor in
the bottom  window,  the  buffer  in  that  window  would now be on the screen
instead.


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

These are the commands for working with multiple windows:

                                                              PT45 template
      {2 FILE ON/OFF}    Divides screen into two horizontal    {ON/OFF}
                         windows or make one window again
                         depending on if you had one or two
                         windows before pressing the key.

      {OTHER FILE}       Moves point to other window.


OVERLAY MODE
------------

By now you've worked with EMACS  long  enough  to  notice  how  EMACS  inserts
characters into  a buffer.  As EMACS inserts each new character, it shifts the
text following it on the line over one space.  Sometimes you  won't  want  the
insertion process  to  work this way.  To change it, you can use overlay mode.
Overlay mode permits you to enter new characters onto  a  line  without  moving
other text.

Like other  modes in EMACS, overlay mode works in the current buffer only.  If
you switch to a new buffer, the usual method of inserting text will  still  be
in effect.   However, if you leave the current buffer in overlay mode, work in
a new one, and then go back to the first buffer, EMACS will remember that  you
had overlay mode in effect for that buffer.

Try overlay mode now:


>> Press {INSERT/OVERLAY} to switch to overlay mode.


Watch the notation "overlay" appear in the mode line to remind you that you've
put overlay mode in effect.


>> Then move to a different line of text in this file and press in some text at
   the beginning.  Notice how the new text overwrites  the  old  text  on  the
   line.


>> Now press {INSERT/OVERLAY} to turn off overlay mode.  Again, this is one
   of those "toggle" keys.


The "overlay" notation will disappear from the mode  line  and  any  text  you
insert will be done in the usual manner.


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

Use the following command for overlay mode:

     {INSERT/OVERLAY}      Puts overlay mode or insert mode in effect in the
                           current buffer depending on which mode was in effect
                           before pressing the key.


CONCLUSION
----------

This concludes TEACH-EMACS-SUI-3.


>> If you want to  continue  on  to  TEACH-EMACS-SUI-4  (or  another  file),
   press {FIND FILE} followed  by TEACH-EMACS-SUI-4 (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-3
