Saltar ó contido principal

Detecting errors on flight with emacs

The “classic” editors like Emacs and VIM may seem a far surpased thing when nowadays IDEs like NetBeans or Eclipse can detect errors on the code without having to wait to manually compile it to find them (even though this happens mostly with Java, for some strange reason...), nevertheless the modularity of these editors allows to do this fairly simply.

Emacs includes by defaun a “minor-mode” named flymake which allows to do this but some configurations may be needed depending on the language, the Emacs wiki describes how to do i for a number of languages.

But, what if the language is not supported, like Flex or assembler? The solution is simply to write a Makefile with a check-syntax entry which runs the compiling/assembling command on the $(CHK_SOURCES) files, for example:

AS=nasm -g

    $(AS) $(CHK_SOURCES) -o /dev/null

When activating flymake-mode, it may disable itself automatically because it interprets
the file extension as not valid for it, can be added to the allowed list with

(push '("\\.<extensión>$" flymake-simple-make-init) flymake-allowed-file-name-masks)
;;; For example, for assambler files
(push '("\\.asm$" flymake-simple-make-init) flymake-allowed-file-name-masks)

And now assembly can be programmed with the realtime alerts of any IDE. Flymake over an assembler file