1 4/11/79 - Multics Emacs PL/I mode
  2 
  3 **This file is intended to be perused via dprint, print, or via an**
  4 **editor.  It is not intended to be perused with the help command **
  5 
  6 
  7 
  8 
  9 ^L
 10 PL/I mode provides an automatic assistance in PL/I progam formatting in the
 11 real-time editing context of Multics EMACS.  The basic facility provided at
 12 this time is that of lining up untyped PL/I statements, although on a
 13 one-for-one basis it will line up typed ones, too.
 14 
 15    Enter PL/I mode by issueing ESC-Xpl1-mode.  It will take a couple of
 16 seconds to "load itself".  When in PL/I mode, which shows up on the Mode line
 17 as "PL/I" as a major mode, the following non-default key bindings apply:
 18 
 19             TAB (^I)    Indent this PL/I statement properly (if not yet
 20                         typed in, tab out to it; otherwise, readjust its
 21                         indentation properly).
 22             ESC-CR (ESC-^M)   Like CR and TAB.
 23             ESC-^C Compile buffer. Write this buffer to its default pathname
 24                     and compile it, using the compiler "pl1" and assuming
 25                     "-tb" for options. These may be changed with the
 26                     extended commands set-compiler and set-compile-options.
 27                     Highly effective in two-window mode.
 28                     (See fortran-mode.info for more on this).
 29             ESC-^D      Try to find a declaration for the entry-point whose
 30                         name is to the left of the cursor, and insert it.
 31                         There exists a library of such.
 32                         If the declaration is not in the library,
 33                         ESC-^D will attempt to figure it out from inbound
 34                         parameter descriptors in  an object segment
 35                         responding to that name.
 36                         error_table_$xxx can be declared by ESC-^D, too.
 37             ESC-^H (ESC-Backspace) Delete 5 columns of indentation.
 38                     Intended for undenting END's.
 39             ESC-^I (ESC-TAB) Add 5 columns of indentation.
 40                     Intended for asserting your own style.
 41             ^X^D   (Control X-Control D) Find next error. When used after
 42                     an ESC-^C, will search for errors and place the cursor
 43                     on them in the source.  Highly effective in two window
 44                     mode.  See fortran-mode.info for more information on
 45                     the compilation error facility.
 46             ^XC    (Control X-C) Start or end a comment. Text following
 47                     this will be set off as a comment. A second ^XC ends
 48                     the comment.
 49 
 50             All the standard commentation commands (ESC-;, etc.) do the PL/I
 51             thing.  Word commands (ESC-F, etc.) in PL/I mode buffers consider
 52             the dollar sign to be part of a word.
 53 
 54      The indentation rules which are followed are such:
 55 
 56            Any fragment of an incomplete statement gets lined up 5 after the
 57 start of that statement.  The statement after a DO or BEGIN gets indented 5
 58 times one less than the number of IF's in the DO or BEGIN.  In "inding style
 59 2", the statement after an END gets lined up 5 LESS than the END statement;
 60 the first statement in a program gets lined up at col.  11 (Multics
 61 reckoning).  OTHERWISE, each statement lines up with the previous one.
 62 
 63     There are two styles available; the default is 1, you can get 2 by saying
 64       ESC-Xopt pl1-inding-style 2 CR
 65 
 66 (i.e., it is managed by the EMACS option mechanism).
 67 
 68  In style 1, you get;
 69 
 70       if x = 6 then do;
 71             bar = 5;
 72             foo = 6;
 73       end;
 74 
 75 In style 1, you are expected to line the END up yourself (use ESC-^H) because
 76 it is impossible in realtime to predict that an untyped statement is going to
 77 be an END.  You must undent the end yourself, because the next statement will
 78 line up with it.
 79 
 80   In style 2 you get
 81 
 82       if x = 6 then do;
 83           bar = 5;
 84           foo = 4;
 85           end;
 86      next = 17;
 87 
 88 Obviously, emacs is happier with this, because it can figure out the next
 89 statement after the END once you have typed it.
 90 
 91     There are no known bugs in the mode's PL/I parsing:  it pretentiously
 92 claims to be able to parse any legal PL/I statement, with the following
 93 exception:  Multi-dimensional label constants not supported (not a big
 94 problem, multics PL/I doesnt support them either).
 95 
 96     There is also a minor mode called "electric PL/I mode", which can be
 97 obtained by ESC-Xelectric-modeCR once in PL/I mode, or ESC-X electric-pl1-mode
 98 CR.  To get it by default as your mode for PL/I programs, put the statement
 99 
100           (defprop pl1 electric-pl1-mode suffix-mode)
101 
102 in your start_up.emacs.  Some users have found electric PL/I mode overly
103 violent, so it remains an option.  It connects semicolon to a function which
104 automatically indents for the next statement after inserting a semicolon;  use
105 \;  to get a semi in without the electric action.  Also, this action is
106 suppressed if there is a next line, and it is not empty.  The "electric
107 semicolon" also moves "end"'s back for you (in inding-style 1), when you type
108 the ";" of the "end" statement.  (Be careful to "\" ;'s in strings, there are
109 problems there).  Electric PL/I mode also gives ":" electric action, i.e.,
110 indenting after labels.