Racket flymake-mode for emacs

491 views Asked by At

Is it possible to make flymake-mode be aware of syntax (or other) errors in racket files like it done for example for erlang or python? I'm using geiser-mode for racket, if it is matters.

1

There are 1 answers

0
Eli Barzilay On BEST ANSWER

It's probably very easy, since Racket spits out warning messages in a standard line:column format.

You don't even need to invoke the compiler -- it's enough to just run the code via racket the-file. But as a semi-side-note, an even better command-line to use is racket -qf the-file. The thing about running the code as above is that it will actually ... run it. More specifically, it loads the module definition and then invokes it. Using -f it will just load the definition but not invoke it and therefore the runtime is not executed. Note that this assumes that the file is one that has just a module, which is what you get for all files that start with a #lang.

Update: I tried it, and indeed it was easy to set things up. I've posted this code on the mailing list:

(defun flymake-racket-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "racket" (list "-qf" local-file))))
(push '("\\.rkt\\'" flymake-racket-init)
      flymake-allowed-file-name-masks)