Metapost Mode Help
Name: | Metapost Mode |
Version: | 3.1 |
Last update: | 2020-05-27 14:28:46 |
Introduction
MetapostMode is a mode for the text editor Alpha: it is designed to make
writing, processing and testing of Metapost source files much easier.
Metapost is the programming language written by John Hobby in order to
create all kinds of figures, graphs, pictures to include in a document
prepared with TeX or with Troff. Its syntax is very much like Metafont's
syntax but Metapost outputs are Postscript encapsulated files.
Once Metapost mode is installed, the opening of a Metapost source file (i-e
with extension .mp) invokes a new menu (called Metapost) in the menu bar
with the following features:
- easy insertion of all the basic Metapost commands (with electric stops):
macros from the mfplain, boxes and graph packages are also included.
- syntax coloring.
- file marking.
- capacity to process a source file from within Alpha with various flags,
printer modes, input mem files.
- editing the log and the mpx files.
- key bindings to choose the processing mode, to process files, open the
log or mpx etc
- advanced keywords completion
- command clicking on a word leads to its definition
- option clicking on the title bar of a window brings a list of .mp and .mpx
files at the same level.
Note that both CMacTeX Metapost and OzMetapost are supported.
MetapostMode is compatible with MetafontMode.
Description
Metapost menu items:
- Switch To Metapost
- Launches the Metapost application in front.
- Process Current Window
- Calls up the Metapost application and processes the current window.
- Process a File
- Prompts you for a Metapost source file to run.
Metapost Utilities submenu
- Open plain.mp
- Edit this file (read-only).
- Open mfplain.mp
- Edit this file (read-only).
- Open plain.mf
- Edit this file (read-only).
- Open modes.mf
- Edit this file (read-only).
- New Figs File Template
- Builds a template for a complete new figures source file. User is asked for
the number of figures in the file. They are numbered automatically.
- Delete Auxiliary Files...
- Prompts you to specify the extensions of auxiliary files to delete.
- Menu Shortcuts...
- Define custom shortcuts for the menu items.
- Display Bindings
- Display the bindings currently defined in Metafont mode
Metapost Editing submenus
All the following submenus contain the basic Metapost commands and
macros: any item you choose will be inserted in your file at the
cursor's current position with electric tabs for those commands which
need arguments. In some cases, you will be asked to enter a number
(see makegrid for instance). All the macros relevant to a particular
aspect have been collected together in a (supposedly) logical way.
When clicking on a submenu, try the option, command, control or shift
keys to get variants.
For instance:
- in the Labels... submenu, the label item will become:
- 'dotlabel' with the option key
- 'dotlabels' with the command key
- 'thelabel' with the shift key
In the case of 'dotlabels' you will be prompted to set the number of
arguments.
((li in the Graph.mp Macros... submenu, the setcoords item will
become: li))
- setcoords(lin,lin) with the option key
- setcoords(log,log) with the command key
- setcoords(lin,log) with the shift key
- setcoords(log,lin) with the control key
ul))
List of the macros submenus:
- Boolean
- Bounds
- Boxes
- Color
- Conditions
- Debugging
- Definitions
- Drawing
- Figures
- Functions
- Graphs
- Internals
- Labels
- Miscellaneous
- Paths
- Pens
- Pictures
- Positioning
- Transformations
- Variables
Macros from additionnal packages:
- Mfplain.mp Macros
- Graph.mp Macros
- Boxes.mp Macros
File marking
Various elements are marked: macros definitions, character definitions,
related files, input files etc. and can be easily accessed through pop-up
menus and option or commed clicking.
The Mark pop-up menu
If you choose to mark your file from the Marks pop-up menu (top right of your
editing window), all the def, vardef and beginfig declarations in your
source file will be marked. Remember that the beginfig command is
customizable (in the Mode Setup) and any change you make there will be
taken into account for marking.
If the Auto Mark checkbox is checked in the Prefs, the file is
automatically marked at opening.
The Functions pop-up menu
The Functions pop-up menu (top right of your editing window) contains the
functions and macros defined in your source file. We list here all the def,
primarydef, secondarydef, tertiarydef and vardef definitions as well as the
files input with an input command.
Shift-Command double clicking a word
If you Shift-Command-Double-Click on a keyword you access its definition. This
procedure looks first for a definition in the current file itself, then in
the list of primitives, then in all the Metapost macros files (boxes.mp,
mfplain.mp, plain.mp etc. Note that plain.mp is scanned first) and finally
in the other .mp text files called in the current file by an 'input'
command and located at the same level (typically they are user defined
macros files).
Option clicking the title bar
If you Option-Click in the title bar, you get a list of all the .mp
or .mpx files located in the folder of your current window.
Selecting any item in this list will open it in a window or bring its
window to front if it is already open.
Completions
Metapost Mode has a rich set of completion procedures:
- First we have a set abbreviations and contractions. Just type the
following abbreviations and hit the completion key to have them
expanded to the entire word or to a complete template:
Abbreviation | Description |
bf | beginfig endfig |
bg | begingroup endgroup |
bt | btex etex |
for | for endfor; |
def | def enddef; |
prim | primarydef enddef; |
sec | secondarydef enddef; |
ter | tertiarydef enddef; |
vardef | vardef enddef; |
forever | forever endfor; |
forsuffixes | forsuffixes endfor; |
if | if fi |
Contraction | Description |
c'n | currentpen |
c'p | currentpicture |
d'p | directionpoint |
d't | directiontime |
r'a | reflectedabout |
r'a | rotatedaround |
x'b | extra_beginfig |
x'e | extra_endfig |
i'p | intersectionpoint |
i't | intersectiontimes |
- You can also type the first letters of a word and hit the completion
key. If it is recognized as a keyword, it will be completed. If there are
different possible completions, they will be listed in the status bar: hit
the completion key again and you will have a list of all the possibilities
from which you can select the one you want.
- With 'input' instructions: type 'input xx' and the proc will look
for a known mp base file whose name starts with 'xx'.
Key Bindings
A few key bindings are defined in Metapost mode. Use the command Mp ↣ Metapost Utilities ↣ Display Bindings to
display them.
Metapost mode preferences
If the current window is in Metapost mode, select the command Alpha ↣ Mode Setup ↣ Mode Preferences… to display the Mp Mode Preferences. They should be self-explanatory.
Here is the meaning of some of them:
- the
Path To Mfplain Mp File,
Path To Modes Mf File,
Path To Plain Mf File,
Path To Plain Mp File and
Path To Plain Mp File
preferences define the paths of several base files.
They are used by the Shift-Command-Double-Click procedure.
- User beginfig: it is customary in Metapost's font files to modify
the definition of the beginfig/endfig routine and to give it a different
name: for instance beginmyfig/endmyfig or whatever. You can specify
here this modified name in order to get a correct file marking from the
Marks pop-up menu on the top right corner of the current window.
Known problems
Please report any problem or bug you encounter to
Alpha's Bug Tracker.
License and Disclaimer
Copyright (c) 2000-2020, Bernard Desgraupes.
All rights reserved.
The Metapost Mode package is free software and distributed under
the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Bernard Desgraupes nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERNARD DESGRAUPES BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.