ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

DM Macro

by alex-trueman ST3

Sublime Text 3 syntax definition, snippets, and commenting for Datamine macros

Details

Installs

  • Total 325
  • Win 278
  • Mac 30
  • Linux 17
Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29
Windows 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime Text 3 Customizations for Datamine Studio RM Macros

These customizations add a colour scheme, snippets, and commenting support to Sublime Text 3 for Datamine macros.

Installation

Use Package Control to install the latest version:

  1. Press Ctrl + ⇧ + P to open the command palette.
  2. Type Package Control: Install Package and press enter. Then search for DM Macro.

Once installed open a Datamine macro file with the '.mac' extension. Go to the View->Syntax->Open all with current extension as... menu and select dm-macro.

Syntax definition

The macro language syntax highlighting definition allows special highlighting of process names and their parameters, variables, and comments in Datamine macros. This scheme defines sub-schemes for language elements of EXTRA, LET, PICREC, and the DOS batch language. Certain errors such as incorrect variable, keyword, and file names are highlighted to help reduce bugs in macro code.

I have tested this scheme with the Material and the Monokai Pro colour schemes, other colour schemes may not work as well.

Snippets

Snippets are small pieces of code, mainly for Datamine macro processes. When you type the first letters of a Datamine keyword a prompt will appear at the cursor where you can select the snippet. Snippets are included for many processes with common options and defaults. These snippets are not exhaustive – I will add additional snippets to the repository as I need them.

Inserting a snippet

Compatibility

The snippets have only been tested in Sublime Text 3 (they should work in version 2 and also in TextMate). The snippets were originally designed to work with Datamine Studio 3 but are in the process of being transferred to Studio RM. As such there may be commands or command options that will not work in Studio 3.

Coding conventions

  • All snippets are in lowercase except where certain Datamine field names are used. Field names are in uppercase as per Datamine conventions (e.g., BHID, FROM, TO, XMORIG, XINC).
  • Because of the 80-character line length limit of Datamine macros the use of spaces (white space) in the snippets is minimized. No spaces are used if not strictly necessary for the code to be valid. The exception to this is a two-space indent for the second and subsequent lines of Datamine processes.
  • By default snippets contain the full set of parameters even when this makes no sense – it is up to the user to modify the code according to its application. Some verbose commands may have one or more alternative forms for specific application (e.g. the ESTIMA command is presented in a simpler form without the unfolding parameters). Other forms are also present for specific common tasks such as a SELCOP command for copying a drillhole file with the required drillhole fields included:
!selcop &in(),&out(),
  *f1(BHID),*f2(FROM),*f3(TO),*f4(LENGTH),
  *f5(X),*f6(Y),*f7(Z),*f8(A0),
  *f9(B0),*f10(),*f11(),*f12(),
  *f13(),*f14(),*f15(),*f16(),
  @keepall=0
  • Snippet place-holder variables are used for all parameters. Where a parameter has a default value in Datamine this default is present in in the place-holder. Sometimes the Datamine default is overridden if another default is more common (e.g., the Datamine default for COMPDH's MODE parameter is 0 but the snippet is defaulted to 1). The override of default values is purely based on my personal preference.
  • Some documentation of parameters is provided as a Datamine comment below the command. This is slowly being implemented for the more complicated commands:
!mgsort &in(),&out(),
  *key1(),*key2(),*key3(),*key4(),
  @order=1,@keyfrst=1,@roworder=1

# &in input file; &out sorted output file; *key1*...n any number of key
# fields for sorting; @order sort order (1: ascending; 2: decending);
# @keyfrst (0: output field in same order as input; 1: key fields first);
# @roworder (0: rows with identical keyfield in any order -- faster;
# 1: rows in input file order -- slowest).

Commenting support

With commenting support when you select lines in a macro and type Ctrl + / the lines will be commented with '#'. If the lines are already commented they will be un-commented.

Comment lines

My favourite Sublime Text settings (optional)

These are some of the setting I use in Sublime Text 3.

Fira has an excellent coding font that includes programming ligatures, now supported in Sublime Text 3. Go to the Fira Code website to install and then and the following to your Sublime Text settings file:

"font_face": "Fira Code Retina",

Assuming you have a HDI monitor, the following setting may improve the quality of text rendering on Windows machines:

"font_options":
  [
    "directwrite",
    "subpixel_antialias"
  ],

I am now using the excellent Monokai Pro theme and colour scheme (Filter Machine variant). Use package control to install this theme and colour scheme and then select it under Preferences->Package Settings->Theme - Monokai Pro->Select Theme. This process will install the following in your settings file:

"color_scheme": "Packages/Theme - Monokai Pro/Monokai Pro (Filter Machine).tmTheme",
"theme": "Monokai Pro (Filter Machine).sublime-theme",