[erlang-patches] patch: emacs flymake support

Klas Johansson <>
Sun May 30 23:05:32 CEST 2010


On Fri, May 28, 2010 at 5:53 AM, Dave Peticolas <> wrote:
> On 05/27/2010 02:44 PM, Klas Johansson wrote:
>>>>>>
>>>>>> This patch adds (optional) support for flymake mode
>>>>>> (on-the-fly syntax checking) on Emacs, for UNIX systems.
>>>>>>
>>>>>> This work was originally submitted to the Erlware version
>>>>>> of the Emacs mode by Mats Cronqvist.
>>>>>>
>>
>> Hi,
>>
>> I took a different approach, which perhaps is of interest to
>> someone.  I'll post it here for the record.  This patch is a pure
>> elisp implementation and seems to work on linux, mac osx and
>> windows (provided that erlc is in the path).
>>
>>     ;; Syntax check erlang source code on the fly (integrates with
>> flymake).
>>     ;;
>>     ;; Start using flymake with erlang by putting the following somewhere
>>     ;; in your .emacs file:
>>     ;;
>>     ;;     (require 'erlang-flymake)
>>     ;;
>>     ;; Flymake is rather eager and does its syntax checks frequently by
>>     ;; default and if you are bothered by this, you might want to put the
>>     ;; following in your .emacs as well:
>>     ;;
>>     ;;     (erlang-flymake-only-on-save)
>>     ;;
>>     ;; There are a couple of variables which control the compilation
>> options:
>>     ;; * erlang-flymake-get-code-path-dirs-function
>>     ;; * erlang-flymake-get-include-dirs-function
>>     ;; * erlang-flymake-extra-opts
>>     ;;
>>     ;; This code is inspired by
>> http://www.emacswiki.org/emacs/FlymakeErlang.
>>
>> There are a few differences that I've spotted.  The previously
>> posted version adds include and code paths whereas mine are by
>> default empty (any takers? :-) ).  They are configurable though.
>> I've used this in a setting where include and code paths are
>> stated in a special file within the application.  I wrote
>> functions which produced lists of paths based on that file.  The
>> following variables can be set to point at such functions:
>>
>>   * erlang-flymake-get-code-path-dirs-function and
>>   * erlang-flymake-get-include-dirs-function
>>
>> The flags used to specify compiler warnings differ as well.
>> There's another variable that can be used to specify the options
>> one wants to use:
>>
>>   * erlang-flymake-extra-opts
>>
>>
>> Code here:
>>
>>     git fetch git://github.com/klajo/otp.git erlang-flymake
>>
>
> An all-elisp solution seems like an improvement over the patch I sent.
>
> What do you think about providing a default implementation of the include
> and code path functions that assume the typical directory layouts for otp
> apps?
> That way folks who use the standard layout don't have to add anything extra
> to their
> configs.
>
> dave

Hi again,

I've made a couple of additional commits:
* Include erlang-flymake.el in Makefile
* By default pass <app>/include and <app>/ebin to compiler
  (note, this covers only the "current" application, not all
   applications on the same level as in the other version,
   hopefully this makes the erlang-flymake more useful
   out-of-the-box)
* Make the syntax check command configurable
  (i.e. now you aren't restricted to erlc, you could for example
   use a wrapper script instead if you want to)
* Document in README

Code here:

   git fetch git://github.com/klajo/otp.git erlang-flymake


Cheers,
Klas


More information about the erlang-patches mailing list