An automatic feature of Emacs Speaks NONMEM is code-alignment and wrapping.
Emacs Speaks NONMEM aligns records based on the record name, and record type
Record Indentation
By default a record is a hanging indent with a variable number of spaces based
on how many characters are record itself. For example an $INPUT record may be
aligned differently based on if the record specification is $INPUT or $INP. For
$INPUT the hanging indent is 7 characters:
$INPUT ID NUM DV TIME CMT CRCL WTKG RACE RIMP SEXF LBW IBW BSA SMOK TBIL ALT AST
For $INP the hanging indent is 5 characters:
$INP ID NUM DV TIME CMT CRCL WTKG RACE RIMP SEXF LBW IBW BSA SMOK TBIL ALT AST
In addition there are records who do not follow this procedure (like $PK) — they are
automatically indented to 2 characters. Which records are only indented to two
characters may be customized by the following menu:
- Automation
- Changes While Editing
- Alignment Options
- Customize records not indented to record-length
- Alignment Options
- Changes While Editing
There are also records that are not indented at all — by default the $TABLE
record. Which records are not indented may be changed in
- Automation
- Changes While Editing
- Alignment Options
- Customize records with no indentation
- Alignment Options
- Changes While Editing
Overall, this automatic record indentation may be toggled at:
- Automation
- Changes While Editing
- Automatically indent
- Changes While Editing
$THETA/$OMEGA/$SIGMA alignment
Another option that Emacs Speaks NONMEM supports is the alignment of $THETA,
$OMEGA, and $SIGMA records. In addition to the standard hanging indent, the
estimates are aligned by commas and semi-colons add continuity to the display of
the estimates.
For example, the $THETA record may be aligned as:
$THETA (0, 30) ; 1 - Cl (L/hr) (0, 40) ; 2 - Vc (L) (-200, 0.1, 200) ; 3 - Cov1 (L)
The numbers are aligned in a column-like fashion. The estimates themselves are also aligned in a similar fashion.
Estimates for $OMEGA and $SIGMA records, are aligned at the "." point whether
present or assumed. For example
$OMEGA BLOCK(4) 0 ; 1 - BSV_Var1 .0002 4 ; 2 - BSV_Var2 20000 400. 3 ; 3 - BSV_Var3 2 .0003 4 5 ; 4 - BSV_var4
This may be toggled at:
- Automation
- Changes While Editing
- Align THETA,OMEGA & SIGMA
- Changes While Editing
$PK/$DES/$AES alignment
For code-based sections, indentation rules are automatically applied. The
comments are aligned, the code itself is aligned at the = sign (for the current
indentation level), and appropriate blocks (like IF ... THEN, ENDIF) are
indented, all without much user intervention. An example of this is the $PK
block:
$PK TVCL = THETA(1) ; Clearance (Population) IF (RACE.EQ.1) THEN TVCL = TVCL + THETA(2) ; Shift for Race 1. ENDIF CL = TVCL*DEXP(ETA(1)) ; Individual Clearance
Note that the alignment is based on the level of the variable, with the
exception of IF statements, for example:
$PK TVCL = THETA(1) ; Clearance (Population) IF (RACE.EQ.1) TVCL = TVCL + THETA(2) ; Shift for Race 1. CL = TVCL*DEXP(ETA(1)) ; Individual Clearance
Does not change the alignment, but a long variable changes the alignment:
$PK TVCL = THETA(1) THISISLONG = THETA(2) CL = TVCL*DEXP(ETA(1))
This automatic alignment of equal signs and alignments may be toggled with the menu:
- Automation
- Changes While Editing
- Align Code at = and comments
- Changes While Editing
When disabled, Emacs Speaks NONMEM only indents the blocks of code.
Wrapping
One of the possible features of NONMEM is to automatically wrap NONMEM code at
the 80 character mark. As an example the following $INPUT record has been typed.
$INPUT ID NUM DV TIME CMT CRCL WTKG RACE RIMP SEXF LBW IBW BSA SMOK TBIL ALT
When automatic indentation is enabled, typing AST at the of the $INPUT field
gives the following automatic wrapping and indentation:
$INPUT ID NUM DV TIME CMT CRCL WTKG RACE RIMP SEXF LBW IBW BSA SMOK TBIL ALT AST
When automatic indentation is disabled, typing AST at the end of the $INPUT
field wraps, but does not indent, as follows:
$INPUT ID NUM DV TIME CMT CRCL WTKG RACE RIMP SEXF LBW IBW BSA SMOK TBIL ALT AST
Wrapping may be toggled at:
- Automation
- Changes While Editing
- Automatic Wrapping of Records
- Changes While Editing
Some records are not wrapped by default (for example the $PK record). Which
records may be customized in Emacs speaks NONMEM by the following menu:
- Automation
- Changes While Editing
- Customize records not wrapped
- Changes While Editing
