home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / forthmac / !Forthmacs / docs / memacs / emacs_doc < prev    next >
Encoding:
Text File  |  1996-12-28  |  149.7 KB  |  4,994 lines

  1.  
  2.  
  3.                      Archimedes EMACS
  4.  
  5.                      Full Screen Text Editor
  6.  
  7.                      Version 1.00
  8.                      July 1988
  9.  
  10.              (C)opyright 1988 D. J. Pilling
  11.  
  12.              Archimedes EMACS is derived from
  13.              Micro EMACS 3.9e which is
  14.  
  15.                      (C)opyright 1987 by Daniel M. Lawrence
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.      Introduction
  49.  
  50.              ARC EMACS is a tool for creating and changing documents,
  51.      programs, and other text  files.   It is both relatively easy for
  52.      the novice to  use,  but  also  very  powerful in the hands of an
  53.      expert. ARC EMACS can be extensively customized for the needs of
  54.      the individual user.
  55.  
  56.              ARC EMACS allows  several files to be edited at the same
  57.      time.  The  screen  can be split into different windows, and text
  58.      may  be  moved  freely from one window to the next.  Depending on
  59.      the  type  of  file  being  edited, ARC EMACS can change how  it
  60.      behaves to make editing simple.    Editing  standard  text files,
  61.      program files and  word  processing documents are all possible at
  62.      the same time.
  63.  
  64.              There are extensive  capabilities to make word processing
  65.      and editing  easier.  These include commands for string searching
  66.      and replacing,  paragraph  reformatting  and  deleting, automatic
  67.      word wrapping,  word move and deletes, easy case controlling, and
  68.      automatic word counts.
  69.  
  70.              For complex and  repetitive editing tasks editing macroes
  71.      can be written.  These macroes  allow  the user a great degree of
  72.      flexibility in determining how ARC EMACS behaves.  Also, any and
  73.      all the commands  can  be  used  by any keystroke by changing, or
  74.      rebinding, what commands various keys  are  connected,  or bound,
  75.      to.
  76.  
  77.              Special features are also available to perform  a diverse
  78.      set of  operations such as file encryption, automatic backup file
  79.      generation, entabbing  and  detabbing  lines,  executing  of  MOS
  80.      commands and  filtering of text through other programs.
  81.      
  82.  
  83.      History
  84.  
  85.              EMACS was originally a  text  editor  written  by Richard
  86.      Stahlman  at  MIT  in  the  early  1970s  for  Digital  Equipment
  87.      computers. Various versions, rewrites  and  clones  have  made an
  88.      appearence since.
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.      Basic Concepts                        ARC EMACS Reference Manual
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.                                  Chapter 1
  160.  
  161.                               Basic Concepts
  162.  
  163.  
  164.  
  165.  
  166.  
  167.      1.1  Keys and the Keyboard
  168.  
  169.  
  170.              Many times throughout  this  manual  we  will  be talking
  171.      about commands and the  keys  on the keyboard needed to use them.
  172.      There  are  a  number of "special" keys which can be used and are
  173.      listed here:
  174.  
  175.      <NL>           NewLine which is also called RETURN or ENTER, this
  176.                     key is used to end different commands.
  177.  
  178.      ^              The control key can be used before  any alphabetic
  179.                     character and some symbols.  For example, ^C means
  180.                     to hold down the <CONTROL>  key and type the C key
  181.                     at the same time.
  182.  
  183.      ^X             The CONTROL-X key is used at the beginning of many
  184.                     different commands.
  185.  
  186.      META or M-     This is a special EMACS  key  used  to  begin many
  187.                     commands as well.   This  key  is pressed and then
  188.                     released  before  typing  the  next character.  On
  189.                     the  ARC, this  is  the <ESC>  key,  but it can be
  190.                     changed.
  191.     
  192.  
  193.              Whenever a command is described, the manual will list the
  194.      actual  keystrokes needed to execute it  in  boldface  using  the
  195.      above conventions, and also the name of the command in italics.
  196.  
  197.  
  198.      1.2  Getting Started
  199.  
  200.  
  201.              In  order to use EMACS, you must call  it  up  from  your
  202.      system or computer's command prompt.  On the Archimedes,
  203.  
  204.  
  205.      1
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.      ARC EMACS Reference Manual                        Basic Concepts
  213.  
  214.  
  215.      type "emacs" from the MOS * command prompt and follow it with
  216.      the  <RETURN>  or  <ENTER> key (we will refer to this key as <NL>
  217.      for  "new-line"  for  the remainder of  this  manual).
  218.      Shortly  after  this, a screen similar to the one below should appear.
  219.  
  220.  
  221.      1.3  Parts and Pieces
  222.  
  223.  
  224.              The screen is divided into  a number of areas or windows.
  225.      The  top  window  contains  a  function  list of unshifted and shifted 
  226.      function keys.   We will discuss these keys later.  Below  them  is an
  227.      EMACS mode line which, as we will see, informs you of the present mode of
  228.      operation  of  the editor--for example "(WRAP)" if  you  set  EMACS  to
  229.      wrap at the end of each line. Under the mode  line  is the text window 
  230.      where text appears and is manipulated.    Since  each  window has its
  231.      own mode line, below the text window is it's  mode  line.   The last 
  232.      line of the screen is the command line where EMACS takes commands and 
  233.      reports on what it is doing.
  234.  
  235.      ===========================================================================
  236.      f1 search-> f2 <-search |    ARC EMACS:  Text Editor
  237.      f3 hunt->   f4 <-hunt   |
  238.      f5 fkeys    f6 help     |  Available function key Pages include:
  239.      f7 nxt wind f8 pg[    ] |    WORD  PROG  BOX
  240.      f9 save     f10 exit    |  [use the f8 key to load Pages]
  241.      ===========================================================================
  242.      -- ARC EMACS 1.00 () -- Function Keys
  243.      ---------------------------------------
  244.      ===========================================================================
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.      ===========================================================================
  258.      -- ARC EMACS 1.00 () -- Main
  259.      ------------------------------------------------
  260.      ===========================================================================
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                                                                      2
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.      Basic Concepts                        ARC EMACS Reference Manual
  276.  
  277.  
  278.  
  279.  
  280.  
  281.      1.4  Entering Text
  282.  
  283.  
  284.              Entering text in EMACS is  simple.    Type  the following
  285.      sentence fragment:
  286.  
  287.           Fang Rock lighthouse, center of a series  of mysterious
  288.           and
  289.  
  290.      The text is displayed at the top of the text window.  Now type:
  291.  
  292.           terrifying events at the turn of the century
  293.  
  294.              Notice the text to the  left of the cursor disappears and
  295.      a '$' sign appears.    Don't  panic--your  text is safe!!! You've
  296.      just discovered that EMACS doesn't "wrap" text to  the  next line
  297.      like most word processors  unless  you hit <NL>.  But since EMACS
  298.      is used for both word processing, and text editing, it has  a bit
  299.      of a dual personality.   You  can  change  the  way  it  works by
  300.      setting various modes.  In this case, you need to set  WRAP mode,
  301.      using the add-mode command, by typing ^X-M.  The command  line at
  302.      the base of the screen will prompt you for the  mode  you wish to
  303.      add.   Type  wrap  followed  by the <NL> key and any text you now
  304.      enter  will  be  wrapped.  However, the command doesn't wrap text
  305.      already entered.   To  get  rid  of  the  truncated  line, delete
  306.      characters with the <BACKSPACE> key until the '$' goes away.  Now
  307.      type in the words you deleted,  watch  how EMACS goes down to the
  308.      next line at the right time.  
  309.  
  310.  
  311.  
  312.              Now let's type  a  longer  insert.   Hit <NL> a couple of
  313.      times to tab down from the text you just entered.    Now type the
  314.      following paragraphs.   Press  <NL> twice to indicate a paragraph
  315.      break.
  316.  
  317.           Fang Rock lighthouse, center of a series  of mysterious
  318.           and terrifying events at  the  turn  of the century, is
  319.           built  on a rocky island a few  miles  of  the  Channel
  320.           coast.  So small is  the island that wherever you stand
  321.           its rocks are wet with sea spray.
  322.  
  323.           The lighthouse tower is in the center of the island.  A
  324.           steep  flight  of  steps leads to the heavy door in its
  325.           base.  Winding stairs lead up to the crew room.
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      3
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.      ARC EMACS Reference Manual                        Basic Concepts
  342.  
  343.  
  344.      1.5  Basic cursor movement
  345.  
  346.  
  347.              Now let's practice moving around in this text.    To move
  348.      the cursor back  to  the word "Winding," enter M-B previous-word.
  349.      This command moves the cursor backwards by one word  at  a  time.
  350.      Note you have to press the key combination every time  the cursor
  351.      steps back by one word.   Continuously pressing META and toggling
  352.      B  produces  an  error  message.    To  move  forward to the word
  353.      "stairs" enter M-F, which moves the cursor forward by one word at
  354.      a time.
  355.  
  356.              Notice that EMACS commands  are  usually  mnemonic--F for
  357.      forward, B for backward, for example.
  358.  
  359.              To move the  cursor  up one line, enter ^P previous-line,
  360.      down one line ^N next-line.  Practice this movement by moving the
  361.      cursor to the word "terrifying" in the second line.
  362.  
  363.              The  cursor  may  also be moved forward  or  backward  in
  364.      smaller increments.  To move forward by one  character,  enter ^F
  365.      forward-character,  to  move  backward,  ^B   backward-character.
  366.      EMACS also allows you to specify a number which is  normally used
  367.      to  tell  a  command to execute  many  times.    To  repeat  most
  368.      commands, press META and  then  the  number  before you enter the
  369.      command.   Thus,  the  command  META  5  ^F (M-5^F) will move the
  370.      cursor forward by five characters.  Try moving around in the text
  371.      by using these commands.    For extra practice, see how close you
  372.      can come to the word "small" in the first paragraph by  giving an
  373.      argument to the commands listed here.
  374.  
  375.              Two other  simple cursor commands that are useful to help
  376.      us move around in the text are M-N next-paragraph which moves the
  377.      cursor to the second paragraph, and M-P  previous-paragraph which
  378.      moves it back to the previous paragraph.  The cursor may  also be
  379.      moved rapidly from one end of  the  line  to the other.  Move the
  380.      cursor to the word "few" in the second line.  Press ^A beginning-
  381.      of-line.  Notice  the  cursor  moves  to the word "events" at the
  382.      beginning of the line.   Pressing ^E end-of-line moves the cursor
  383.      to the end of the line.
  384.  
  385.              Finally,  the  cursor  may be moved from any point in the
  386.      file to the end or beginning  of  the file.  Entering M-> end-of-
  387.      file moves the cursor to the end of the buffer, M-< beginning-of-
  388.      file to the first character of the file.
  389.  
  390.              The cursor  keys can also be used to move the cursor about.
  391.  
  392.              Practice  moving the cursor in the  text  until  you  are
  393.      comfortable with the commands we've explored in this chapter.
  394.  
  395.  
  396.  
  397.  
  398.                                                                      4
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.      Basic Concepts                        ARC EMACS Reference Manual
  406.  
  407.  
  408.      1.6  Saving your text
  409.  
  410.  
  411.              When you've  finished  practicing  cursor  movement, save
  412.      your file.  Your file currently resides in a BUFFER.   The buffer
  413.      is a temporary storage area for  your  text, and is lost when the
  414.      computer is  turned  off.    You can save the buffer to a file by
  415.      entering ^X-^S save-file.  Notice  that  EMACS  informs  you that
  416.      your file has no name and will not let you save it.
  417.  
  418.              To save your buffer to a file with a different  name than
  419.      it's current one (which is  empty), press ^X^W write-file.  EMACS
  420.      will  prompt  you  for the filename you wish to write.  Enter the
  421.      name fang_txt and press return.  On a micro, the drive light will
  422.      come  on, and EMACS will inform you it is writing the file.  When
  423.      it finishes, it will inform you of the  number  of  lines  it has
  424.      written to the disk.
  425.  
  426.              Congratulations!!  You've just  saved  your  first  EMACS
  427.      file!
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.      5
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.      ARC EMACS Reference Manual                        Basic Concepts
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.                              Chapter 1 Summary
  479.  
  480.  
  481.              In chapter 1, you  learned  how to enter text, how to use
  482.      wrap mode,  how  to  move  the cursor, and to save a buffer.  The
  483.      following is a table of the commands covered in this  chapter and
  484.      their corresponding key bindings:
  485.  
  486.      Key Binding             Keystroke       Effect
  487.  
  488.      abort-command           ^G              aborts current command
  489.  
  490.      add-mode                ^XM             allows addition of EMACS
  491.                                              mode such as WRAP
  492.  
  493.      backward-character      ^B              moves cursor left one character
  494.  
  495.      beginning-of-file       M-<             moves cursor to beginning of file
  496.  
  497.      beginning-of-line       ^A              moves cursor to beginning of line
  498.  
  499.      end-of-file             M->             moves cursor to end of file
  500.  
  501.      end-of-line             ^E              moves cursor to end of line
  502.  
  503.      forward-character       ^F              moves cursor right one character
  504.  
  505.      next-line               ^N              moves cursor to next line
  506.  
  507.      next-paragraph          M-N             moves cursor to next paragraph
  508.  
  509.      next-word               M-F             moves cursor forward one word
  510.  
  511.      previous-line           ^P              moves cursor backward by one line
  512.  
  513.      previous-paragraph      M-P             moves cursor to previous paragraph
  514.  
  515.      previous-word           M-B             moves cursor backward by one word
  516.  
  517.      save-file               ^X-^S           saves current buffer to a file
  518.  
  519.      write-file              ^X-^W           save current buffer under a new
  520.                                              name
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.                                                                      6
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.      Basic Editing--Simple Insertions and Deletions         ARC EMACS
  538.                                                       Reference Manual
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.                                  Chapter 2
  548.  
  549.               Basic Editing--Simple Insertions and Deletions
  550.  
  551.  
  552.      2.1  A Word About Windows, Buffers, Screens, and Modes
  553.  
  554.  
  555.              In the first chapter, you  learned how to create and save
  556.      a file in EMACS. Let's do some more editing on  this  file.  Call
  557.      up emacs by typing in the following command.
  558.  
  559.              emacs fang_txt
  560.  
  561.  
  562.              Shortly after you invoke EMACS, the text should appear on
  563.      the screen ready for you to  edit.    The text you are looking at
  564.      currently resides in a buffer.   A  buffer is a temporary area of
  565.      computer  memory  which  is the primary unit internal to EMACS --
  566.      this is the place where EMACS goes to work.  The mode line at the
  567.      bottom of the screen lists the buffer name, FANG_TXT and the name
  568.      of the file with which this buffer is associated, FANG_TXT
  569.  
  570.              The computer talks to you  through the use of its screen.
  571.      This screen usually has an area of 24 lines each of 80 characters
  572.      across.  You can  use  EMACS to subdivide the screen into several
  573.      separate  work  areas,  or windows, each of which can be 'looking
  574.      into'  different  files  or sections of text.  Using windows, you
  575.      can work on several related texts at one time, copying and moving
  576.      blocks of text between windows with ease.  To keep track  of what
  577.      you are editing, each window is identified by a mode line  on the
  578.      last line of the window which lists the name of the  buffer which
  579.      it  is  looking  into, the file from which the text was read, and
  580.      how the text is being edited.
  581.  
  582.              An  EMACS  mode  tells EMACS how to deal with user input.
  583.      As we have already seen, the mode 'WRAP' controls how EMACS deals
  584.      with long lines (lines with over 79 characters) while the user is
  585.      typing  them  in.   The 'VIEW' mode, allows you to  read  a  file
  586.      without modifying it.  Modes  are associated with buffers and not
  587.      with files; hence, a  mode  needs to be explicitly set or removed
  588.      every time you edit a file.  A new file read into a buffer with a
  589.      previously specified mode will be edited under this mode.  If you
  590.  
  591.  
  592.  
  593.      7
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.      ARC EMACS Reference Manual  Basic Editing--Simple Insertions and
  601.                                                              Deletions
  602.  
  603.  
  604.      use specific modes frequently, EMACS  allows you to set the modes
  605.      which are used by all new buffers, called global modes.
  606.  
  607.  
  608.      2.2  Insertions
  609.  
  610.  
  611.              Your previously-saved text should look like this:
  612.  
  613.           Fang Rock lighthouse, center of a series  of mysterious
  614.           and terrifying events at  the  turn  of the century, is
  615.           built  on a rocky island a few  miles  of  the  Channel
  616.           coast.  So small is  the island that wherever you stand
  617.           its rocks are wet with sea spray.
  618.  
  619.           The lighthouse tower is in the center of the island.  A
  620.           steep  flight  of  steps leads to the heavy door in its
  621.           base.  Winding stairs lead up to the crew room.
  622.  
  623.              Let's assume you want  to  add  a  sentence in the second
  624.      paragraph after the word "base."  Move the cursor until it  is on
  625.      the "W" of "Winding". Now type the following:
  626.  
  627.           This gives entry to the lower floor where the big steam
  628.           generator throbs steadily away, providing power for the
  629.           electric lantern.
  630.  
  631.              If  the line fails to wrap and you end up with a '$' sign
  632.      in the right margin,  just  enter  M-Q fill-paragraph to reformat
  633.      the  paragraph.    This  new  command  attempts  to  fill  out  a
  634.      paragraph.  Long lines  are  divided  up,  and words are shuffled
  635.      around to make the paragraph look nicer.
  636.  
  637.              Notice  that  all  visible  EMACS  characters  are  self-
  638.      inserting -- all you had to do was type the characters  to insert
  639.      and the existing text made space  for  it.  With a few exceptions
  640.      discussed later, all non-printing characters (such as  control or
  641.      escape sequences) are commands.  To insert spaces, simply use the
  642.      space bar.  Now move to the first line of the  file  and  type ^O
  643.      open-line (Oh, not zero).  You've just learned how  to  insert  a
  644.      blank line in your text.
  645.  
  646.  
  647.      2.3  Deletions
  648.  
  649.  
  650.              EMACS offers  a number of deletion options.  For example,
  651.      move the cursor until it's under the period  at  the  end  of the
  652.      insertion you just did.  Press the backspace key.  Notice the "n"
  653.      on "lantern"  disappeared.  The backspace implemented on EMACS is
  654.  
  655.      called  a  destructive  backspace--it  removes  text  immediately
  656.      before the current cursor position from the buffer.  Now  type ^H
  657.  
  658.  
  659.  
  660.                                                                      8
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.      Basic Editing--Simple Insertions and Deletions         ARC EMACS
  668.                                                       Reference Manual
  669.  
  670.  
  671.      delete-previous-character.  Notice that the cursor moves back and
  672.      obliterates the "r"--either command will backspace the cursor.
  673.  
  674.              Type in the two letters you erased to  restore  your text
  675.      and move the cursor to the beginning of the buffer M-> beginning-
  676.      of-file.  Move the cursor down  one  line to the beginning of the
  677.      first paragraph.
  678.  
  679.              To  delete  the  forward  character, type ^D delete-next-
  680.      character.  The "F" of "Fang" disappears.  Continue  to  type  ^D
  681.      until the whole word is erased EMACS also permits the deletion of
  682.      larger elements of text.  Move the cursor to the word "center" in
  683.      the first line of text.  Pressing  M-<backspace> delete-previous-
  684.      word kills the word immediately before the cursor.  M-^H  has the
  685.      same effect.
  686.  
  687.              Notice that  the commands are very similar to the control
  688.      commands you used to  delete  individual  letters.   As a general
  689.      rule in EMACS, control sequences affect small areas of text, META
  690.      sequences larger areas.  The  word forward of the cursor position
  691.      can therefore be deleted by  typing  M-D  delete-next-word.   Now
  692.      let's take out the remainder of the first line by typing ^K kill-
  693.      to-end-of-line.  You now have a blank line  at  the  top  of your
  694.      screen.   Typing ^K again or ^X-^O delete-blank-lines deletes the
  695.      blank  line  and  flushes the second line to the top of the text.
  696.      Now exit EMACS by typing ^X-^C exit-emacs .  Notice EMACS reminds
  697.      you that you have not saved your buffer.  Ignore the  warning and
  698.      exit.  This  way  you  can  exit  EMACS without saving any of the
  699.      changes you just made.
  700.  
  701.  
  702.  
  703.  
  704.                              Chapter 2 Summary
  705.  
  706.  
  707.              In Chapter  2,  you  learned  about  the  basic 'building
  708.      blocks' of an EMACS text file--buffers, windows, and files.
  709.  
  710.      Key binding             Keystroke       Effect
  711.      delete-previous-character
  712.                              ^H              deletes character immediately
  713.                                              before
  714.                                              the current cursor position
  715.  
  716.      delete-next-character   ^D              deletes character immediately after
  717.                                              current cursor position
  718.  
  719.      delete-previous-word    M-^H            deletes word immediately before
  720.                                              current cursor position
  721.  
  722.      delete-next-word        M-D             deletes word immediately after
  723.                                              current cursor position
  724.  
  725.  
  726.      9
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.      ARC EMACS Reference Manual  Basic Editing--Simple Insertions and
  734.                                                              Deletions
  735.  
  736.  
  737.      kill-to-end-of-line     ^K              deletes from current cursor
  738.                                              position to end of line
  739.  
  740.      insert-space            ^C              inserts a space to right of cursor
  741.  
  742.      open-line               ^O              inserts blank line
  743.  
  744.      delete-blank-lines      ^X-^O           removes blank line
  745.  
  746.      exit-emacs              ^X-^C           exits emacs
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.                                                                     10
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.      Using Regions                         ARC EMACS Reference Manual
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.                                  Chapter 3
  809.  
  810.                                Using Regions
  811.  
  812.  
  813.      3.1  Defining and Deleting a Region
  814.  
  815.  
  816.              At this  point its time to familiarize ourselves with two
  817.      more EMACS terms--the point  and  the mark.  The point is located
  818.      directly behind the current  cursor  position.    The mark (as we
  819.      shall see shortly) is user  defined.  These two elements together
  820.      are called the  current  region  and  limit the region of text on
  821.      which EMACS performs many of its editing functions.
  822.  
  823.              Let's begin by entering some new text.   Don't  forget to
  824.      add wrap  mode  if  its  not set on this buffer.  Start EMACS and
  825.      open a file called PUBLISHTXT.  Type in the following text:
  826.  
  827.           One of the largest growth areas  in  personal computing
  828.           is electronic publishing.  There are packages available
  829.           for practically  every  machine  from  elegantly simple
  830.           programs  for the humble Commodore 64 to  sophisticated
  831.           professional packages for PC and Macintosh computers.
  832.  
  833.           Electronic publishing is as revolutionary in its way as
  834.           the  Gutenburg  press.    Whereas  the  printing  press
  835.           allowed  the  mass  production  and distribution of the
  836.           written  word, electronic publishing puts the means  of
  837.           production  in  the  hands  of nearly every individual.
  838.           From  the  class  magazine  to  the  corporate  report,
  839.           electronic publishing is changing  the  way  we produce
  840.           and disseminate information.
  841.  
  842.           Personal  publishing  greatly  increases the utility of
  843.           practically every computer.   Thousands  of  people who
  844.           joined the computer revolution of this  decade  only to
  845.           hide their machines unused in closets have discovered a
  846.           new use for them as dedicated publishing workstations.
  847.  
  848.              Now  let's  do  some editing.  The last paragraph seems a
  849.      little out of place.  To see what the document looks like without
  850.      it we can  cut  it  from  the  text  by  moving the cursor to the
  851.      beginning of the paragraph.   Enter  M-<space>  set-mark.   EMACS
  852.      will respond with "[Mark set]".   Now  move the cursor to the end
  853.      of the paragraph.  You have  just  defined  a region of text.  To
  854.      remove  this  text  from  the  screen, type ^W kill-region.   The
  855.      paragraph disappears from the screen.
  856.  
  857.  
  858.      11
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.      ARC EMACS Reference Manual                         Using Regions
  866.  
  867.  
  868.              On further consideration, however, perhaps  the paragraph
  869.      we cut wasn't so bad after all.  The problem may have been one of
  870.      placement.  If  we  could  tack  it  on  to  the end of the first
  871.      paragraph it might work quite  well to support and strengthen the
  872.      argument.  Move the cursor to the end of the first  paragraph and
  873.      enter ^Y yank.  Your text should now look like this:
  874.  
  875.           One of the largest growth areas  in  personal computing
  876.           is electronic publishing.  There are packages available
  877.           for practically  every  machine  from  elegantly simple
  878.           programs  for the humble Commodore 64 to  sophisticated
  879.           professional  packages for PC and Macintosh  computers.
  880.           Personal  publishing  greatly  increases the utility of
  881.           practically every computer.   Thousands  of  people who
  882.           joined the computer revolution of this  decade  only to
  883.           hide their machines unused in closets have discovered a
  884.           new use for them as dedicated publishing workstations.
  885.  
  886.           Electronic publishing is as revolutionary in its way as
  887.           the  Gutenburg  press.    Whereas  the  printing  press
  888.           allowed  the  mass  production  and distribution of the
  889.           written  word, electronic publishing puts the means  of
  890.           production  in  the  hands  of nearly every individual.
  891.           From  the  class  magazine  to  the  corporate  report,
  892.           electronic publishing is changing  the  way  we produce
  893.           and disseminate information.
  894.  
  895.  
  896.      3.2  Yanking a Region
  897.  
  898.  
  899.              The text you cut initially didn't simply  just disappear,
  900.      it  was  cut  into  a  buffer  that  retains  the  'killed'  text
  901.      appropriately called the kill buffer.  ^Y "yanks"  the  text back
  902.      from this buffer into the current buffer. If you have a long line
  903.      (indicated,  remember,  by  the  "$"  sign),  simply  hit M-Q  to
  904.      reformat the paragraph.
  905.  
  906.              There are other uses to which the kill buffer can be put.
  907.      Using the method we've already learned, define the last paragraph
  908.      as  a  region.   Now type M-W copy-region.  Nothing seems to have
  909.      happened; the cursor stays  blinking  at  the  point.  But things
  910.      have  changed,  even  though you may  not  be  able  to  see  any
  911.      alteration.
  912.  
  913.              To  see what has happened to the  contents  of  the  kill
  914.      buffer, move the  cursor  down  a  couple of lines and "yank" the
  915.      contents  of  the kill buffer back with  ^Y.    Notice  the  last
  916.      paragraph is now repeated.  The region you defined is "tacked on"
  917.      to the end of your file because M-W copies a  region  to the kill
  918.      buffer while leaving the  original  text  in your working buffer.
  919.      Some caution is needed however,  because the contents of the kill
  920.      buffer are updated when you delete any regions,  lines  or words.
  921.      If  you  are  moving  large  quantities  of  text,  complete  the
  922.  
  923.  
  924.                                                                     12
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.      Using Regions                         ARC EMACS Reference Manual
  932.  
  933.  
  934.      operation before you do any more deletions or you could find that
  935.      the  text  you  want to move has been replaced by the most recent
  936.      deletion.  Remember--a buffer is  a  temporary  area  of computer
  937.      memory that is lost when the machine is powered down  or switched
  938.      off.  In order to make your changes permanent, they must be saved
  939.      to  a  file  before you leave EMACS.  Let's delete the section of
  940.      text we just added and save the file to disk.
  941.  
  942.  
  943.  
  944.  
  945.                              Chapter 3 Summary
  946.  
  947.  
  948.              In  Chapter  3,  you  learned  how   to   achieve  longer
  949.      insertions  and  deletions.   The EMACS terms point and mark were
  950.      introduced and you learned how to manipulate text  with  the kill
  951.      buffer.
  952.  
  953.      Key Binding     Keystroke       Effect
  954.  
  955.      Delete-Region   ^W              Deletes region between point and mark and
  956.                                      places it in KILL buffer
  957.  
  958.      Copy-Region     M-W             Copies text between point and mark into
  959.                                      KILL buffer
  960.  
  961.      Yank-Text       ^Y              Inserts a copy of the KILL buffer into
  962.                                      current buffer at point
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.      13
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.      ARC EMACS Reference Manual                    Search and Replace
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.                                  Chapter 4
  1007.  
  1008.                             Search and Replace
  1009.  
  1010.  
  1011.      4.1  Forward Search
  1012.  
  1013.  
  1014.              Load EMACS and bring in the file you just  saved.    Your
  1015.      file should look like the one below.
  1016.  
  1017.           One of the largest growth areas  in  personal computing
  1018.           is electronic publishing.  There are packages available
  1019.           for practically  every  machine  from  elegantly simple
  1020.           programs  for the humble Commodore 64 to  sophisticated
  1021.           professional  packages for PC and Macintosh  computers.
  1022.           Personal  publishing  greatly  increases the utility of
  1023.           practically every computer.   Thousands  of  people who
  1024.           joined the computer revolution of this  decade  only to
  1025.           hide their machines unused in closets have discovered a
  1026.           new use for them as dedicated publishing workstations.
  1027.  
  1028.           Electronic publishing is as revolutionary in its way as
  1029.           the  Gutenburg  press.    Whereas  the  printing  press
  1030.           allowed  the  mass  production  and distribution of the
  1031.           written  word, electronic publishing puts the means  of
  1032.           production  in  the  hands  of nearly every individual.
  1033.           From  the  class  magazine  to  the  corporate  report,
  1034.           electronic publishing is changing  the  way  we produce
  1035.           and disseminate information.
  1036.  
  1037.              Let's use EMACS to search for the word "revolutionary" in
  1038.      the second paragraph.   Because  EMACS  searches from the current
  1039.      cursor  position  toward  the  end  of buffers, and we intend  to
  1040.      search forward, move the  cursor  to  the  beginning of the text.
  1041.      Enter ^S search-forward.  Note that the command line now reads
  1042.  
  1043.              "Search [] <META>:"
  1044.  
  1045.              EMACS is prompting you to  enter the search string -- the
  1046.      text you want to find.  Enter the word revolutionary and  hit the
  1047.      META  key.     The   cursor   moves   to  the  end  of  the  word
  1048.      "revolutionary."
  1049.  
  1050.              Notice  that  you  must enter the <META> key to start the
  1051.      search.  If you simply press <NL> the command line  responds with
  1052.      "<NL>".  Although this may seem infuriating to users who are used
  1053.      to pressing the return key to execute any command, EMACS'  use of
  1054.  
  1055.  
  1056.                                                                     14
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.      Search and Replace                    ARC EMACS Reference Manual
  1064.  
  1065.  
  1066.      <META>  to  begin  searches allows it to pinpoint text with great
  1067.      accuracy.  After every line wrap or carriage return, EMACS 'sees'
  1068.      a new line character (<NL>).  If you need to search for a word at
  1069.      the end of a line, you can specify this word uniquely in EMACS.
  1070.  
  1071.              In our sample text for example, the word  "and"  occurs a
  1072.      number  of times, but only once at the end of a line.  To  search
  1073.      for this particular occurence of the word, move the cursor to the
  1074.      beginning of the buffer and type ^S.  Notice  that  EMACS  stores
  1075.      the last specified search  string  as the default string.  If you
  1076.      press  <META>  now,  EMACS will search for the default string, in
  1077.      this case, "revolutionary."
  1078.  
  1079.              To change this string so  we can search for our specified
  1080.      "and" simply enter the word and followed by <NL>.    The  command
  1081.      line now shows:
  1082.  
  1083.              "search [and<NL>]<META>:"
  1084.  
  1085.              Press <META> and the cursor moves to "and" at the  end of
  1086.      the second last line.
  1087.  
  1088.  
  1089.      4.2  Exact Searches
  1090.  
  1091.  
  1092.              If the mode EXACT is  active in the current buffer, EMACS
  1093.      searches on a case sensitive basis.  Thus, for example  you could
  1094.      search for Publishing as distinct from publishing.
  1095.  
  1096.  
  1097.      4.3  Backward Search
  1098.  
  1099.  
  1100.              Backward  searching is very similar to forward  searching
  1101.      except  that  it  is  implemented  in the reverse direction.   To
  1102.      implement a reverse  search,  type  ^R  search-reverse.   Because
  1103.      EMACS makes no distinction between  forward  and  backward stored
  1104.      search strings, the last search item you entered  appears  as the
  1105.      default string.   Try  searching  back  for  any  word  that lies
  1106.      between the cursor and the beginning of the buffer.   Notice that
  1107.      when the item is found, the  point  moves to the beginning of the
  1108.      found string (i.e., the cursor  appears under the first letter of
  1109.      the search item).
  1110.  
  1111.              Practice searching for other words in your text.
  1112.  
  1113.  
  1114.      4.4  Searching and Replacing
  1115.  
  1116.  
  1117.              Searching and replacing is  a  powerful  and quick way of
  1118.      making changes to your text.  Our sample text is about electronic
  1119.      publishing, but the correct term  is  'desktop'  publishing.   To
  1120.  
  1121.  
  1122.      15
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.      ARC EMACS Reference Manual                    Search and Replace
  1130.  
  1131.  
  1132.      make the necessary changes we need to replace  all  occurences of
  1133.      the word "electronic"  with  "desktop." First, move the cursor to
  1134.      the top of the current buffer with the M-< command.  Then type M-
  1135.      R replace-string.  The command line responds:
  1136.  
  1137.              "Replace []<META>:"
  1138.  
  1139.              where  the  square  brackets  enclose the default string.
  1140.      Type the word  electronic  and  hit  <META>.    The  command line
  1141.      responds:
  1142.  
  1143.              "with []<META>"
  1144.  
  1145.              type desktop<META>.  EMACS replaces all instances  of the
  1146.      original word with your revision.  Of course, you  will  have  to
  1147.      capitalize the first letter of "desktop" where it  occurs  at the
  1148.      beginning of a sentence.
  1149.  
  1150.              You have just completed  an  unconditional  replace.   In
  1151.      this operation, EMACS replaces every instance of the found string
  1152.      with the replacement string.
  1153.  
  1154.  
  1155.      4.5  Query-Replace
  1156.  
  1157.  
  1158.              You may also replace text on  a  case by case basis.  The
  1159.      M-^R query-replace-string command causes EMACS to  pause  at each
  1160.      instance of the found string.
  1161.  
  1162.              For example,  assume we want to replace some instances of
  1163.      the  word  "desktop"  with  the  word "personal." Go back to  the
  1164.      beginning of  the current buffer and enter the M-^R query-replace
  1165.      command.    The  procedure is very  similar  to  that  which  you
  1166.      followed in the unconditional search/replace  option.    When the
  1167.      search begins however, you will  notice that EMACS pauses at each
  1168.      instance of "publishing" and asks  whether you wish to replace it
  1169.      with the replacement  string.    You  have  a  number  of options
  1170.      available for response:
  1171.  
  1172.              Response        Effect
  1173.              Y(es)   Make the current replacement and skip to the next
  1174.                      occurence of the search string
  1175.  
  1176.              N(o)    Do not make this replacement but continue
  1177.  
  1178.              !       Do the rest of the replacements with no more queries
  1179.  
  1180.              U(ndo)  Undo just the last replacement and query for it
  1181.                      again (This can only go back ONE time)
  1182.  
  1183.              ^G      Abort the replacement command (This action does not
  1184.                      undo previously-authorized replacements
  1185.  
  1186.  
  1187.  
  1188.                                                                     16
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.      Search and Replace                    ARC EMACS Reference Manual
  1196.  
  1197.  
  1198.              .       Same effect as ^G, but cursor returns to the point at
  1199.                      which the replacement command was given
  1200.  
  1201.              ?       This lists help for the query replacement command
  1202.  
  1203.              Practice searching and  searching and replacing until you
  1204.      feel comfortable with the commands and their effects.
  1205.  
  1206.  
  1207.  
  1208.  
  1209.                              Chapter 4 Summary
  1210.  
  1211.  
  1212.              In this  chapter, you learned how to search for specified
  1213.      strings of text in EMACS.  The chapter also dealt  with searching
  1214.      for and replacing elements within a buffer.
  1215.  
  1216.      Key Binding             Keystroke                        Effect
  1217.  
  1218.      Search-Forward          ^S      Searches from point to end of buffer.
  1219.                                      Point is moved from current location to
  1220.                                      the end of the found string
  1221.  
  1222.      Search-Backward         ^R      Searches from point to beginning of buffer.
  1223.                                      Point is moved from current location to
  1224.                                      beginning of found string
  1225.  
  1226.      Replace                 M-R Replace ALL ocurrences of search string with
  1227.                                      specified (null) string from point to the
  1228.                                      end of the current buffer
  1229.  
  1230.      Query-Replace          M-^R     As above, but pause at each found string
  1231.                                      and query for action
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.      17
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.      ARC EMACS Reference Manual                               Windows
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.                                  Chapter 5
  1270.  
  1271.                                   Windows
  1272.  
  1273.  
  1274.      5.1  Creating Windows
  1275.  
  1276.  
  1277.              We  have  already  met windows in an earlier chapter.  In
  1278.      this  chapter,  we  will  explore  one  of  EMACS' more  powerful
  1279.      features   --  text  manipulation  through  multiple   windowing.
  1280.      Windows  offer  you  a powerful and easy way to edit  text.    By
  1281.      manipulating  a  number  of  windows  and buffers on  the  screen
  1282.      simultaneously, you can perform complete edits  and  revisions on
  1283.      the computer screen while having your draft text or original data
  1284.      available for reference in another window.
  1285.  
  1286.              You will recall that windows  are  areas  of  buffer text
  1287.      that  you  can see on the screen.    Because  EMACS  can  support
  1288.      several screen windows simultaneously  you  can  use them to look
  1289.      into different places in the same buffer.  You can also  use them
  1290.      to  look  at  text in different buffers.  In effect, you can edit
  1291.      several files at the same time.
  1292.  
  1293.              Let's  invoke EMACS and pull back  our  file  on  desktop
  1294.      publishing by typing
  1295.  
  1296.           emacs publishtxt
  1297.  
  1298.              When  the  text   appears,  type  the  ^X-2  split-window
  1299.      command.  The window  splits  into two windows.  The window where
  1300.      the cursor resides is  called  the current window -- in this case
  1301.      the bottom window.  Notice that each window has a text area and a
  1302.      mode line.  The command line is however, common to all windows on
  1303.      the screen.
  1304.  
  1305.              The two  windows  on  your  screen  are  virtually mirror
  1306.      images of each other because the new window is  opened  into  the
  1307.      same buffer as the one you are in when you issue  the open-window
  1308.      command.  All  commands  issued  to  EMACS  are  executed  on the
  1309.      current buffer in the current window.
  1310.  
  1311.              To move the cursor  to  the  upper  window (i.e., to make
  1312.      that  window  the  current  window,  type  ^X-P  previous-window.
  1313.      Notice  the  cursor  moves  to  the  upper  or  previous  window.
  1314.      Entering ^X-O next-window moves to  the  next  window.   Practice
  1315.      moving between windows.   You  will notice that you can also move
  1316.      into the Function Key menu by entering these commands.
  1317.  
  1318.  
  1319.                                                                     18
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.      Windows                               ARC EMACS Reference Manual
  1327.  
  1328.  
  1329.              Now move to the upper window.  Let's open a new file.  On
  1330.      the  EMACS disk is a tutorial file.  Let's call it into the upper
  1331.      window by typing:
  1332.  
  1333.           ^X-^F
  1334.  
  1335.              and press return.
  1336.  
  1337.              Enter the filename emacs.tut.
  1338.  
  1339.              In a short time,  the  tutorial  file  will appear in the
  1340.      window.  We now have two windows on the screen, each looking into
  1341.      different buffers.  We have just used the ^X-^F find-file command
  1342.      to find a file and bring it into our current window.
  1343.  
  1344.              You can scroll any  window  up  and  down with the cursor
  1345.      keys, or with the commands we've learned so far. However, because
  1346.      the area of visible text in each window is relatively  small, you
  1347.      can scroll the current window a line at a time.
  1348.  
  1349.              Type ^X-^N move-window-down
  1350.  
  1351.              The  current  window  scrolls down by one line -- the top
  1352.      line of  text  scrolls  out  of  view,  and the bottom line moves
  1353.      towards the top of the screen.  You can imagine, if you like, the
  1354.      whole window  slowly  moving  down  to  the  end of the buffer in
  1355.      increments of one line.  The command ^X-^P move-window-up scrolls
  1356.      the window in the opposite direction.
  1357.  
  1358.              As we have  seen,  EMACS editing commands are executed in
  1359.      the current window, but the program does support a useful feature
  1360.      that allows you to scroll the next window.    M-^Z scroll-next-up
  1361.      scrolls the next  window  up,  M-^V  scroll-next-down  scrolls it
  1362.      downward.   From  the  tutorial  window,  practice  scrolling the
  1363.      window with the desktop publishing text in it up and down.
  1364.  
  1365.              When you're  finished,  exit  EMACS  without  saving  any
  1366.      changes in your files.
  1367.  
  1368.  
  1369.              Experiment  with  splitting  the  windows on your screen.
  1370.      Open windows into different buffers and experiment with any other
  1371.      files you may have.  Try editing the  text  in  each  window, but
  1372.      don't  forget  to  save any changes you want to keep -- you still
  1373.      have to save each buffer separately.
  1374.  
  1375.  
  1376.      5.2  Deleting Windows
  1377.  
  1378.  
  1379.      Windows allow you to perform  complex  editing  tasks  with ease.
  1380.      However,  they  become  an  inconvenience  when  your  screen  is
  1381.      cluttered  with  open  windows  you  have  finished  using.   The
  1382.      simplest solution is to delete  unneeded  windows.    The command
  1383.  
  1384.  
  1385.      19
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.      ARC EMACS Reference Manual                               Windows
  1393.  
  1394.  
  1395.      ^X-0 delete-window  will  delete  the  window  you  are currently
  1396.      working in and move you to the next window.
  1397.  
  1398.              If you have a number of windows open, you can  delete all
  1399.      but the current window by entering ^X-1 delete-other-windows.
  1400.  
  1401.  
  1402.      5.3  Resizing Windows
  1403.  
  1404.  
  1405.              During complex editing tasks, you will  probably  find it
  1406.      convenient  to  have  a  number   of   windows   on   the  screen
  1407.      simultaneously.       However   this   situation   may    present
  1408.      inconveniences because the more  windows  you  have on the screen
  1409.      the smaller they are; in some cases, a  window  may  show  only a
  1410.      couple of lines of text.  To increase the flexibility and utility
  1411.      of the window environment, EMACS  allows you to resize the window
  1412.      you  are  working  in  (called,  as you will recall, the  current
  1413.      window) to a convenient size  for easier editing, and then shrink
  1414.      it when you no longer need it to be so large.
  1415.  
  1416.              Let's try an example.  Load in any EMACS  text  file  and
  1417.      split the current window into two.  Now type ^X-^(Shift-6), grow-
  1418.      window.   Your  current  window  should  be  the lower one on the
  1419.      screen.  Notice that it increases in size upwards  by  one  line.
  1420.      If  you  are  in  the  upper  window,  it increases in size in  a
  1421.      downward   direction.      The   command   ^X-^Z,   shrink-window
  1422.      correspondingly decreases window size by one line at a time.
  1423.  
  1424.              EMACS also allows  you  to resize a window more precisely
  1425.      by entering a numeric argument  specifying the size of the window
  1426.      in  lines.  To resize the window this way, press the META key and
  1427.      enter  a  numeric  argument (remember to keep it smaller than the
  1428.      number of lines on your screen display) then  press  ^X-W resize-
  1429.      window.  The  current  window  will  be enlarged or shrunk to the
  1430.      number of lines specified in the numeric argument.    For example
  1431.      entering:
  1432.  
  1433.           M-8 ^X-W
  1434.  
  1435.      will resize the current window to 8 lines.
  1436.  
  1437.  
  1438.      5.4  Repositioning within a Window
  1439.  
  1440.  
  1441.              The cursor may be  centered  within  a window by entering
  1442.      M-! or M-^L redraw-display.  This command is especially useful in
  1443.      allowing  you  to  quickly  locate  the cursor if you are  moving
  1444.      frequently from window to window.  You can also use  this command
  1445.      to move the line containing the cursor to any position within the
  1446.      current window.  This is done by using a numeric  argument before
  1447.      the command. Type M-<n> M-^L where <n> is the number of  the line
  1448.      within the window that you wish the current line to be displayed.
  1449.  
  1450.  
  1451.                                                                     20
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.      ARC EMACS Reference Manual                               Windows
  1459.  
  1460.  
  1461.              The ^L Refresh-screen command is useful for 'cleaning up'
  1462.      a 'messy' screen that can result of using EMACS  on  a  mainframe
  1463.      system and being interupted by a system message.
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.                                                                     22
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.      Windows                               ARC EMACS Reference Manual
  1525.  
  1526.  
  1527.      Chapter 5 summary
  1528.  
  1529.              In Chapter 5 you  learned  how  to manipulate windows and
  1530.      the editing flexibility they offer.
  1531.  
  1532.      Key Binding     Keystroke       Effect
  1533.  
  1534.      Open-Window     ^X-2            Splits current window into two windows if
  1535.                                      space available
  1536.  
  1537.      Close-Windows   ^X-1            Closes all windows except current window
  1538.  
  1539.      Next-Window     ^X-O[oh]        Moves point into next (i.e. downward)
  1540.                                      window
  1541.  
  1542.      Previous-Window ^XP             Moves point to previous (i.e. upward)
  1543.                                      window
  1544.  
  1545.      Move-Window-Down ^X-^N          Scrolls current window down one line
  1546.  
  1547.      Move-Window-Up  ^X-^P           Scrolls current window up one line
  1548.  
  1549.      Redraw-display  M ! or          Window is moved so line with point
  1550.                      M ^L            (with cursor) is at center of window
  1551.  
  1552.      Grow-Window     M-X ^ or        Current window is enlarged by one
  1553.                      M ^L            line and nearest window is shrunk by
  1554.                                      one line
  1555.  
  1556.      Shrink-Window   ^X-^Z           Current window is shrunk by one line
  1557.                                      and nearest window is enlarged by one line
  1558.  
  1559.      Clear-and-redraw ^L             Screen is blanked and redrawn.  Keeps
  1560.                                      screen updates in sync with your commands
  1561.  
  1562.      Scroll-Next-Up  M-^Z            Scrolls next window up by one line
  1563.  
  1564.      Scroll-Next-Down M-^V           Scrolls next window down by one line
  1565.  
  1566.      Delete-Window   ^X-0            Deletes current window
  1567.  
  1568.      Delete-Other-Windows ^X-1       Deletes all but current window
  1569.  
  1570.      Resize-Window   ^X-^W           Resizes window to a given numeric argument
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.      23
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.      ARC EMACS Reference Manual                               Buffers
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.                                  Chapter 6
  1600.  
  1601.                                   Buffers
  1602.  
  1603.  
  1604.                We  have  already  learned  a  number  of things  about
  1605.      buffers.    As  you will recall,  they  are  the  major  internal
  1606.      entities  in  EMACS  --  the  place  where  editing commands  are
  1607.      executed.  They are  characterized  by  their names, their modes,
  1608.      and by the file with which they are associated.  Each buffer also
  1609.      "remembers" its mark  and  point.  This convenient feature allows
  1610.      you to go to other buffers and return to the original location in
  1611.      the "current" buffer.
  1612.  
  1613.              Advanced users  of  EMACS  frequently  have  a  number of
  1614.      buffers in the computer's memory  simultaneously.    In  the last
  1615.      chapter, for example, you opened at least two buffers -- one into
  1616.      the text you were  editing,  and the other into the EMACS on-line
  1617.      tutorial.  If you deal with complex text files --  say, sectioned
  1618.      chapters  of  a  book, you may have five or six  buffers  in  the
  1619.      computer's memory.   You could select different buffers by simply
  1620.      calling up the file  with  ^X-^F find-file, and let EMACS open or
  1621.      reopen the  buffer.  However, EMACS offers fast and sophisticated
  1622.      buffering techniques that you will find easy to  master  and much
  1623.      more convenient to use.
  1624.  
  1625.              Let's begin by opening three buffers.  You  can  open any
  1626.      three  you  choose,  for example call the  following  files  into
  1627.      memory: fang_txt, publishtxt, and  emacs_tut in the  order listed
  1628.      here.  When you've finished this process, you'll be looking  at a
  1629.      screen showing the EMACS tutorial.  Let's assume that you want to
  1630.      move to the fang_txt buffer.  Enter:
  1631.  
  1632.              ^X-X next-buffer
  1633.  
  1634.              This command moves you to the next buffer.  Because EMACS
  1635.      cycles through the  buffer  list, which is alphabetized, you will
  1636.      now be in the fang_txt buffer. Using ^X-X again places you in the
  1637.      publishtxt  buffer.   If  you  are  on  a  machine that  supports
  1638.      function keys, using ^X-X again places you in  the  Function Keys
  1639.      buffer. Using ^X-X one last time cycles you back to the beginning
  1640.      of the list.
  1641.  
  1642.              If you have a large number of buffers to deal  with, this
  1643.      cycling process may be slow and inconvenient.   The  command ^X-B
  1644.      select-buffer allows you to  specify  the  buffer  you wish to be
  1645.      switched  to.    When the command is entered, EMACS prompts, "Use
  1646.  
  1647.  
  1648.  
  1649.                                                                     24
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.      Buffers                               ARC EMACS Reference Manual
  1657.  
  1658.  
  1659.      buffer:".  Simply enter the buffer name (NOT the file  name), and
  1660.      that buffer will then become the current buffer.
  1661.  
  1662.              Multiple  buffer  manipulation  and  editing is a complex
  1663.      activity, and you will probably  find it very inconvenient to re-
  1664.      save each  buffer  as  you  modify  it.   The command ^X-^B list-
  1665.      buffers creates a new  window  that  gives  details about all the
  1666.      buffers  currently  known  to  EMACS.    Buffers  that have  been
  1667.      modified are identified by  the  "buffer  changed"  indicator (an
  1668.      asterisk in the second column).  You can thus quickly  and easily
  1669.      identify buffers that need  to  be saved to files before you exit
  1670.      EMACS.   The buffer window also  provides  other  information  --
  1671.      buffer  specific modes, buffer size, and  buffer  name  are  also
  1672.      listed.   To close this window,  simply  type  the  close-windows
  1673.      command, ^X-1.
  1674.  
  1675.              To delete any buffer,  type  ^X-K  delete-buffer.   EMACS
  1676.      prompts you "Kill buffer:".  Enter the buffer name  you  want  to
  1677.      delete.    As  this  is  destructive command, EMACS will ask  for
  1678.      confirmation if the buffer  was  changed  and  not saved.  Answer
  1679.      Y(es) or N(o).  As usual ^G cancels the command.
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.      25
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.      ARC EMACS Reference Manual                               Buffers
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.                              Chapter 6 Summary
  1730.  
  1731.  
  1732.              In Chapter 6 you learned how to manipulate buffers.
  1733.  
  1734.      Key Binding             Keystroke                      Effect
  1735.      Next-Buffer             ^X-^X           Switch to the next buffer in the
  1736.                                              buffer list
  1737.  
  1738.      Select-Buffer           ^X-B            Switch to a particular buffer
  1739.  
  1740.      List-Buffers            ^X-^B           List all buffers
  1741.  
  1742.      Delete-Buffer           ^X-K            delete a particular buffer if it
  1743.                                              is off-screen
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.                                                                     26
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.      Modes                                 ARC EMACS Reference Manual
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.                                  Chapter 7
  1798.  
  1799.                                    Modes
  1800.  
  1801.  
  1802.              EMACS allows you to  change  the way it works in order to
  1803.      customized it to the style of editing you  are  using.    It does
  1804.      this by providing a number of different modes .  These  modes can
  1805.      effect either a single buffer, or any new buffer that is created.
  1806.      To add a mode to the  current  buffer, type ^X-M add-mode.  EMACS
  1807.      will then prompt you for the name of  a  mode  to  add.  When you
  1808.      type in a legal mode name,  and  type  a <NL>, EMACS will add the
  1809.      mode  name  to  the list of current mode names in the modeline of
  1810.      the current buffer.
  1811.  
  1812.              To remove an existing mode, typing the  ^X-^M delete-mode
  1813.      will cause EMACS to prompt you for the name of  a  mode to delete
  1814.      from the current  buffer.    This  will remove that mode from the
  1815.      mode list on the current modeline.
  1816.  
  1817.              Global modes are the modes which are inherited by any new
  1818.      buffers which are created.  For example, if you wish to always do
  1819.      string searching with character case being significant, you would
  1820.      want global mode EXACT to be  set  so  that any new files read in
  1821.      inherent the EXACT mode.  Global modes are set with the  M-M add-
  1822.      global-mode  command, and unset with the M-^M  delete-global-mode
  1823.      command.  Also, the  current  global  modes  are displayed in the
  1824.      first line of a ^X-^B list-buffers command.
  1825.  
  1826.      Mode  commands  can  also  set  the  background   and  foreground
  1827.      character colors.  Using add-mode or delete-mode with a lowercase
  1828.      color will set the background color in the current  window.    An
  1829.      uppercase  color will set the foreground  color  in  the  current
  1830.      window.  Colors that EMACS knows about are: white, cyan, magenta,
  1831.      yellow, blue, red,  green,  and  black.   
  1832.      
  1833.  
  1834.      7.1  ASAVE mode
  1835.  
  1836.  
  1837.              Automatic Save mode tells  EMACS  to  automatically write
  1838.      out the current buffer to its associated file on a regular basis.
  1839.      Normally this will be every 256 characters typed  into  the file.
  1840.      The environment variable $ACOUNT  counts  down  to the next auto-
  1841.  
  1842.  
  1843.      27
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.      ARC EMACS Reference Manual                                 Modes
  1851.  
  1852.  
  1853.      save, and $ASAVE is the value used to reset $ACOUNT after  a save
  1854.      occurs.
  1855.  
  1856.  
  1857.      7.2  CMODE mode
  1858.  
  1859.  
  1860.              CMODE is useful to C  programmers.  When CMODE is active,
  1861.      EMACS will try to assist the user in a number of ways.  This mode
  1862.      is set automatically with files that have a .c or .h extension.
  1863.  
  1864.              The <NL> key will normally  attempt to return the user to
  1865.      the next line  at  the  same  level of indentation as the current
  1866.      line, unless the current line ends with a open brace ({) in which
  1867.      case the new line will be further indented by one tab position.
  1868.  
  1869.              A close brace (}) will delete one tab position preceeding
  1870.      itself  as it is typed.  This should line up the close brace with
  1871.      its matching IF, FOR or WHILE statement.
  1872.  
  1873.              A pound sign (#) with only leading whitespace will delete
  1874.      all the whitespace  preceeding  itself.  This  will  always bring
  1875.      preprocessor directives flush to the left margin.
  1876.  
  1877.              Whenever  any  close  fence  is  typed, ie )]>},  if  the
  1878.      matching  open  fence  is  on  screen in the current window,  the
  1879.      cursor will briefly  flash  to  it,  and  then  back.  This makes
  1880.      balancing expressions, and matching blocks much easier.
  1881.  
  1882.  
  1883.      7.3  CRYPT mode
  1884.  
  1885.  
  1886.              When a buffer is in  CRYPT mode, it is encrypted whenever
  1887.      it is written to a file, and decrypted when it  is  read from the
  1888.      file.  The encryption key can be specified on  the  command  line
  1889.      with the -k  switch,  or with the M-E set-encryption-key command.
  1890.      If you attempt to read or  write  a  buffer in crypt mode and now
  1891.      key has  not  been  set,  EMACS  will  execute set-encryption-key
  1892.      automatically, prompting  you for the needed key.  Whenever EMACS
  1893.      prompts you for a key, it will not echo the key to your screen as
  1894.      you type it  (ie  make  SURE  you  get  it  right when you set it
  1895.      originally).
  1896.  
  1897.              The encryption algorithm used changes all characters into
  1898.      normal printing characters, thus the resulting  file  is suitable
  1899.      for  sending  via  electronic mail.  All  version  of  ARC EMACS
  1900.      should  be able decrypt the resulting  file  regardless  of  what
  1901.      machine encrypted it.   Also  available  with  EMACS is the stand
  1902.      alone  program,  MicroCRYPT,   which  can  en/decrypt  the  files
  1903.      produced by CRYPT mode in EMACS.
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.                                                                     28
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.      Modes                                 ARC EMACS Reference Manual
  1917.  
  1918.  
  1919.      7.4  EXACT mode
  1920.  
  1921.  
  1922.              All   string  searches   and   replacements   will   take
  1923.      upper/lower  case into account. Normally the  case  of  a  string
  1924.      during a search or replace is not taken into account.
  1925.  
  1926.  
  1927.      7.5  MAGIC mode
  1928.  
  1929.  
  1930.              In  the  MAGIC   mode  certain  characters  gain  special
  1931.      meanings  when  used  in a search pattern.  Collectively they are
  1932.      know as regular expressions,  and  a  limited  number of them are
  1933.      supported in ARC EMACS.   They  grant  greater  flexibility when
  1934.      using the search  command.    However,  they  do  not  affect the
  1935.      incremental search command.
  1936.  
  1937.              The symbols that  have  special meaning in MAGIC mode are
  1938.      ^, $, ., &, *, [ (and ], used with it), and \.
  1939.  
  1940.              The  characters ^ and $ fix the  search  pattern  to  the
  1941.      beginning  and  end  of line, respectively.  The ^ character must
  1942.      appear  at the beginning of the search string,  and  the  $  must
  1943.      appear at the end,  otherwise  they  loose  their meaning and are
  1944.      treated just like any  other  character.    For example, in MAGIC
  1945.      mode, searching for the pattern "t$" would put the cursor  at the
  1946.      end of any line that ended with the letter 't'.    Note that this
  1947.      is different than searching for "t<NL>", that is, 't' followed by
  1948.      a newline character.  The character $ (and ^,  for  that  matter)
  1949.      matches a position, not a character, so the cursor remains at the
  1950.      end of the line.  But a  newline  is  a  character  that  must be
  1951.      matched,  just like any other character,  which  means  that  the
  1952.      cursor is placed just after it - on  the  beginning  of  the next
  1953.      line.
  1954.  
  1955.              The character .  has a very simple meaning --  it matches
  1956.      any  single character, except the newline.   Thus  a  search  for
  1957.      "bad.er" could match "badger", "badder" (slang), or up to the 'r'
  1958.      of "bad error".
  1959.  
  1960.              The character * is known  as closure, and means that zero
  1961.      or  more  of  the preceding character will match.  If there is no
  1962.      character preceding, * has no  special meaning, and since it will
  1963.      not match  with  a  newline,  *  will  have no special meaning if
  1964.      preceded by the beginning of line symbol ^ or the literal newline
  1965.      character <NL>.
  1966.  
  1967.              The notion of zero or  more characters is important.  If,
  1968.      for example, your cursor was on the line
  1969.  
  1970.           This line is missing two vowels.
  1971.  
  1972.  
  1973.  
  1974.  
  1975.      29
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.      ARC EMACS Reference Manual                                 Modes
  1983.  
  1984.  
  1985.              and  a search was made for "a*",  the  cursor  would  not
  1986.      move, because it  is  guaranteed  to  match no letter 'a' , which
  1987.      satifies the search conditions.  If you wanted to search  for one
  1988.      or  more of the letter 'a', you would  search  for  "aa*",  which
  1989.      would match the letter a, then zero or more of them.
  1990.  
  1991.              The character [ indicates the  beginning  of  a character
  1992.      class.  It is similar to  the  'any'  character ., but you get to
  1993.      choose which characters you want to match.   The  character class
  1994.      is ended with the character ].  So,  while  a  search  for "ba.e"
  1995.      will match "bane", "bade", "bale",  "bate",  et  cetera,  you can
  1996.      limit  it   to  matching  "babe"  and  "bake"  by  searching  for
  1997.      "ba[bk]e".    Only  one of the characters inside the [ and ] will
  1998.      match  a  character.   If in fact you want to match any character
  1999.      except those in the character class, you can put a ^ as the first
  2000.      character.  It must be the first character of the class,  or else
  2001.      it has no special meaning.  So, a search for [^aeiou]  will match
  2002.      any  character except a vowel, but a  search  for  [aeiou^]  will
  2003.      match any vowel or a ^.
  2004.  
  2005.              If you have a lot of characters in order that you want to
  2006.      put in  the  character  class,  you may use a dash (-) as a range
  2007.      character.  So, [a-z] will match any letter (or  any  lower  case
  2008.      letter if EXACT mode is on), and [0-9a-f] will match any digit or
  2009.      any letter 'a' through 'f', which happen to be the characters for
  2010.      hexadecimal numbers.  If the dash is at the beginning or end of a
  2011.      character class, it is taken to be just a dash.
  2012.  
  2013.              The  character & (ampersand) is a replacement  character,
  2014.      and represents the characters which  matched  the  search string.
  2015.      When used in the  M-R  replace-string  or the M-^R query-replace-
  2016.      string commands, the & will be substituted for the search string.
  2017.  
  2018.              The escape character \ is for those times  when  you want
  2019.      to  be  in  MAGIC mode, but also want to use a regular expression
  2020.      character to  be  just  a  character.    It turns off the special
  2021.      meaning of the character.  So a search for "it\." will search for
  2022.      a line with "it.", and not "it" followed by any  other character.
  2023.      The escape character will also let  you  put  ^, -, or ] inside a
  2024.      character class with no special side effects.
  2025.  
  2026.  
  2027.      7.6  OVER mode
  2028.  
  2029.  
  2030.              OVER mode stands for overwrite  mode.  When in this mode,
  2031.      when characters  are typed, instead of simply inserting them into
  2032.      the file, EMACS  will  attempt to overwrite an existing character
  2033.      past the point.    This  is  very useful for adjusting tables and
  2034.      diagrams.
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.                                                                     30
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.      Modes                                 ARC EMACS Reference Manual
  2049.  
  2050.  
  2051.      7.7  WRAP mode
  2052.  
  2053.  
  2054.              Wrap  mode  is  used  when  typing  in  continuous  text.
  2055.      Whenever the cursor is past the currently set fill column  (72 by
  2056.      default) and the user types a space or a <NL>,  the  last word of
  2057.      the line  is  brought  down  to  the  beginning of the next line.
  2058.      Using this, one just types a continuous stream of words and EMACS
  2059.      automatically inserts <NL>s at appropriate places.
  2060.  
  2061.                            NOTE to programmers:
  2062.  
  2063.           EMACS actually  calls  up  the  function  bound  to the
  2064.           illegal keystroke M-FNW.  This is bound to the function
  2065.           wrap-word by default, but can be  re-bound  to activate
  2066.           different functions and macros at wrap time.
  2067.  
  2068.  
  2069.      7.8  VIEW mode
  2070.  
  2071.  
  2072.              VIEW mode disables  all  commands  which  can  change the
  2073.      current buffer.  EMACS will display an error message and ring the
  2074.      bell every time you attempt to change a buffer in VIEW mode.
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.      31
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.      ARC EMACS Reference Manual                                 Modes
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.                              Chapter 7 Summary
  2122.  
  2123.  
  2124.              In Chapter 7 you learned about modes and their effects.
  2125.  
  2126.      Key Binding             Keystroke                      Effect
  2127.      Add-Mode                ^X-M            Add a mode to the current buffer
  2128.  
  2129.      Delete-Mode             ^X-^M           Delete a mode from the current
  2130.                                              buffer
  2131.  
  2132.      Add-Global-Mode         M-M             Add a global mode to the
  2133.                                              current buffer
  2134.  
  2135.      Delete-Global-Mode      M-^M            Delete a global mode from the
  2136.                                              current buffer
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.                                                                     32
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.      Files                                 ARC EMACS Reference Manual
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.                                  Chapter 8
  2190.  
  2191.                                    Files
  2192.  
  2193.  
  2194.              A file is simply a collection of related data.   In EMACS
  2195.      we  are  dealing  with  text  files -- named collections of  text
  2196.      residing  on a disk (or some other storage  medium).    You  will
  2197.      recall  that the major entities EMACS  deals  with  are  buffers.
  2198.      Disk-based  versions  of  files are only active in EMACS when you
  2199.      are reading into or writing out  of  buffers.  As we have already
  2200.      seen, buffers and physical  files  are  linked by associated file
  2201.      names.  For example, the  buffer  "ch7_txt"  which  is associated
  2202.      with the physical disk file "ch7_txt." You will  notice  that the
  2203.      file  is usually specified by the drive name or (in the case of a
  2204.      hard drive) a  path.    Thus  you  can specify full file names in
  2205.      EMACS,
  2206.  
  2207.              e.g. :disk.directories.filename
  2208.  
  2209.              If you do not specify a disk and directories, the default
  2210.      disk is used.
  2211.  
  2212.              IMPORTANT -- If you do not explicitly save your buffer to
  2213.      a  file,  all  your edits will  be  lost  when  you  leave  EMACS
  2214.      (although EMACS will prompt you when you are about to  lose edits
  2215.      by exiting).  In addition, EMACS does not protect your disk-based
  2216.      files from overwriting  when  it  saves  files.    Thus  when you
  2217.      instruct EMACS to save a file to disk, it will  create  a file if
  2218.      the  specified  file  doesn't  exist,  or it will  overwrite  the
  2219.      previously saved version of the file thus replacing it.  Your old
  2220.      version is gone forever.
  2221.  
  2222.              If you are at all unsure about your edits, or if (for any
  2223.      reason) you wish  to  keep  previous  versions of a file, you can
  2224.      change the name of  the  associated  file  with the command ^X-N.
  2225.      When this file is saved to disk, EMACS will create a new physical
  2226.      file  under  the  new  name.    The  earlier  disk  file will  be
  2227.      preserved.
  2228.  
  2229.              For example, let's load  the  file  fang_txt  into EMACS.
  2230.      Now, type ^X-N.  The EMACS command line prompts "name:".  Enter a
  2231.      new name for the file --  say  new.txt  and press <NL>.  The file
  2232.      will be saved under  the  new  filename,  and your disk directory
  2233.      will show both fang_txt and new.txt.
  2234.  
  2235.              An alternative method is  to  write  the file directly to
  2236.      disk under a new  filename.    Let's  pull our "publishtxt" file
  2237.  
  2238.  
  2239.      33
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.      ARC EMACS Reference Manual                                 Files
  2247.  
  2248.  
  2249.      into EMACS.  To write this file under another filename,  type ^X-
  2250.      ^W.  EMACS  will  prompt  you  "write file:".  Enter an alternate
  2251.      filename -- desktoptxt.  Your file will be saved as the physical
  2252.      file "desktoptxt".
  2253.  
  2254.              Note  that  in  the  examples  above,  although  you have
  2255.      changed the names of the related files, the  buffer  names remain
  2256.      the same.   However,  when  you  pull the physical file back into
  2257.      EMACS,  you will find that the buffer name  now  relates  to  the
  2258.      filename.
  2259.  
  2260.              For example --  You  are working with a buffer "fang_txt"
  2261.      with the related  file  "fang_txt".    You change the name of the
  2262.      file to "new.txt".   EMACS  now shows you working with the buffer
  2263.      "fang_txt" and the related  file  "new_txt".    Now pull the file
  2264.      "new.txt" into EMACS.    Notice  that  the  buffer  name  has now
  2265.      changed to "new_txt".
  2266.  
  2267.              If for any  reason  a conflict of buffer names occurs,(if
  2268.      you have files of the same name on different drives  for example)
  2269.      EMACS will prompt you "use buffer:".  Enter an alternative buffer
  2270.      name if you need to.
  2271.  
  2272.              For a list of file related commands (including some we`ve
  2273.      already seen), see the summary page.
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.                                                                     34
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.      Files                                 ARC EMACS Reference Manual
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.                              Chapter 8 Summary
  2320.  
  2321.  
  2322.              In  Chapter  8  you  learned  some of the  more  advanced
  2323.      concepts of  file  naming  and  manipulation.    The relationship
  2324.      between files and buffers was discussed in some detail.
  2325.  
  2326.      Key Binding     Keystroke       Effect
  2327.  
  2328.      Save-file       ^X-^S           Saves contents of current buffer with
  2329.                                      associated filename on default disk/
  2330.                                      directory (if not specified)
  2331.  
  2332.      Write-File      ^X-^W           Current buffer contents will be
  2333.                                      saved under specified name
  2334.  
  2335.      Change-File-name
  2336.                      ^X-N            The associated filename is changed
  2337.                                      (or associated if not previously
  2338.                                      specified) as specified
  2339.  
  2340.      Find-File       ^X-^F           Reads specified file into buffer and
  2341.                                      switches you to that buffer, or switches
  2342.                                      to buffer in which the file has previously
  2343.                                      been read
  2344.  
  2345.      Read-File       ^X-^R           Reads file into buffer thus overwriting
  2346.                                      buffer contents.  If file has already
  2347.                                      been read into another buffer, you will
  2348.                                      be switched to it
  2349.  
  2350.      View-File       ^X-^V           The same as read-file except the buffer
  2351.                                      is automatically put into VIEW mode thus
  2352.                                      preventing any changes from being made
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.      35
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.      ARC EMACS Reference Manual                     Screen Formatting
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.                                  Chapter 9
  2388.  
  2389.                              Screen Formatting
  2390.  
  2391.  
  2392.      9.1  Wrapping Text
  2393.  
  2394.  
  2395.              As  we  learned  in the introduction, EMACS is not a word
  2396.      processor, but an editor.   Some  simple  formatting  options are
  2397.      available however, although in  most  cases  they will not affect
  2398.      the appearence of the finished text when it is  run  through  the
  2399.      formatter.  We have already  encountered  WRAP  mode  which wraps
  2400.      lines longer than a  certain  length  (default is 75 characters).
  2401.      You  will  recall  that WRAP is  enabled  by  entering  ^X-M  and
  2402.      responding to the command line prompt with wrap.
  2403.  
  2404.              You  can  also  set your own wrap margin with the command
  2405.      ^X-F set-fill-column.  Notice  EMACS  responds  "[Fill  column is
  2406.      1]." Now try typing  some  text.  You'll notice some very strange
  2407.      things happening -- your text wraps at every  word!!  This effect
  2408.      occurs because the set wrap margin command must be preceeded by a
  2409.      numeric argument or EMACS sets it to the first column.   Thus any
  2410.      text you type that extends past the first column will wrap at the
  2411.      most convenient line break.
  2412.  
  2413.              To  reset the wrap column to  72  characters,  press  the
  2414.      <META> key and  enter  72.    EMACS  will respond "Arg: 72".  Now
  2415.      press ^X-F.  EMACS will respond "[Fill column is 72]".  Your text
  2416.      will again wrap at the margin you've been using up to this point.
  2417.  
  2418.  
  2419.      9.2  Reformatting Paragraphs
  2420.  
  2421.  
  2422.              After an intensive editing session, you may find that you
  2423.      have paragraphs containing lines of differing lengths.   Although
  2424.      this disparity  will not affect the formatted text, aesthetic and
  2425.      technical concerns  may  make  it  desirable  to  have consistent
  2426.      paragraph blocks on the screen.  If you are in WRAP mode, you can
  2427.      reformat a paragraph  with  the command M-Q fill-paragraph.  This
  2428.      command 'fills'  the current paragraph reformatting it so all the
  2429.      lines are filled and wrap logically.  The process is complex, and
  2430.      (especially with longer paragraphs) may take a little time.
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.                                                                     36
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.      Screen Formatting                     ARC EMACS Reference Manual
  2445.  
  2446.  
  2447.      9.3  Changing Case
  2448.  
  2449.  
  2450.              There  may be occasions when you  find  it  necessary  to
  2451.      change the case of the text you've entered.  EMACS allows  you to
  2452.      change the case of even large  amounts  of text with ease.  Let's
  2453.      try and convert a few of the office traditionalists to the joy of
  2454.      word processing.  Type in the following text:
  2455.  
  2456.           Throw  away your typewriter and learn  to  use  a  word
  2457.           processor.  Word processing is relatively easy to learn
  2458.           and will increase  your productivity enormously.  Enter
  2459.           the Computer Age and find out just how much fun  it can
  2460.           be!!
  2461.  
  2462.              Let's give it a  little  more  impact by capitalizing the
  2463.      first four words.  The first step is to define the region of text
  2464.      just as you would if you  were  doing an extensive deletion.  Set
  2465.      the  mark  at  the beginning of the paragraph with M-<space> set-
  2466.      mark  and  move  the cursor to the space beyond "typewriter." Now
  2467.      enter ^X-^U case-region-upper.   Your  text  should now look like
  2468.      this:
  2469.  
  2470.           THROW  AWAY YOUR TYPEWRITER and learn  to  use  a  word
  2471.           processor.  Word processing is relatively easy to learn
  2472.           and will increase  your productivity enormously.  Enter
  2473.           the Computer Age and find out just how much fun  it can
  2474.           be!!
  2475.  
  2476.              If you want to  change  the text back to lower case, type
  2477.      ^X-^L  case-region-lower.   You can  also  capitalize  individual
  2478.      words.   To capitalize the word "fun",  position  the  cursor  in
  2479.      front of the word and type M-U case-word-upper.  The word  is now
  2480.      capitalized.  To change it back to lower case,  move  the  cursor
  2481.      back to the beginning of the word and type M-L case-word-lower.
  2482.  
  2483.              You may also capitalize individual letters in EMACS.  The
  2484.      command M-C  case-word-capitalize  capitalizes  the  first letter
  2485.      after the point.  This command would normally be issued  with the
  2486.      cursor positioned in front of the first letter of  the  word  you
  2487.      wish to capitalize.  If you issue it in the middle of a word, you
  2488.      can end up with some strAnge looking text.
  2489.  
  2490.  
  2491.      9.4  Tabs
  2492.  
  2493.  
  2494.  
  2495.      Tabs in EMACS generally affect screen formatting only.  When EMACS
  2496.      is first started, it sets the default tab to every eighth column.
  2497.      As long as you stay with default, every time you press the tab key
  2498.      a tab character, ^I is inserted.  This    
  2499.  
  2500.  
  2501.      37
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.      ARC EMACS Reference Manual                     Screen Formatting
  2509.  
  2510.  
  2511.      character, like  other control characters, is invisible -- but it
  2512.      makes  a  subtle  and  significant  difference to your  file  and
  2513.      editing.
  2514.  
  2515.              For example, in default mode,  press the tab key and then
  2516.      type the word Test.  "Test"  appears  at the eighth column.  Move
  2517.      your cursor to the beginning of the word and delete  the backward
  2518.      character.    The  word doesn't move back just one character, but
  2519.      flushes  to the left margin.  The reason  for  this  behavior  is
  2520.      easily explained.  In  tab  default,  EMACS  inserts a 'real' tab
  2521.      character when you press the tab key.  This character is inserted
  2522.      at the default position, but NO SPACES are  inserted  between the
  2523.      tab character and the margin (or previous tab character).  As you
  2524.      will recall,  EMACS only recognizes characters (such as spaces or
  2525.      letters) and thus when  the  tab  character  is removed, the text
  2526.      beyond  the tab is flushed back to the  margin  or  previous  tab
  2527.      mark.
  2528.  
  2529.              This  situation  changes  if   you   alter   the  default
  2530.      configuration.    The  default value may be changed by entering a
  2531.      numeric argument before pressing the tab key.  As we saw earlier,
  2532.      pressing the META key and entering a number allows you to specify
  2533.      how EMACS performs a  given  action.  In this case, let's specify
  2534.      an argument of 10 and hit the tab key.
  2535.  
  2536.              Now hit the tab key again and type Test.  Notice the word
  2537.      now  appears  at  the tenth column.  Now move to the beginning of
  2538.      the word and delete the  backward character. "Test" moves back by
  2539.      one character.
  2540.  
  2541.              EMACS behaves differently in these  circumstances because
  2542.      the ^I handle-tab function deals  with  tabbing  in  two distinct
  2543.      ways.  In default conditions, or if the numeric argument  of zero
  2544.      is used, handle-tab inserts a true tab character.  If, however, a
  2545.      non-zero numeric argument is  specified,  handle-tab  inserts the
  2546.      correct number of spaces  needed  to  position  the cursor at the
  2547.      next specified tab position.    It does NOT insert the single tab
  2548.      character and  hence any editing functions should take account of
  2549.      the number of spaces between tabbed columns.
  2550.  
  2551.              Many times you would  like  to take a line which has been
  2552.      created using the tab character and change it to use just spaces.
  2553.      The command ^X-^D detab-line changes any tabs from  the  point to
  2554.      the  end  of  the current line into the right number of spaces so
  2555.      the line does not change.  This is very useful for times when the
  2556.      file must be printed or transfered to a machine  which  does  not
  2557.      understand tabs.
  2558.  
  2559.              Also,  the inverse  command,  ^X-^E  entab-lines  changes
  2560.      multiple  spaces  to  tabs where possible.  This is a good way to
  2561.      shrink the  size of large documents, especially with data tables.
  2562.      Both of these commands can take a numeric argument which  will be
  2563.      interpeted as the number of lines to en/detab.
  2564.  
  2565.  
  2566.  
  2567.                                                                     38
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.      Screen Formatting                     ARC EMACS Reference Manual
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.                              Chapter 9 Summary
  2582.  
  2583.  
  2584.              In Chapter 9 introduced some of  the  formatting features
  2585.      of  EMACS.  Text-wrap,  paragraph  reformatting,  and  tabs  were
  2586.      discussed  in  some  detail.  The commands in the following table
  2587.      were covered in the chapter.
  2588.  
  2589.  
  2590.      Key Binding             Keystroke                   Effect
  2591.      Add-Mode/WRAP           ^X-M[WRAP]      Add wrap mode to current buffer
  2592.  
  2593.      Delete-Mode/WRAP        ^X-^M[WRAP]     Remove wrap mode from current
  2594.                                              buffer
  2595.  
  2596.      Set-Fill-Column         ^X-F            Set fill column to given numeric
  2597.                                              argument
  2598.  
  2599.      Fill-Paragraph          M-Q             Logically reformats the current
  2600.                                              paragraph
  2601.  
  2602.      Case-Word-Upper         M-U             Text from point to end of the
  2603.                                              current word is changed to
  2604.      uppercase
  2605.  
  2606.      Case-Word-Lower         M-L             Text from point to end of the
  2607.                                              current word is changed to
  2608.      lowercase
  2609.  
  2610.      Case-Word-Capitalize    M-C             First word (or letter) after the
  2611.                                              point is capitalized
  2612.  
  2613.      Case-Region-Upper       ^X-^U           The current region is uppercased
  2614.  
  2615.      Case-Region-Lower       ^X-^L           The current region is lowercased
  2616.  
  2617.      Handle-Tab              ^I              Tab interval is set to the given
  2618.                                              numeric argument
  2619.      Entab-Line              ^X-^E           Changes multiple spaces to tabs
  2620.                                              characters where possible
  2621.      Detab-Line              ^X-^D           Changes tab characters to the
  2622.                                              appropriate number of spaces
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.      39
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.      ARC EMACS Reference Manual           Access to the Outside World
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.                                 Chapter 10
  2650.  
  2651.                         Access to the Outside World
  2652.  
  2653.  
  2654.              EMACS has  the ability to interface to other programs and
  2655.      the environment of the computer outside of itself.  It  does this
  2656.      through  a  series  of  commands  that  allow  it  to talk to the
  2657.      computer's command processor or shell. On the Archimedes, this is
  2658.      the Arthur OSCLI command line interpreter. 
  2659.  
  2660.  
  2661.              The ^X-! shell-command command  prompts  the  user  for a
  2662.      command line to send out to the shell  to  execute.  This  can be
  2663.      very  useful for doing file listings  and  changing  the  current
  2664.      directory or folder.   EMACS  gives  control  to the shell, which
  2665.      executed the command, and then types [END] and waits for the user
  2666.      to  type a character before redrawing  the  screen  and  resuming
  2667.      editing. If the shell-command command  is  used  from  within the
  2668.      macro language, there is no pause.
  2669.  
  2670.              ^X-@ pipe-command command allows EMACS to execute a shell
  2671.      command,  and  if  the particular computer allows  it,  send  the
  2672.      results into a buffer which  is  automatically  displayed  on the
  2673.      screen. The resulting buffer, called "command" can be manipulated
  2674.      just like any other editing buffer. Text can be copied out  of it
  2675.      or rearanged as needed. This buffer is originally created in VIEW
  2676.      mode, so remember to ^X-^Mview<NL> in order to change it.
  2677.  
  2678.  
  2679.  
  2680.                                                                     40
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.      Access to the Outside World           ARC EMACS Reference Manual
  2688.  
  2689.  
  2690.      ^X-$ is equivalent to the ^X-! shell-command.
  2691.  
  2692.              Sometimes,  you  would  like to get back to the shell and
  2693.      execute other commands, without losing  the  current  contents of
  2694.      EMACS.  The ^X-C  i-shell  command  shells  out of EMACS, leaving
  2695.      EMACS in the computer and  executing another command shell. This
  2696.      brings up a screen with the Arthur * prompt. EMACS will remain in 
  2697.      this mode allowing you to enter star commands until you either press
  2698.      escape or RETURN at the * prompt.
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.      41
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.      ARC EMACS Reference Manual           Access to the Outside World
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.                             Chapter 10 Summary
  2749.  
  2750.  
  2751.              In Chapter 10 introduced  different  ways  to  access the
  2752.      computers  shell or command processor from  within  EMACS.    The
  2753.      commands in the following table were covered in the chapter.
  2754.  
  2755.  
  2756.      Key Binding             Keystroke                   Effect
  2757.      Execute-program         ^X-$            Execute an external program
  2758.                                              directly
  2759.  
  2760.      Filter-command          ^X-#            Send the current buffer through
  2761.                                              a shell filter
  2762.  
  2763.      I-shell                 ^X-C            Escape to a new shell
  2764.  
  2765.      Pipe-command            ^X-@            Send the results of an external
  2766.                                              shell command to a buffer
  2767.  
  2768.      Shell-command           ^X-!            Execute one shell command
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.                                                                     42
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.      Keyboard Macros                       ARC EMACS Reference Manual
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.                                 Chapter 11
  2815.  
  2816.                               Keyboard Macros
  2817.  
  2818.  
  2819.              In many applications, it may  be  necessary  to  repeat a
  2820.      series  of characters or commands frequently.    For  example,  a
  2821.      paper may require the frequent repetition of a complex formula or
  2822.      a long name.  You may also have a series  of  EMACS commands that
  2823.      you invoke frequently.  Keyboard macros offer a convenient method
  2824.      of recording and repeating these commands.
  2825.  
  2826.              Imagine, for example, you are writing  a  scholarly paper
  2827.      on  Asplenium  platyneuron,  the  spleenwort  fern.     Even  the
  2828.      dedicated botanist would probably find it a task bordering on the
  2829.      agonizing to type Asplenium platyneuron frequently throughout the
  2830.      paper.  An alternative method is 'record' the name in  a keyboard
  2831.      macro.  Try it yourself.
  2832.  
  2833.              The command ^X-( begin-macro starts recording the all the
  2834.      keystrokes and commands you input.   After you've typed it, enter
  2835.      Asplenium platyneuron.  To stop recording,  type  ^X-) end-macro.
  2836.      EMACS has stored all the keystrokes between the two commands.  To
  2837.      repeat the name you've stored, just enter ^X-E execute-macro, and
  2838.      the name "Asplenium platyneuron"  appears.    You can repeat this
  2839.      action as often  as  you  want,  and  of course as with any EMACS
  2840.      command, you may precede it with a numerical argument.
  2841.  
  2842.              Because EMACS records keystrokes, you may freely intermix
  2843.      commands and text.  Unfortunately, you can only  store  one macro
  2844.      at  a  time.   Thus, if you begin to record  another  macro,  the
  2845.      previously  defined  macro  is lost. Be careful  to  ensure  that
  2846.      you've finished with one macro before defining another.    If you
  2847.      have a series  of  commands  that  you would like to 'record' for
  2848.      future use, use the macro  or  procedure  facilities  detailed in
  2849.      chapter <X>.
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.      43
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.      ARC EMACS Reference Manual                       Keyboard Macros
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.                             Chapter 11 Summary
  2879.  
  2880.  
  2881.              Chapter 11 covered  keyboard  macros.  You learned how to
  2882.      record keystrokes and how to repeat the stored sequence.
  2883.  
  2884.      Key Binding             Keystroke               Effect
  2885.  
  2886.      Start-Macro             ^X-(            Starts recording all keyboard input
  2887.  
  2888.      End-Macro               ^X-)            Stops recording keystrokes for
  2889.                                              macro
  2890.  
  2891.      Execute-Macro           ^X-E            Entire sequence of recorded
  2892.                                              keystrokes is replayed
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.                                                                     44
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.      ARC EMACS Macros                     ARC EMACS Reference Manual
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.                                 Chapter 12
  2947.  
  2948.                              ARC EMACS Macros
  2949.  
  2950.  
  2951.              Macros are programs that are used to customize the editor
  2952.      and to perform complicated editing tasks.  They may be  stored in
  2953.      files  or  buffers  and  may  be  executed  using an  appropriate
  2954.      command, or bound to  a  particular  keystroke.   Portions of the
  2955.      standard start-up file are implemented via macros, as well as the
  2956.      example menu system.  The  execute-macro-<n>  commands  cause the
  2957.      macro, numbered from 1  to  40, to be executed.  The execute-file
  2958.      command allows you to execute a macro stored in a disk  file, and
  2959.      the execute-buffer command  allows  you to execute a macro stored
  2960.      in a buffer.   Macros  are stored for easy execution by executing
  2961.      files that contain the store-macro command.
  2962.  
  2963.              If you need more  than  40  macros, named macroes, called
  2964.      procedures, can be used.   The  store-procedure  command  takes a
  2965.      string argument which is the name of a procedure to store.  These
  2966.      procedures than can be executed with  the  M-^E execute-procedure
  2967.      or the run commands.
  2968.  
  2969.              There are many different aspects  to  the  macro language
  2970.      within ARC EMACS.  Editor commands are the various commands that
  2971.      manipulate  text,  buffers,  windows,  etc,  within  the  editor.
  2972.      Directives are commands which  control  what  lines  get executed
  2973.      within  a  macro.    Also  there are various types of  variables.
  2974.      Environmental  variables  both control and  report  on  different
  2975.      aspects of the editor.  User variables hold  string  values which
  2976.      may be changed and inspected.  Buffer variables allow text  to be
  2977.      placed into variables.  Interactive variable allow the program to
  2978.      prompt the user  for  information.    Functions  can  be  used to
  2979.      manipulate all these variables.
  2980.  
  2981.  
  2982.      12.1  Constants
  2983.  
  2984.  
  2985.              All constants and variable contents in  EMACS  are stored
  2986.      as  strings  of  characters. Numbers are stored digit by digit as
  2987.      characters.  This  allows  EMACS  to  be  "typeless",  not having
  2988.      different variables types be legal  in  different  contexts. This
  2989.      has  the disadvantage of forcing the user  to  be  more  carefull
  2990.      about the context of the  statements variables are placed in, but
  2991.      in  turn  gives  them  more  flexibility in where they can  place
  2992.      variables. Needless to say, this also  allows  EMACS's expression
  2993.      evaluator to be both consice and quick.
  2994.  
  2995.  
  2996.      45
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3004.  
  3005.  
  3006.              Wherever statements need to have arguments,  it  is legal
  3007.      to  place constants.  A constant is  a  double  quote  character,
  3008.      followed by a string of  characters,  and  terminated  by another
  3009.      double  quote character. To represent various special  characters
  3010.      within a constant, the tilde (~) character is used. The character
  3011.      following the tilde  is  interpeted  according  to  the following
  3012.      table:
  3013.  
  3014.      Sequence        Result
  3015.      ~n              ^J      linefeed/newline, (EMACS newline character)
  3016.      ~r              ^M      carraige return
  3017.      ~~              ~
  3018.      ~b              ^H      backspace
  3019.      ~f              ^L      formfeed
  3020.      ~t              ^I      tab
  3021.      ~"              "
  3022.  
  3023.              Any character not in the table which follows a tilde will
  3024.      be passed unmodified.  This action is similar to  the  ^Q  quote-
  3025.      character command available from the keyboard.
  3026.  
  3027.              The double  quotes around constants are not needed if the
  3028.      constant contains no internal whitespace  and  it  also  does not
  3029.      happen  to  meet   the   rules  for  any  other  EMACS  commands,
  3030.      directives, variables, or functions.  This  is  reasonable useful
  3031.      for numeric constants.
  3032.  
  3033.  
  3034.      12.2  Variables
  3035.  
  3036.  
  3037.              Variables in ARC EMACS  can  be  used  to  return values
  3038.      within expressions, as  repeat  counts to editing commands, or as
  3039.      text  to be inserted into buffers and messages.    The  value  of
  3040.      these  variables  is  set using the  set  (^X-A)  command.    For
  3041.      example, to set the  current  fill  column  to 64 characters, the
  3042.      following macro line would be used:
  3043.  
  3044.              set $fillcol 64
  3045.  
  3046.              or to have the contents of %name inserted at the point in
  3047.      the current buffer, the command to use would be:
  3048.  
  3049.              insert-string %name
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.                                                                     46
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.      ARC EMACS Macros                     ARC EMACS Reference Manual
  3070.  
  3071.  
  3072.  
  3073.      12.2.1  Environmental Variables
  3074.  
  3075.  
  3076.              "What good is a quote if you can't change it?"
  3077.  
  3078.              These variables are used to change  different  aspects of
  3079.      the  way the editor works.  Also they  will  return  the  current
  3080.      settings if used as  part  of  an  expression.  All environmental
  3081.      variable  names begin with a dollar sign ($)  and  are  in  lower
  3082.      case.
  3083.  
  3084.      $acount        The countdown  of  inserted  characters  until the
  3085.                     next save-file.
  3086.  
  3087.      $asave         The   number   of  inserted   characters   between
  3088.                     automatic file-saves in ASAVE mode.
  3089.  
  3090.      $cbufname      Name of the current buffer
  3091.  
  3092.      $cfname        File name of the current buffer
  3093.  
  3094.      $cmode         Integer containing the mode of the current buffer.
  3095.                     (See Appendix F for values)
  3096.  
  3097.      $curchar       Character currently at the point
  3098.  
  3099.      $curcol        Current column of point in current buffer
  3100.  
  3101.      $curline       Current line of point in current buffer
  3102.  
  3103.      $curwidth      Number of columns used currently
  3104.  
  3105.      $cwline        Current display line in current window
  3106.  
  3107.      $debug         Flag to trigger  macro debugging (try it... you'll
  3108.                     like it!)
  3109.  
  3110.      $discmd        Flag to disable the  echoing  of  messages  on the
  3111.                     command line
  3112.  
  3113.      $disinp        Flag  to disable the echoing of characters  during
  3114.                     command line input
  3115.  
  3116.      $fillcol       Current fill column
  3117.  
  3118.      $gflags        Global  flags  controlling  some  EMACS   internal
  3119.                     functions (See appendix G for details)
  3120.  
  3121.      $gmode         Global mode flags. (See Appendix F for values)
  3122.  
  3123.  
  3124.  
  3125.      47
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3133.  
  3134.  
  3135.      $lastkey       [READ ONLY]Last keyboard character typed
  3136.  
  3137.      $line          The current line  in  the  current  buffer  can be
  3138.                     retrieved and set with this environment variable
  3139.  
  3140.      $lwidth        [READ ONLY]Returns the number of characters in the
  3141.                     current line
  3142.  
  3143.      $match         [READ  ONLY]Last  string  matched  in a magic mode
  3144.                     search
  3145.  
  3146.      $pagelen       Number of screen lines used currently
  3147.  
  3148.      $palette       string  used  to  control  the   palette  register
  3149.                     settings  on graphics versions.  The usually  form
  3150.                     consists  of groups of three octal digits  setting
  3151.                     the red, green, and blue levels.
  3152.  
  3153.      $pending       [READ  ONLY]Flag  to  determine  if there are user
  3154.                     keystrokes waiting to be processed.
  3155.  
  3156.      $progname      [READ ONLY]Always contains the string "ARC EMACS"
  3157.                     for standard ARC EMACS.   Could be something else
  3158.                     if EMACS is incorporated as part of someone else's
  3159.                     program
  3160.  
  3161.      $replace       Current default replace string
  3162.  
  3163.      $rval          This contains  the  return  value  from  the  last
  3164.  
  3165.                     subprocess which was invoked from EMACS
  3166.  
  3167.      $search        Current default search string
  3168.  
  3169.      $seed          Integer seed of the random number generator
  3170.  
  3171.  
  3172.      $status        [READ ONLY]Status  of  the  success  of  the  last
  3173.                     command (TRUE or FALSE).    This  is  usually used
  3174.                     with !force to  check  on the success of a search,
  3175.                     or a file operation.
  3176.  
  3177.      $target        Current target for line moves (setting this fool's
  3178.                     EMACS into believing the last command  was  a line
  3179.                     move)
  3180.  
  3181.      $tpause        Controls the length  of  the  pause  to  display a
  3182.                     matched fence when the current buffer is  in CMODE
  3183.                     and a close fence has been typed
  3184.  
  3185.      $version       [READ ONLY]Contains the current ARC EMACS version
  3186.                     number
  3187.  
  3188.  
  3189.                                                                     48
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.      ARC EMACS Macros                     ARC EMACS Reference Manual
  3197.  
  3198.  
  3199.      $wline         Number of display lines in current window
  3200.  
  3201.              Obviously, many more of these variables will be availible
  3202.      in  future releases of ARC EMACS.
  3203.  
  3204.  
  3205.  
  3206.      12.2.2  User variables
  3207.  
  3208.  
  3209.              User variables  allow you, the user, to store strings and
  3210.      manipulate  them.    These strings can be pieces of text, numbers
  3211.      (in  text form), or the logical values TRUE  and  FALSE.    These
  3212.      variables can be combined,  tested,  inserted  into  buffers, and
  3213.      otherwise used to control the way your macros execute.    At  the
  3214.      moment, up to 255 user variables may be  in  use  in  one editing
  3215.      session.  All users variable names must begin with a percent sign
  3216.      (%) and may contain  any  printing characters.  Only the first 10
  3217.      characters are  significant  (ie  differences  beyond  the  tenth
  3218.      character are  ignored).  Most operators will truncate strings to
  3219.      a length of 128 characters.
  3220.  
  3221.  
  3222.      12.2.3  Buffer Variables
  3223.  
  3224.  
  3225.              Buffer variables are special in  that  they  can  only be
  3226.      queried and cannot be set.  What buffer variables are is a way to
  3227.      take text from a buffer and place it in a variable.  For example,
  3228.      if I  have  a  buffer  by the name of RIGEL2, and it contains the
  3229.      text:
  3230.  
  3231.              Richmond
  3232.              Lafayette
  3233.              <*>Bloomington          (where <*> is the current point)
  3234.              Indianapolis
  3235.              Gary
  3236.              =* ARC EMACS 1.00 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  3237.  
  3238.              and within a command I reference #rigel2, like:
  3239.  
  3240.              insert-string #rigel2
  3241.  
  3242.              ARC EMACS would start at the current point in the RIGEL2
  3243.      buffer and grab  all the text up to the end of that line and pass
  3244.      that back.  Then it would  advance  the point to the beginning of
  3245.      the next line. Thus, after  our last command executes, the string
  3246.      "Bloomington" gets inserted  into  the  current  buffer,  and the
  3247.      buffer RIGEL2 now looks like this:
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.      49
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3263.  
  3264.  
  3265.              Richmond
  3266.              Lafayette
  3267.              Bloomington
  3268.              <*>Indianapolis         (where <*> is the current point)
  3269.              Gary
  3270.              =* ARC EMACS 1.00 (WRAP) == rigel2 == File: /data/rigel2.txt =====
  3271.  
  3272.              as you have probably noticed, a buffer  variable consists
  3273.      of the buffer name, preceded by a pound sign (#).
  3274.  
  3275.  
  3276.      12.2.4  Interactive variables
  3277.  
  3278.  
  3279.              Interactive variables are actually a method to prompt the
  3280.      user for a string.  This is done by using an at sign (@) followed
  3281.      either with a quoted string, or a variable  containing  a string.
  3282.      The string is the placed on the bottom line, and the editor waits
  3283.      for the user to type in a string.  Then the  string  typed  in by
  3284.      the users is returned as the value of  the  interactive variable.
  3285.      For example:
  3286.  
  3287.              set %quest "What file? "
  3288.              find-file @%quest
  3289.  
  3290.              will ask the user for a file name, and  then  attempt  to
  3291.      find it. Note also that complex expressions can be built  up with
  3292.      these operators, such as:
  3293.  
  3294.      @&cat &cat "File to decode[" %default "]: "
  3295.  
  3296.              which prompts the user with the concatinated string.
  3297.  
  3298.  
  3299.      12.3  Functions
  3300.  
  3301.  
  3302.              Functions can be used to manipulate variables  in various
  3303.      ways.  Functions can have one, two, or three  arguments.    These
  3304.      arguments will always be placed after the function on the current
  3305.      command line.  For example, if we wanted to increase  the current
  3306.      fill  column  by  two, using emacs's set (^X-A) command, we would
  3307.      write:
  3308.  
  3309.              set $fillcol &add $fillcol 2
  3310.               \      \      \      \     \____second operand
  3311.                \      \      \      \_________first operand
  3312.                 \      \      \_______________function to execute
  3313.                  \      \_____________________variable to set
  3314.                   \___________________________set (^X-A) command
  3315.  
  3316.              Function  names  always  begin  with  the  ampersand  (&)
  3317.      character, and are only significant to the first three characters
  3318.      after the ampersand.  Functions will normal expect  one  of three
  3319.  
  3320.  
  3321.                                                                     50
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.      ARC EMACS Macros                     ARC EMACS Reference Manual
  3329.  
  3330.  
  3331.      types of arguments, and  will  automatically  convert  types when
  3332.      needed.
  3333.  
  3334.      <num>          an ascii string of digits which is interpeted as a
  3335.                     numeric value.  Any string  which  does  not start
  3336.                     with  a   digit  or  a  minus  sign  (-)  will  be
  3337.                     considered zero.
  3338.  
  3339.      <str>          An arbitrary string of characters.  At the moment,
  3340.                     strings are limited to 128 characters in length.
  3341.  
  3342.      <log>          A logical value consisting of the string "TRUE" or
  3343.                     "FALSE".  Numeric strings  will  also  evaluate to
  3344.                     "FALSE" if they  are  equal to zero, and "TRUE" if
  3345.                     they are non-zero.   Arbitrary  text  strings will
  3346.                     have the value of "FALSE".
  3347.  
  3348.              A  list  of the currently  availible  functions  follows:
  3349.      Functions are  always  used  in  lower case, the uppercase letters
  3350.      in the function table  are  the short form of the function (ie &div 
  3351.      for ÷).
  3352.  
  3353.      Numeric Functions:      (returns <num>)
  3354.  
  3355.      &ADD            <num> <num>     Add two numbers
  3356.      &SUB            <num> <num>     Subtract the second number from the first
  3357.      &TIMes          <num> <num>     Multiply two numbers
  3358.      &DIVide         <num> <num>     Divide the first number by the second
  3359.                                      giving an integer result
  3360.      &MOD            <num> <num>     Return the reminder of dividing the
  3361.                                      first number by the second
  3362.      &NEGate         <neg>           Multiply the arg by -1
  3363.      &LENgth         <str>           Returns length of string
  3364.      &SINdex         <str1> <str2>   Finds the position of <str2> within
  3365.                                      <str1>. Returns zero if not found.
  3366.      &ASCii          <str>           Return the ascii code of the first
  3367.                                      character in <str>
  3368.      &RND            <num>           Returns a random integer between 1 and
  3369.                                      <num>
  3370.      &ABS            <num>           Returns the absolute value of <num>
  3371.      &BANd           <num> <num>     Bitwise AND function
  3372.      &BOR            <num> <num>     Bitwise OR function
  3373.      &BXOr           <num> <num>     Bitwise XOR function
  3374.      &BNOt           <num>           Bitwise NOT function
  3375.  
  3376.      String manipulation functions:  (returns <str>)
  3377.  
  3378.      &CAT            <str> <str>     Concatinate the two strings to form one
  3379.      &LEFt           <str> <num>     return the <num> leftmost characters
  3380.                                      from <str>
  3381.      &RIGht          <str> <num>     return the <num> rightmost characters
  3382.                                      from <str>
  3383.  
  3384.  
  3385.  
  3386.      51
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3394.  
  3395.  
  3396.      &MID            <str> <num1> <num2>
  3397.                                      Starting from <num1> position in <str>,
  3398.                                      return <num2> characters.
  3399.      &UPPer          <str>           Uppercase <str>
  3400.      &LOWer          <str>           lowercase <str>
  3401.      &CHR            <num>           return a string with the character
  3402.                                      represented by ascii code <num>
  3403.      >K                            return a string containing a single
  3404.                                      keystroke from the user
  3405.      &ENV            <str>           If the operating system is capable, this
  3406.                                      returns the environment string associated
  3407.                                      with <str>
  3408.      &BIND           <str>           return the function name bound to the
  3409.                                      keystroke <str>
  3410.      &ENV            <str>           Returns the operating system value
  3411.                                      attached to environmental variable <str>
  3412.      &FINd           <str>           Find the named file <str> along the
  3413.                                      path and return its full file specification
  3414.                                      or an empty string if none exists
  3415.  
  3416.      Logical Testing functions:      (returns <log>)
  3417.  
  3418.      &NOT            <log>           Return the opposite logical value
  3419.      &AND            <log1> <log2>   Returns TRUE if BOTH logical arguments
  3420.                                      are TRUE
  3421.      &OR             <log1> <log2>   Returns TRUE if either argument
  3422.                                      is TRUE
  3423.      &EQUal          <num> <num>     If <num> and <num> are numerically
  3424.                                      equal, return TRUE
  3425.      &LESs           <num1> <num2>   If <num1> is less than <num2>, return
  3426.                                      TRUE.
  3427.      &GREater        <num1> <num2>   If <num1> is greater than, or equal to
  3428.                                      <num2>, return TRUE.
  3429.      &SEQual         <str1> <str2>   If the two strings are the same, return
  3430.                                      TRUE.
  3431.      &SLEss          <str1> <str2>   If <str1> is less alphabetically than
  3432.                                      <str2>, return TRUE.
  3433.      &SGReater       <str1> <str2>   If <str1> is alphabetically greater than
  3434.                                      or equal to <str2>, return TRUE.
  3435.      &FINd           <str>           Does the named file <str> exist?
  3436.  
  3437.      Special Functions:
  3438.  
  3439.      &INDirect       <str>           Evaluate <str> as a variable.
  3440.  
  3441.              This last function deserves  more  explanation.  The &IND
  3442.      function evaluates its argument, takes the resulting  string, and
  3443.      then  uses  it  as a variable  name.    For  example,  given  the
  3444.      following code sequence:
  3445.  
  3446.              ; set up reference table
  3447.  
  3448.              set %one        "elephant"
  3449.              set %two        "giraffe"
  3450.  
  3451.  
  3452.                                                                     52
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.      ARC EMACS Macros                     ARC EMACS Reference Manual
  3460.  
  3461.  
  3462.              set %three      "donkey"
  3463.  
  3464.              set %index "two"
  3465.              insert-string &ind %index
  3466.  
  3467.              the string "giraffe"  would  have  been  inserted  at the
  3468.      point  in the current buffer.  This  indirection  can  be  safely
  3469.      nested up to about 10 levels.
  3470.  
  3471.  
  3472.      12.4  Directives
  3473.  
  3474.  
  3475.              Directives  are  commands which only  operate  within  an
  3476.      executing macro, ie they  do  not make sense as a single command.
  3477.      As such, they cannot  be  called up singly or bound to keystroke.
  3478.      Used within macros, they control what lines are  executed  and in
  3479.      what order.
  3480.  
  3481.              Directives  always  start  with  the exclamation mark (!)
  3482.      character  and  must  be  the  first  thing  placed  on  a  line.
  3483.      Directives executed interactively  (via  the execute-command-line
  3484.      command) will be ignored.
  3485.  
  3486.  
  3487.      12.4.1  !ENDM Directive
  3488.  
  3489.  
  3490.              This directive is used to terminate a macro being stored.
  3491.      For example, if a file is being executed contains the text:
  3492.  
  3493.              ;       Read in a file in view mode, and make the window red
  3494.  
  3495.              26      store-macro
  3496.                      find-file @"File to view: "
  3497.                      add-mode "view"
  3498.                      add-mode "red"
  3499.              !endm
  3500.  
  3501.              write-message "[Consult macro has been loaded]"
  3502.  
  3503.              only the lines between the  store-macro  command  and the
  3504.      !ENDM  directive  are  stored in macro 26.  Both numbered macroes
  3505.      and named procedures (via the store-procedure command)  should be
  3506.      terminated with this directive.
  3507.  
  3508.  
  3509.      12.4.2  !FORCE Directive
  3510.  
  3511.  
  3512.              When ARC EMACS executes a macro, if  any  command fails,
  3513.      the macro is terminated at that point. If a line is  preceeded by
  3514.      a !FORCE  directive,  execution  continues  weather  the  command
  3515.      succeeds or not. For example:
  3516.  
  3517.  
  3518.      53
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3526.  
  3527.  
  3528.              ;       Merge the top two windows
  3529.  
  3530.              save-window             ;remember what window we are at
  3531.              1 next-window           ;go to the top window
  3532.              delete-window           ;merge it with the second window
  3533.              !force restore-window   ;This will continue regardless
  3534.              add-mode "red"
  3535.  
  3536.  
  3537.      12.4.3  !IF, !ELSE, and !ENDIF Directives
  3538.  
  3539.  
  3540.              This directive allows statements only to be executed if a
  3541.      condition  specified  in  the  directive  is  met.    Every  line
  3542.      following  the !IF directive, until the  first  !ELSE  or  !ENDIF
  3543.      directive, is only  executed  if the expression following the !IF
  3544.      directive evaluates to a TRUE  value.  For example, the following
  3545.      macro segment creates  the  portion of a text file automatically.
  3546.      (yes believe me, this will be easier to understand then that last
  3547.      explanation....)
  3548.  
  3549.              !if &sequal %curplace "timespace vortex"
  3550.                      insert-string "First, rematerialize~n"
  3551.              !endif
  3552.              !if &sequal %planet "earth"     ;If we have landed on earth...
  3553.                      !if &sequal %time "late 20th century"  ;and we are then
  3554.                              write-message "Contact U.N.I.T."
  3555.                      !else
  3556.                              insert-string "Investigate the situation....~n"
  3557.                              insert-string "(SAY 'stay here Sara')~n"
  3558.                      !endif
  3559.              !else
  3560.                      set %conditions @"Atmosphere conditions outside? "
  3561.                      !if &sequal %conditions "safe"
  3562.                              insert-string &cat "Go outside......" "~n"
  3563.                              insert-string "lock the door~n"
  3564.                      !else
  3565.                              insert-string "Dematerialize..try somewhen else"
  3566.                              newline
  3567.                      !endif
  3568.              !endif
  3569.  
  3570.  
  3571.      12.4.4  !GOTO Directive
  3572.  
  3573.  
  3574.              Flow can be controlled within  a  ARC EMACS  macro using
  3575.      the !GOTO directive.  It  takes  as  an argument a label. A label
  3576.      consists  of a line starting with an asterisk  (*)  and  then  an
  3577.      alphanumeric label.  Only labels in the currently executing macro
  3578.      can  be jumped to, and trying to jump  to  a  non-existing  label
  3579.      terminates execution of a macro.  For example..
  3580.  
  3581.              ;Create a block of DATA statements for a BASIC program
  3582.  
  3583.  
  3584.                                                                     54
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.      ARC EMACS Macros                     ARC EMACS Reference Manual
  3592.  
  3593.  
  3594.                      insert-string "1000 DATA "
  3595.                      set %linenum 1000
  3596.  
  3597.              *nxtin
  3598.                      update-screen           ;make sure we see the changes
  3599.                      set %data @"Next number: "
  3600.                      !if &equal %data 0
  3601.                              !goto finish
  3602.                      !endif
  3603.  
  3604.                      !if &greater $curcol 60
  3605.                              2 delete-previous-character
  3606.                              newline
  3607.                              set %linenum &add %linenum 10
  3608.                              insert-string &cat %linenum " DATA "
  3609.                      !endif
  3610.  
  3611.                      insert-string &cat %data ", "
  3612.                      !goto nxtin
  3613.  
  3614.              *finish
  3615.  
  3616.                      2 delete-previous-character
  3617.                      newline
  3618.  
  3619.  
  3620.      12.4.5  !WHILE and !ENDWHILE Directives
  3621.  
  3622.  
  3623.              This directive allows  you  to  set  up  repetitive tasks
  3624.      easily  and  efficiently.  If  a  group of statements need to  be
  3625.      executed while a certain condition is true, enclose  them  with a
  3626.      while loop. For example,
  3627.  
  3628.              !while &less $curcol 70
  3629.                      insert-string &cat &cat "[" #stuff "]"
  3630.              !endwhile
  3631.  
  3632.              places items from buffer "item" in the current line until
  3633.      the cursor is at or past  column  70.   While loops may be nested
  3634.      and can contain and be the targets of !GOTOs with no ill effects.
  3635.      Using a  while  loop  to  enclose  a  repeated task will run much
  3636.      faster than the corresponding construct using !IFs.
  3637.  
  3638.  
  3639.      12.4.6  !BREAK Directive
  3640.  
  3641.  
  3642.              This  directive  allows  the  user  to abort out  of  the
  3643.      currently most inner while loop, regardless of the condition.  It
  3644.      is  often used to abort processing for  error  conditions.    For
  3645.      example:
  3646.  
  3647.      ;       Read in files and substitute "begining" with "beginning"
  3648.  
  3649.  
  3650.      55
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.      ARC EMACS Reference Manual                     ARC EMACS Macros
  3658.  
  3659.  
  3660.              set %filename #list
  3661.              !while ¬ &seq %filename "<end>"
  3662.      !force          find-file %filename
  3663.                      !if &seq $status FALSE
  3664.                              write-message "[File read error]"
  3665.                              !break
  3666.                      !endif
  3667.                      beginning-of-file
  3668.                      replace-string "begining" "beginning"
  3669.                      save-file
  3670.                      set %filename #list
  3671.              !endwhile
  3672.  
  3673.              This  while loop will process files  until  the  list  is
  3674.      exhausted or there is an error while reading a file.
  3675.  
  3676.  
  3677.      12.4.7  !RETURN Directive
  3678.  
  3679.  
  3680.              The !RETURN Directive causes the current  macro  to exit,
  3681.      either returning to the caller (if any) or  to  interactive mode.
  3682.      For example:
  3683.  
  3684.              ;       Check the monitor type and set %mtyp
  3685.  
  3686.              !if &sres "CGA"
  3687.                      set %mtyp 1
  3688.                      !return
  3689.              !else
  3690.                      set %mtyp 2
  3691.              !endif
  3692.  
  3693.              insert-string "You are on a MONOCHROME machine!~n"
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.                                                                     56
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.      ARC EMACS Command Line Switches and Startup Files     ARC EMACS
  3724.                                                       Reference Manual
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.                                 Appendix A
  3734.  
  3735.             ARC EMACS Command Line Switches and Startup Files
  3736.  
  3737.  
  3738.              When EMACS first executes, it always searches for a file,
  3739.      called rc which it will execute as EMACS macros before it reads in
  3740.      the named source files. This file normally contains EMACS macroes
  3741.      to  bind  the  function keys to useful functions and load various
  3742.      usefull macros.  The  contents  of  this  file will probably vary
  3743.      from system to system and can be modified by the user as desired.
  3744.  
  3745.              When searching for this file,  EMACS looks for it in this
  3746.      order.  
  3747.      
  3748.      
  3749.      Finally,  it  looks   in  the  current  directory.  This  is also
  3750.      the same method EMACS uses to  look  up any files to execute, and
  3751.      to find it's help file help.
  3752.  
  3753.              When calling up EMACS via the command  line there are 
  3754.      different things that can be added to the command line to control it
  3755.      These can be switches,  which are a dash ('-') followed
  3756.      by a letter, and  possible  other  parameters,  or a startup file
  3757.      specifier, which is an at sign '@' followed by a file name.
  3758.  
  3759.      @<file>        This causes the named file to be  executed instead
  3760.                     of  the standard emacs.rc file before emacs  reads
  3761.                     in any other files.  More than one of these can be
  3762.                     placed on  the  command  line,  and  they  will be
  3763.                     executed in the order that they appear.
  3764.  
  3765.     
  3766.      -E             The following source files on the command line can
  3767.                     be edited (as opposed to being in VIEW mode). This
  3768.                     is mainly used to cancel  the  effects  of  the -v
  3769.                     switch used previously in the same command line.
  3770.  
  3771.  
  3772.  
  3773.  
  3774.      57
  3775.  
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.      ARC EMACS Reference Manual  ARC EMACS Command Line Switches and
  3782.                                                          Startup Files
  3783.  
  3784.  
  3785.      -G<num>        Upon entering EMACS, position  the  cursor  at the
  3786.                     <num> line of the first file.
  3787.  
  3788.      -K<key>        This key  tells emacs to place the source files in
  3789.                     CRYPT  mode  and  read it in using  <key>  as  the
  3790.                     encryption key.  If no  key  is  listed immediatly
  3791.                     after the  -K switch, EMACS will prompt for a key,
  3792.                     and not echo it as it is typed.
  3793.  
  3794.      -R             This  places EMACS in "restricted mode" where  any
  3795.                     commands allowing the user to  read  or  write any
  3796.                     files other than the ones  listed  on  the command
  3797.                     line are disabled.  Also all commands allowing the
  3798.                     user access to  the operating system are disabled.
  3799.                     This  makes  EMACS  very   useful   as   a  "safe"
  3800.                     environment for use within other  applications and
  3801.                     especially used as a  remote  editor  for a BBS or
  3802.                     electronic bulletin board system.
  3803.  
  3804.      -S<string>     After EMACS is started, it  automatically searches
  3805.                     for <string> in the first source file.
  3806.  
  3807.      -V             This tells EMACS that  all  the  following sources
  3808.                     files on the  command  line should be in VIEW mode
  3809.                     to prevent any changes being made to them.
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.                                                                     58
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.      ARC EMACS commands                   ARC EMACS Reference Manual
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.                                 Appendix B
  3857.  
  3858.                             ARC EMACS commands
  3859.  
  3860.  
  3861.              Below  is  a  complete list of the commands in EMACS, the
  3862.      keys normally used to do the command, and what the  command does.
  3863.      Remember,  on   there    may    also   be   additional   ways  of
  3864.      using  a  command  (cursor  keys  and special function  keys  for
  3865.      example).
  3866.  
  3867.      Command                         Binding         Meaning
  3868.      abort-command            ^G     This allows the user to abort out of any
  3869.                                      command that is waiting for input
  3870.  
  3871.      add-mode                 ^X-M   Add a mode to the current buffer
  3872.  
  3873.      add-global-mode          M-M    Add a global mode for all new buffers
  3874.  
  3875.      apropos                  M-A    List out commands whose name contains
  3876.                                      the string specified
  3877.  
  3878.      backward-character       ^B     Move one character to the left
  3879.  
  3880.      begin-macro              ^X-(   Begin recording a keyboard macro
  3881.  
  3882.      beginning-of-file        M-<    Move to the beginning of the file in
  3883.                                      the current buffer
  3884.  
  3885.      beginning-of-line        ^A     Move to the beginning of the current line
  3886.  
  3887.      bind-to-key              M-K    Bind a key to a function
  3888.  
  3889.      buffer-position          ^X-=   List the position of the cursor in the
  3890.                                      current window on the command line
  3891.  
  3892.      case-region-lower        ^X-^L  Make a marked region all lower case
  3893.  
  3894.      case-region-upper        ^X-^U  Make a marked region all upper case
  3895.  
  3896.      case-word-capitalize     M-C    Capitalize the following word
  3897.  
  3898.      case-word-lower          M-L    Lower case the following word
  3899.  
  3900.      case-word-upper          M-U    Upper case the following word
  3901.  
  3902.      change-file-name         ^X-N   Change the name of the file in the
  3903.                                      current buffer
  3904.  
  3905.  
  3906.      59
  3907.  
  3908.  
  3909.  
  3910.  
  3911.  
  3912.  
  3913.      ARC EMACS Reference Manual                   ARC EMACS commands
  3914.  
  3915.  
  3916.      change-screen-size       M-^S   Change the number of lines of the screen
  3917.                                      currently being used
  3918.  
  3919.      change-screen-width      M-^T   Change the number of columns of the
  3920.                                      screen currently being used
  3921.  
  3922.      clear-and-redraw         ^L     Clear the physical screen and redraw it
  3923.  
  3924.      clear-message-line      (none)  Clear the command line
  3925.  
  3926.      copy-region              M-W    Copy the currently marked region into
  3927.                                      the kill buffer
  3928.  
  3929.      count-words              M-^C   Count how many words, lines and
  3930.                                      characters are in the current marked region
  3931.  
  3932.      ctlx-prefix              ^X     Change the key used as the ^X prefix
  3933.  
  3934.      delete-blank-lines       ^X-^O  Delete all blank lines around the cursor
  3935.  
  3936.      delete-buffer            ^X-K   Delete a buffer which is not being
  3937.                                      currently displayed in a window
  3938.  
  3939.      delete-mode              ^X-^M  Turn off a mode in the current buffer
  3940.  
  3941.      delete-global-mode       M-^M   Turn off a global mode
  3942.  
  3943.      delete-next-character    ^D     Delete the character following the cursor
  3944.  
  3945.      delete-next-word         M-D    Delete the word following the cursor
  3946.  
  3947.      delete-other-windows     ^X-1   Make the current window cover the entire
  3948.                                      screen
  3949.  
  3950.      delete-previous-character^H     Delete the character to the left of the
  3951.                                      cursor
  3952.  
  3953.      delete-previous-word     M-^H   Delete the word to the left of the cursor
  3954.  
  3955.      delete-window            ^X-0   Remove the current window from the screen
  3956.  
  3957.      describe-bindings       (none)  Make a list of all legal commands
  3958.  
  3959.      describe-key             ^X-?   Describe what command is bound to a
  3960.                                      keystroke sequence
  3961.  
  3962.      detab-line               ^X-^D  Change all tabs in a line to the
  3963.                                      equivelant spaces
  3964.  
  3965.      end-macro                ^X-)   stop recording a keyboard macro
  3966.  
  3967.      end-of-file              M->    Move cursor to the end of the current
  3968.                                      buffer
  3969.  
  3970.  
  3971.  
  3972.                                                                     60
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.      ARC EMACS commands                   ARC EMACS Reference Manual
  3980.  
  3981.  
  3982.      end-of-line              ^E     Move to the end of the current line
  3983.  
  3984.      entab-line               ^X-^E  Change multiple spaces to tabs where
  3985.                                      possible
  3986.  
  3987.      exchange-point-and-mark  ^X-^X  Move cursor to the last marked spot,
  3988.                                      make the original position be marked
  3989.  
  3990.      execute-buffer          (none)  Execute a buffer as a macro
  3991.  
  3992.      execute-command-line    (none)  Execute a line typed on the command
  3993.                                      line as a macro command
  3994.  
  3995.      execute-file             FNB    Execute a file as a macro
  3996.  
  3997.      execute-macro            ^X-E   Execute the keyboard macro (play back
  3998.                                      the recorded keystrokes)
  3999.      execute-macro-<n>       (none)  Execute numbered macro <N> where <N> is
  4000.                                      an integer from 1 to 40
  4001.  
  4002.      execute-named-command    M-X    Execute a command by name
  4003.  
  4004.      execute-procedure        M-^E   Execute a procedure by name
  4005.  
  4006.      execute-program         ^X-$    Execute a program directly (not through
  4007.                                      an intervening shell)
  4008.  
  4009.      exit-emacs               ^X-^C  Exit EMACS. If there are unwritten,
  4010.                                      changed buffers EMACS will ask to confirm
  4011.  
  4012.      fill-paragraph           M-Q    Fill the current paragraph
  4013.  
  4014.      filter-buffer            ^X-#   Filter the current buffer through an
  4015.                                      external filter
  4016.  
  4017.      find-file                ^X-^F  Find a file to edit in the current window
  4018.  
  4019.      forward-character        ^F     Move cursor one character to the right
  4020.  
  4021.      goto-line                M-G    Goto a numbered line
  4022.  
  4023.      goto-matching-fence      M-^F   Goto the matching fence
  4024.  
  4025.      grow-window              ^X-^   Make the current window larger
  4026.  
  4027.      handle-tab               ^I     Insert a tab or set tab stops
  4028.      hunt-forward             FN=    Hunt for the next match of the last
  4029.                                      search string
  4030.  
  4031.      hunt-backward            FN>    Hunt for the last match of the last
  4032.                                      search string
  4033.  
  4034.      help                     M-?    Read EMACS.HLP into a buffer and display it
  4035.  
  4036.  
  4037.      61
  4038.  
  4039.  
  4040.  
  4041.  
  4042.  
  4043.  
  4044.      ARC EMACS Reference Manual                   ARC EMACS commands
  4045.  
  4046.  
  4047.      i-shell                  ^X-C   Shell up to a new command processor
  4048.  
  4049.      incremental-search       ^X-S   Search for a string, incrementally
  4050.  
  4051.      insert-file              ^X-^I  insert a file at the cursor in the
  4052.                                      current file
  4053.  
  4054.      insert-space             ^C     Insert a space to the right of the cursor
  4055.  
  4056.      insert-string           (none)  Insert a string at the cursor
  4057.  
  4058.      kill-paragraph           M-^W   Delete the current paragraph
  4059.  
  4060.      kill-region              ^W     Delete the current marked region, moving
  4061.                                      it to the kill buffer
  4062.  
  4063.      kill-to-end-of-line      ^K     Delete the rest of the current line
  4064.  
  4065.      list-buffers             ^X-^B  List all existing buffers
  4066.  
  4067.      meta-prefix              <ESC>  Key used to precede all META commands
  4068.  
  4069.      move-window-down         ^X-^N  Move all the lines in the current window
  4070.                                      down
  4071.  
  4072.      move-window-up           ^X-^P  Move all the lines in the current window up
  4073.  
  4074.      name-buffer              M-^N   Change the name of the current buffer
  4075.  
  4076.      newline                  ^M     Insert a <NL> at the cursor
  4077.  
  4078.      newline-and-indent       ^J     Insert a <NL> at the cursor and indent
  4079.                                      the new line the same as the preceeding
  4080.      line
  4081.  
  4082.      next-buffer              ^X-X   Bring the next buffer in the list into
  4083.                                      the current window
  4084.  
  4085.      next-line                ^N     Move the cursor down one line
  4086.  
  4087.      next-page                ^V     Move the cursor down one page
  4088.  
  4089.      next-paragraph           M-N    Move cursor to the next paragraph
  4090.  
  4091.      next-window              ^X-O   Move cursor to the next window
  4092.  
  4093.      next-word                M-F    Move cursor to the beginning of the
  4094.                                      next word
  4095.  
  4096.      nop                      M-FNC  Does nothing
  4097.  
  4098.      open-line                ^O     Open a line at the cursor
  4099.  
  4100.      overwrite-string        (none)  Overwrite a string at the cursor
  4101.  
  4102.  
  4103.                                                                     62
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.      ARC EMACS commands                   ARC EMACS Reference Manual
  4111.  
  4112.  
  4113.      pipe-command             ^X-@   Execute an external command and place
  4114.                                      its output in a buffer
  4115.  
  4116.      previous-line            ^P     Move cursor up one line
  4117.  
  4118.      previous-page            ^Z     Move cursor up one page
  4119.  
  4120.      previous-paragraph       M-P    Move back one paragraph
  4121.  
  4122.      previous-window          ^X-P   Move the cursor to the last window
  4123.  
  4124.      previous-word            M-B    Move the cursor to the beginning of the
  4125.                                      word to the left of the cursor
  4126.  
  4127.      query-replace-string     M-^R   Replace all of one string with another
  4128.                                      string, interactively querying the user
  4129.  
  4130.      quick-exit               M-Z    Exit EMACS, writing out all changed buffers
  4131.  
  4132.      quote-character          ^Q     Insert the next character literally
  4133.  
  4134.      read-file                ^X-^R  Read a file into the current buffer
  4135.  
  4136.      redraw-display           M-^L   Redraw the display, centering the
  4137.                                      current line
  4138.  
  4139.      resize-window            ^X-W   Change the number of lines in the
  4140.                                      current window
  4141.  
  4142.      restore-window          (none)  Move cursor to the last saved window
  4143.  
  4144.      replace-string           M-R    Replace all occurences of one string
  4145.                                      with another string from the cursor
  4146.                                      to the end of the buffer
  4147.  
  4148.      reverse-incremental-search^X-R  Search backwards, incrementally
  4149.  
  4150.      run                      M-^E   Execute a named procedure
  4151.  
  4152.      save-file                ^X-^S  Save the current buffer if it is changed
  4153.  
  4154.      save-window             (none)  Remember current window (to restore later)
  4155.  
  4156.      scroll-next-up           M-^Z   Scroll the next window up
  4157.  
  4158.      scroll-next-down         M-^V   Scroll the next window down
  4159.  
  4160.      search-forward           ^S     Search for a string
  4161.  
  4162.      search-reverse           ^R     Search backwards for a string
  4163.  
  4164.      select-buffer            ^X-B   Select a buffer to display in the
  4165.                                      current window
  4166.  
  4167.  
  4168.  
  4169.      63
  4170.  
  4171.  
  4172.  
  4173.  
  4174.  
  4175.  
  4176.      ARC EMACS Reference Manual                   ARC EMACS commands
  4177.  
  4178.  
  4179.      set                      ^X-A   Set a variable to a value
  4180.  
  4181.      set-encryption-key       M-E    Set the encryption key of the current
  4182.                                      buffer
  4183.  
  4184.      set-fill-column          ^X-F   Set the current fill column
  4185.  
  4186.      set-mark                        Set the mark
  4187.  
  4188.      shell-command            ^X-!   Causes an external shell to execute
  4189.                                      a command
  4190.  
  4191.      shrink-window            ^X-^Z  Make the current window smaller
  4192.  
  4193.      split-current-window     ^X-2   Split the current window in two
  4194.  
  4195.      store-macro             (none)  Store the following macro lines to a
  4196.                                      numbered macro
  4197.  
  4198.      store-procedure         (none)  Store the following macro lines to a
  4199.                                      named procedure
  4200.  
  4201.      transpose-characters     ^T     Transpose the character at the cursor
  4202.                                      with the character to the left
  4203.  
  4204.      trim-line                ^X-^T  Trim any trailing whitespace from line
  4205.  
  4206.      unbind-key               M-^K   Unbind a key from a function
  4207.  
  4208.      universal-argument       ^U     Execute the following command 4 times
  4209.  
  4210.      unmark-buffer            M-~    Unmark the current buffer (so it is
  4211.                                      no longer changed)
  4212.  
  4213.      update-screen           (none)  Force a screen update during macro
  4214.                                      execution
  4215.  
  4216.      view-file                ^X-^V  Find a file,and put it in view mode
  4217.  
  4218.      wrap-word                M-FNW  Wrap the current word, this is an
  4219.                                      internal function
  4220.  
  4221.      write-file               ^X-^W  Write the current buffer under a new
  4222.                                      file name
  4223.  
  4224.      write-message           (none)  Display a string on the command line
  4225.  
  4226.      yank                     ^Y     yank the kill buffer into the current
  4227.                                      buffer at the cursor
  4228.  
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235.                                                                     64
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.      ARC EMACS Bindings                   ARC EMACS Reference Manual
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.                                 Appendix C
  4252.  
  4253.                             ARC EMACS Bindings
  4254.  
  4255.  
  4256.              Below  is a complete list of the  key  bindings  used  in
  4257.      ARC EMACS. This can  be  used  as  a  wall  chart  reference for
  4258.      ARC EMACS commands.
  4259.  
  4260.                       Default Key Bindings for ARC EMACS 
  4261.  
  4262.       ^A   Move to start of line           ESC A   Apropos (list some commands)
  4263.       ^B   Move backward by characters     ESC B   Backup by words
  4264.       ^C   Insert space                    ESC C   Initial capitalize word
  4265.       ^D   Forward delete                  ESC D   Delete forward word
  4266.       ^E   Goto end of line                ESC E   Reset Encryption Key
  4267.       ^F   Move forward by characters      ESC F   Advance by words
  4268.       ^G   Abort out of things             ESC G   Go to a line
  4269.       ^H   Backward delete
  4270.       ^I   Insert tab/Set tab stops
  4271.       ^J   Insert <NL>, then indent
  4272.       ^K   Kill forward                    ESC K   Bind Key to function
  4273.       ^L   Refresh the screen              ESC L   Lower case word
  4274.       ^M   Insert <NL>                     ESC M   Add global mode
  4275.       ^N   Move forward by lines           ESC N   Goto End paragraph
  4276.       ^O   Open up a blank line
  4277.       ^P   Move backward by lines          ESC P   Goto Begining of paragraph
  4278.       ^Q   Insert literal                  ESC Q   Fill current paragraph
  4279.       ^R   Search backwards                ESC R   Search and replace
  4280.       ^S   Search forward
  4281.       ^T   Transpose characters
  4282.       ^U   Repeat command four times       ESC U   Upper case word
  4283.       ^V   Move forward by pages           ESC V   Move backward by pages
  4284.       ^W   Kill region                     ESC W   Copy region to kill buffer
  4285.       ^Y   Yank back from killbuffer       ESC X   Execute named command
  4286.       ^Z   Move backward by pages          ESC Z   Save all buffers and exit
  4287.  
  4288.       ESC ^C   Count words in region       ESC ~   Unmark current buffer
  4289.       ESC ^E   Execute named procedure
  4290.       ESC ^F   Goto matching fence         ESC !   Reposition window
  4291.       ESC ^H   Delete backward word        ESC <   Move to start of buffer
  4292.       ESC ^K   Unbind Key from function    ESC >   Move to end of buffer
  4293.       ESC ^L   Reposition window           ESC .   Set mark
  4294.       ESC ^M   Delete global mode          ESC space    Set mark
  4295.       ESC ^N   Rename current buffer       ESC rubout   Delete backward word
  4296.       ESC ^R   Search & replace w/query        rubout   Backward delete
  4297.       ESC ^S   Change screen rows
  4298.       ESC ^T   Change screen columns
  4299.  
  4300.  
  4301.      65
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308.      ARC EMACS Reference Manual                   ARC EMACS Bindings
  4309.  
  4310.  
  4311.       ESC ^V   Scroll next window down
  4312.       ESC ^W   Delete Paragraph
  4313.       ESC ^Z   Scroll next window up
  4314.  
  4315.       ^X ?   Describe a key             ^X !   Run 1 command in a shell
  4316.       ^X =   Show the cursor position   ^X @    Pipe shell command to buffer
  4317.       ^X ^   Enlarge display window     ^X #   Filter buffer thru shell filter
  4318.       ^X 0   Delete current window      ^X $   Execute an external program
  4319.       ^X 1   Delete other windows       ^X (   Begin macro
  4320.       ^X 2   Split current window       ^X )   End macro
  4321.                                         ^X A   Set variable value
  4322.       ^X ^B   Display buffer list       ^X B   Switch a window to a buffer
  4323.       ^X ^C   Exit ARC EMACS            ^X C   Start a new command processor
  4324.       ^X ^D   Detab line                
  4325.       ^X ^E   Entab line                ^X E   Execute macro
  4326.       ^X ^F   Find file                 ^X F   Set fill column
  4327.       ^X ^I   Insert file
  4328.                                         ^X K   Delete buffer
  4329.       ^X ^L   Lower case region
  4330.       ^X ^M   Delete Mode               ^X M   Add a mode
  4331.       ^X ^N   Move window down          ^X N   Rename current filename
  4332.       ^X ^O   Delete blank lines        ^X O   Move to the next window
  4333.       ^X ^P   Move window up            ^X P   Move to the previous window
  4334.       ^X ^R   Get a file from disk      ^X R   Incremental reverse search
  4335.       ^X ^S   Save current file         ^X S   Incremental forward search
  4336.       ^X ^T   Trim line                 (Incremental search
  4337.       ^X ^U   Upper case region                not always availible)
  4338.       ^X ^V   View file
  4339.       ^X ^W   Write a file to disk      ^X W   resize Window
  4340.       ^X ^X   Swap "." and mark         ^X X   Use next buffer
  4341.       ^X ^Z   Shrink window             ^X Z   Enlarge display window
  4342.  
  4343.      Usable Modes
  4344.      WRAP     Lines going past right margin "wrap" to a new line
  4345.      VIEW     Read-Only mode where no modifications are allowed
  4346.      CMODE    Change behavior of some commands to work better with C
  4347.      EXACT    Exact case matching on search strings
  4348.      OVER     Overwrite typed characters instead of inserting them
  4349.      CRYPT    Current buffer will be encrypted on write, decrypted on read
  4350.      MAGIC    Use regular expression matching in searches
  4351.      ASAVE    Save the file every 256 inserted characters
  4352.  
  4353.      WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK  Sets foreground color
  4354.      white/cyan/magenta/yellow/blue/red/green/black  Sets background color
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.  
  4361.  
  4362.  
  4363.  
  4364.  
  4365.  
  4366.  
  4367.                                                                     66
  4368.  
  4369.  
  4370.  
  4371.  
  4372.  
  4373.  
  4374.      Supported machines                    ARC EMACS Reference Manual
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.                                 Appendix D
  4384.  
  4385.  
  4386.  
  4387.  
  4388.      67
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.      ARC EMACS Reference Manual                    
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439.  
  4440.  
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.                                                                     68
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.      Machine Dependent Notes               ARC EMACS Reference Manual
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.                                 Appendix E
  4469.  
  4470.                           Machine Dependent Notes
  4471.  
  4472.  
  4473.  
  4474.      E.1  Archimedes 
  4475.  
  4476.              EMACS also takes advantege of various  function  keys and
  4477.      the  keys  on  the keypad on the ARC.    The  function  keys  are
  4478.      initially not bound to  any  particular  functions (except by the
  4479.      emacs.rc startup file), but  the  keypad  keys  do default to the
  4480.      following:
  4481.  
  4482.      Keypad key      Function
  4483.  
  4484.      Home            beginning-of-file
  4485.      CSR  UP         previous-line
  4486.      Pg Up           previous-page
  4487.      CSR  LEFT       backward-character
  4488.      CSR  RIGHT      forward-character
  4489.      Shift Copy      end-of-file
  4490.      CSR  DOWN       next-line
  4491.      Pg Dn           next-page
  4492.      Copy            delete-next-character
  4493.  
  4494.              All these  special keys are indicated in EMACS macroes by
  4495.      use  of  the  FN prefix.  Below is a list of many of the keys and
  4496.      the  codes used to specify them.  Also the codes may be gotten by
  4497.      using the describe-key (^X ?) command on the suspect key.
  4498.  
  4499.  
  4500.  
  4501.  
  4502.  
  4503.      69
  4504.  
  4505.      ARC EMACS Reference Manual               Machine Dependent Notes
  4506.  
  4507.                       function keys in ARC EMACS
  4508.  
  4509.     Key      code    EMACS     Keyboard
  4510.                                (CTRL+SHIFT then ALT followed by...)  
  4511.  
  4512.       f0     &180    FN€        CTRL @
  4513.       f1     &181    FNŴ        CTRL A
  4514.       f2     &182    FNŵ        CTRL B
  4515.       f3     &183    FN◰        CTRL C
  4516.       f4     &184    FN☓        CTRL D
  4517.       f5     &185    FNŶ        CTRL E
  4518.       f6     &186    FNŷ        CTRL F
  4519.       f7     &187    FN        CTRL G
  4520.       f8     &188    FN⇦        CTRL H
  4521.       f9     &189    FN⇨        CTRL I
  4522.       f10    &1CA    FNÊ             J
  4523.       f11    &1CB    FNË             K
  4524.       f12    &1CC    FNÌ             L
  4525.  
  4526.  
  4527. SHIFT f0      &190   FN‘        CTRL P
  4528. SHIFT f1      &191   FN’        CTRL Q
  4529. SHIFT f2      &192   FN‹        CTRL R
  4530. SHIFT f3      &193   FN›        CTRL S
  4531. SHIFT f4      &194   FN“        CTRL T
  4532. SHIFT f5      &195   FN”        CTRL U
  4533. SHIFT f6      &196   FN„        CTRL V
  4534. SHIFT f7      &197   FN–        CTRL W
  4535. SHIFT f8      &198   FN—        CTRL X
  4536. SHIFT f9      &199   FN−        CTRL Y
  4537. SHIFT f10     &1DA   FNÚ             Z
  4538. SHIFT f11     &1DB   FNÛ             [
  4539. SHIFT f12     &1DC   FNÜ             \
  4540.  
  4541. CTRL  f0      &1A0   FN              SPACE
  4542. CTRL  f1      &1A1   FN¡             !
  4543. CTRL  f2      &1A2   FN¢             "
  4544. CTRL  f3      &1A3   FN£             #
  4545. CTRL  f4      &1A4   FN¤             $
  4546. CTRL  f5      &1A5   FN¥             %
  4547. CTRL  f6      &1A6   FNÞ             ^
  4548. CTRL  f7      &1A7   FN¦             &
  4549. CTRL  f8      &1A8   FNª             *
  4550. CTRL  f9      &1A9   FN¨             (
  4551. CTRL  f10     &1EA   FNê             j
  4552. CTRL  f11     &1EB   FNë             k
  4553. CTRL  f12     &1EC   FNì             l
  4554.  
  4555.                                                                     70
  4556.  
  4557.      Machine Dependent Notes               ARC EMACS Reference Manual
  4558.  
  4559.       
  4560. Page Up       &19F   FNfl        CTRL _
  4561. +SHIFT        &18F   FN•        CTRL O
  4562. +CTRL         &1BF   FN¿             ?
  4563.  
  4564. Page Dn       &19E   FNfi        CTRL ^
  4565. +SHIFT        &18E   FN‰        CTRL N
  4566. +CTRL         &1BE   FN¾             >
  4567.  
  4568. CSR Left      &18C   FN…        CTRL L
  4569. +SHIFT        &19C   FN†        CTRL \
  4570. +CTRL         &1AC   FN¬             ,
  4571.  
  4572. CSR Right     &18D   FN™        CTRL M
  4573. +SHIFT        &19D   FN‡        CTRL ]
  4574. +CTRL         &1AD   FN­             -
  4575.  
  4576. CSR Down      &18E   FN‰        CTRL N
  4577. +SHIFT        &19E   FNfi        CTRL ^
  4578. +CTRL         &1AE   FN®             .
  4579.  
  4580. CSR Up        &18F   FN•        CTRL O
  4581. +SHIFT        &19F   FNfl        CTRL _
  4582. +CTRL         &1AF   FN¯             /
  4583.  
  4584. Copy          &18B   FN⇧        CTRL K
  4585. +SHIFT        &19B   FNœ        CTRL [
  4586. +CTRL         &1AB   FN«             +
  4587.  
  4588. Insert        &1CD   FNÍ             M
  4589. +SHIFT        &1DD   FNÝ             ]
  4590. +CTRL         &1ED   FNí             m
  4591.  
  4592. Tab           &18A   FN⇩        CTRL J
  4593. +SHIFT        &19A   FNŒ        CTRL Z
  4594. +CTRL         &1AA   FNª             *
  4595.  
  4596.  
  4597.      71
  4598.  
  4599.  
  4600.      ARC EMACS Reference Manual               Machine Dependent Notes
  4601.  
  4602. Many of the special codes are entered by using the Archimedes ability to 
  4603. enter character codes greater than 128. You do this by holding down CTRL
  4604. and SHIFT simultaneously and then whilst still holding them down press
  4605. ALT. Next release all keys and press any character sequence like CTRL A or
  4606. SHIFT A. The second keypress will have 128 added to it. By prefixing it
  4607. with FN, you add &100=256. The Home key produces code 30. 
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.  
  4625.  
  4626.  
  4627.  
  4628.  
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.  
  4636.  
  4637.  
  4638.  
  4639.  
  4640.  
  4641.      73
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.                                                                     74
  4685.  
  4686.  
  4687.  
  4688.                                 Appendix F
  4689.  
  4690.                                 Mode Flags
  4691.  
  4692.  
  4693.              The two environment variables, $cmode and $gmode, contain
  4694.      a number the corresponds to the modes set for the  current buffer
  4695.      and  the editor as a whole.  These are encoded as the sum of  the
  4696.      following numbers for each of the possible modes:
  4697.  
  4698.      WRAP      1             Word wrap
  4699.      CMODE     2             C indentation and fence match
  4700.      SPELL     4             Interactive spell checking (Not Implemented Yet)
  4701.      EXACT     8             Exact matching for searches
  4702.      VIEW     16             Read-only buffer
  4703.      OVER     32             Overwrite mode
  4704.      MAGIC    64             Regular expressions in search
  4705.      CRYPT   128             Encrytion mode active
  4706.      ASAVE   256             Auto-save mode
  4707.  
  4708.              So,  if  you  wished  to  set the current buffer to  have
  4709.      CMODE, EXACT, and MAGIC on, and all the others off, you would add
  4710.      up the values for those three, CMODE 2  +  EXACT 8  +  MAGIC 64 =
  4711.      74, and use a statement like:
  4712.  
  4713.              set $cmode 74
  4714.  
  4715.              or, use the  binary  or operator to combine the different
  4716.      modes:
  4717.  
  4718.              set $cmode &bor &bor 2 8 64
  4719.  
  4720.      Internal Flags
  4721.  
  4722.              Some of the ways EMACS  controls  its  internal functions
  4723.      can be modified by the value in the $gflags environment variable.
  4724.      Each bit in  this  variable  will  be used to control a different
  4725.      function.
  4726.  
  4727.      GFFLAG          1       If this bit is set to zero, EMACS will not
  4728.                              automatically switch to the buffer of the
  4729.                              first file after executing the startup macros.
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.                                                                     76
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.      Index                                 ARC EMACS Reference Manual
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.                                      Index
  4755.  
  4756.  
  4757.              .emacsrc 57                 delete-mode 27
  4758.              <NL> 14                     delete-next-
  4759.                                               character 9
  4760.              A                           delete-next-word 9
  4761.              add-global-mode 27          delete-previous-
  4762.              add-mode 3, 27                   character 8
  4763.              ASAVE mode 27               delete-previous-word
  4764.                                               9
  4765.              B                           detab-line 38
  4766.              backward-character 4
  4767.              BBS 58                      E
  4768.              begin-macro 43              emacs.rc 57
  4769.              beginning-of-file 4,        encryption 28
  4770.                   9                      end-macro 43
  4771.              beginning-of-line 4         end-of-file 4
  4772.              buffer 5, 7, 24             end-of-line 4
  4773.                                          entab-lines 38
  4774.              C                           error parsing 57
  4775.              case-region-lower 37        EXACT mode 29
  4776.              case-word-capitalize        execute-buffer 45
  4777.                   37                     execute-file 45
  4778.              case-word-lower 37          execute-macro 43
  4779.              case-word-upper 37          execute-macro-<n> 45
  4780.              change-screen-size          execute-procedure 45
  4781.                   74                     execute-program 40
  4782.              change-screen-width         exit-emacs 9
  4783.                   74
  4784.              CMODE mode 28               F
  4785.              color 27                    file locking 75
  4786.              command.com 40              fill-paragraph 8, 36
  4787.              command line 18             fill column 31
  4788.              command processor 40        filter 40
  4789.              control-x 1                 find-file 19, 24
  4790.              control key 1               forward-character 4
  4791.              copy-region 12
  4792.              CRYPT mode 28, 58           G
  4793.              cshell 40                   grow-window 20
  4794.              cursor keys 4
  4795.                                          H
  4796.              D                           handle-tab 38
  4797.              default string 15           Help File 57
  4798.              delete-blank-lines 9        HOME environment
  4799.              delete-buffer 25                 variable 57
  4800.              delete-global-mode
  4801.                   27
  4802.  
  4803.  
  4804.      77
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.      ARC EMACS Reference Manual                                 Index
  4812.  
  4813.  
  4814.                                          refresh-screen 21
  4815.              I                           replace-string 16,
  4816.              i-shell 41                       30
  4817.                                          resize-window 20
  4818.              K                           restricted mode 58
  4819.              kill-region 11              run 45
  4820.              kill-to-end-of-line
  4821.                   9                      S
  4822.              kill buffer 12              save-file 5
  4823.                                          screen 7
  4824.              L                           scroll-next-down 19
  4825.              label-function-key          scroll-next-up 19
  4826.                   71                     search-forward 14
  4827.              list-buffers 25, 27         search-reverse 15
  4828.                                          select-buffer 24
  4829.              M                           set-encryption-key
  4830.              MAGIC mode 29                    28
  4831.              mark 11                     set-fill-column 36
  4832.              meta key 1                  set-mark 11
  4833.              mode line 2, 7              shell 40
  4834.              modes 3, 27                 shell-command 40
  4835.              move-window-down 19         shrink-window 20
  4836.              move-window-up 19           special keys 1
  4837.                                          split-window 18
  4838.              N                           startup files 57
  4839.              newline 1                   store-procedure 45
  4840.              next-buffer 24              suspend-emacs 41, 75
  4841.              next-line 4                 switches 57
  4842.              next-paragraph 4
  4843.                                          T
  4844.              O                           tab handling 38
  4845.              open-line 8                 termcap 75
  4846.              open-window 18              text window 2
  4847.              OVER mode 30
  4848.                                          V
  4849.              P                           VIEW mode 31
  4850.              PATH environment
  4851.                   variable 57            W
  4852.              pipe-command 40             window 7
  4853.              point 11                    windows 2, 18
  4854.              previous-line 4                Creating 18
  4855.              previous-paragraph 4           Deleting 19
  4856.              previous-window 18             Resizing 20
  4857.              previous-word 4             wrap-word 31
  4858.              procedures 45               WRAP mode 31
  4859.                                          wrapping text 36
  4860.              Q                           write-file 5
  4861.              query-replace 16
  4862.              query-replace-string        Y
  4863.                   16, 30                 yank 12
  4864.  
  4865.              R
  4866.              redraw-display 20
  4867.  
  4868.  
  4869.  
  4870.                                                                     78
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.                               Table of Contents
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.           Chapter 1  Basic Concepts                             1
  4890.              1.1  Keys and the Keyboard . . . . . . . . . . . . 1
  4891.              1.2  Getting Started . . . . . . . . . . . . . . . 1
  4892.              1.3  Parts and Pieces  . . . . . . . . . . . . . . 2
  4893.              1.4  Entering Text . . . . . . . . . . . . . . . . 3
  4894.              1.5  Basic cursor movement . . . . . . . . . . . . 3
  4895.              1.6  Saving your text  . . . . . . . . . . . . . . 5
  4896.  
  4897.           Chapter 2  Basic Editing--Simple Insertions and
  4898.              Deletions                                          7
  4899.              2.1  A Word About Windows, Buffers, Screens, and
  4900.              Modes  . . . . . . . . . . . . . . . . . . . . . . 7
  4901.              2.2  Insertions  . . . . . . . . . . . . . . . . . 8
  4902.              2.3  Deletions . . . . . . . . . . . . . . . . . . 8
  4903.  
  4904.           Chapter 3  Using Regions                             11
  4905.              3.1  Defining and Deleting a Region  . . . . . .  11
  4906.              3.2  Yanking a Region  . . . . . . . . . . . . .  12
  4907.  
  4908.           Chapter 4  Search and Replace                        14
  4909.              4.1  Forward Search  . . . . . . . . . . . . . .  14
  4910.              4.2  Exact Searches  . . . . . . . . . . . . . .  15
  4911.              4.3  Backward Search . . . . . . . . . . . . . .  15
  4912.              4.4  Searching and Replacing . . . . . . . . . .  15
  4913.              4.5  Query-Replace . . . . . . . . . . . . . . .  16
  4914.  
  4915.           Chapter 5  Windows                                   18
  4916.              5.1  Creating Windows  . . . . . . . . . . . . .  18
  4917.              5.2  Deleting Windows  . . . . . . . . . . . . .  19
  4918.              5.3  Resizing Windows  . . . . . . . . . . . . .  20
  4919.              5.4  Repositioning within a Window . . . . . . .  20
  4920.  
  4921.           Chapter 6  Buffers                                   24
  4922.  
  4923.           Chapter 7  Modes                                     27
  4924.              7.1  ASAVE mode  . . . . . . . . . . . . . . . .  27
  4925.              7.2  CMODE mode  . . . . . . . . . . . . . . . .  28
  4926.              7.3  CRYPT mode  . . . . . . . . . . . . . . . .  28
  4927.              7.4  EXACT mode  . . . . . . . . . . . . . . . .  29
  4928.              7.5  MAGIC mode  . . . . . . . . . . . . . . . .  29
  4929.              7.6  OVER mode . . . . . . . . . . . . . . . . .  30
  4930.              7.7  WRAP mode . . . . . . . . . . . . . . . . .  31
  4931.              7.8  VIEW mode . . . . . . . . . . . . . . . . .  31
  4932.  
  4933.  
  4934.  
  4935.  
  4936.                                      i
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.           Chapter 8  Files                                     33
  4947.  
  4948.           Chapter 9  Screen Formatting                         36
  4949.              9.1  Wrapping Text . . . . . . . . . . . . . . .  36
  4950.              9.2  Reformatting Paragraphs . . . . . . . . . .  36
  4951.              9.3  Changing Case . . . . . . . . . . . . . . .  37
  4952.              9.4  Tabs  . . . . . . . . . . . . . . . . . . .  37
  4953.  
  4954.           Chapter 10  Access to the Outside World              40
  4955.  
  4956.           Chapter 11  Keyboard Macros                          43
  4957.  
  4958.           Chapter 12  ARC EMACS Macros                        45
  4959.              12.1  Constants  . . . . . . . . . . . . . . . .  45
  4960.              12.2  Variables  . . . . . . . . . . . . . . . .  46
  4961.                 12.2.1  Environmental Variables . . . . . . .  47
  4962.                 12.2.2  User variables  . . . . . . . . . . .  49
  4963.                 12.2.3  Buffer Variables  . . . . . . . . . .  49
  4964.                 12.2.4  Interactive variables . . . . . . . .  50
  4965.              12.3  Functions  . . . . . . . . . . . . . . . .  50
  4966.              12.4  Directives . . . . . . . . . . . . . . . .  53
  4967.                 12.4.1  !ENDM Directive . . . . . . . . . . .  53
  4968.                 12.4.2  !FORCE Directive  . . . . . . . . . .  53
  4969.                 12.4.3  !IF, !ELSE, and !ENDIF Directives . .  54
  4970.                 12.4.4  !GOTO Directive . . . . . . . . . . .  54
  4971.                 12.4.5  !WHILE and !ENDWHILE Directives . . .  55
  4972.                 12.4.6  !BREAK Directive  . . . . . . . . . .  55
  4973.                 12.4.7  !RETURN Directive . . . . . . . . . .  56
  4974.  
  4975.           Appendix A  ARC EMACS Command Line Switches and
  4976.              Startup Files                                    57
  4977.  
  4978.           Appendix B  ARC EMACS commands                      59
  4979.  
  4980.           Appendix C  ARC EMACS Bindings                      65
  4981.  
  4982.           Appendix D  Supported machines                      67
  4983.  
  4984.       Appendix E  ARC details
  4985.  
  4986.           Appendix F  Mode Flags                              76
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.