venerdì 25 gennaio 2013

Emacs Dataflex Mode

I have already written something about my idea of implementing an Emacs major mode to help the development of Dataflex applications.
In the last evenings I've worked on such idea and now the Dataflex mode is something concrete that is available for download from one of my GitHub repositories.

First of all, please consider that I'm no more a Dataflex developer, so I don't use this mode in day-by-day workflow, and therefore bug fixing
could take time. Second, I've written this mode to mainly get more experience in Emacs Lisp programming, and since this is my first major mode at all, it could contain several errors. As in the best Open Source tradition, help and comments are welcome!

So what does the Dataflex mode provides? The first thing is syntax highlighting: as shown by the following picture keywords are now
expressed using the Emacs font-locks, as well as parts of the masks (in particular the fields and mask delimiters). Of course the mode line of Emacs is updated to reflect the usage of the Dataflex mode for recognized files (usually .frm).
Then a few utility commands are builtin in the mode:

- C-c C-t provides the transpose of a single MOVE instruction or a whole group. The idea is that often you have to write a lot of statements like the following:

MOVE archive.field TO mask.field

and the opposite statement in order to save back the field from the mask to the archive as in:

MOVE mask.field TO archive.field

The transposition of the statement automatically converts the former in the latter and viceversa, so that it is possible to copy, paste and transpose an instruction without having to type any character. The
function can work on a single line or a whole region.

- C-c C-i indents the code. Well, there is not a defined way of indenting Dataflex code, so this function simply searches for a BEGIN/END like block and indents it recursively. It can operate on the whole buffer or on the specified section.

- M-; as for all the other programming modes, this allows for the definition of comments.

- C-c C-j jumps to a label. Often you read a piece of code that contains either a GOUSB or a GOTO instruction followed by a label. If the label is far in the code, but is in the same buffer, this command splits the current
window and jump to the label definition, so that the result is a quick  consultancy of the routine.

In order to install the mode into your Emacs download the lisp file into a suitable path, for instance into ~/.emacs.d and insert the following lines into your .emacs configuration file:

;; Dataflex mode
    'load-path "/path/to/the/directory/that/contains/the/lisp/file" )
(require 'dataflex-mode)

Please note that the mode automatically associates itself to files ending in .frm or .mac. The mode provides an hook called dataflex-mode-hook so that it is possible to customize further the mode behavior.

Finally, I posted a message on the DataAccess Forums about the mode.

Nessun commento: