2

According to this question in order for Flymake to work you must add a special target to the makefile. I don't want to do this. Is there an alternative to Flymake that doesn'r require you to mess around with the makefiles?

Community
  • 1
  • 1
EpsilonVector
  • 3,973
  • 7
  • 38
  • 62
  • how do you want this alternative to know how to correctly syntax check your files? – jtahlborn Mar 19 '12 at 18:07
  • Automagically. The same way it works in true IDEs. It can use its own special makefile for example, stored in its own special folder outside of the repository. – EpsilonVector Mar 20 '12 at 17:00
  • 2
    It works in IDEs by using existing configuration. Flymake is a framework for running _something_ to check syntax. there is a pre-existing "something" which uses existing Makefiles with minor modifications. you could easily plugin your own script as that "something" and use your own custom configuration (see examples here: http://www.emacswiki.org/emacs/FlyMake ). – jtahlborn Mar 20 '12 at 19:23

1 Answers1

5

Not true.

You need not change the makefile in order to run flymake. As jtahlborn's comment said, flymake is a framework to run something when your buffer changes. It could be anything. You just need to tell flymake what to run.

For example, there's a program called csslint. It checks a CSS file and flags any warnings or non-standard usages. Lint for CSS. When I edit a css file (in css-mode) I want flymake to run CSSlint and show me the problems. This is how I do it.

(defun cheeso-flymake-css-init ()
  "the initialization fn for flymake for CSS"
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'cheeso-flymake-create-temp-intemp))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list (concat (getenv "windir") "\\system32\\cscript.exe")
          (list "c:\\users\\cheeso\\bin\\csslint-wsh.js" "--format=compiler" local-file))))

(defun cheeso-css-flymake-install ()
  "install flymake stuff for CSS files."
  (add-to-list
   'flymake-err-line-patterns
   (list css-csslint-error-pattern 1 2 3 4))

  (let* ((key "\\.css\\'")
         (cssentry (assoc key flymake-allowed-file-name-masks)))
    (if cssentry
        (setcdr cssentry '(cheeso-flymake-css-init))
      (add-to-list
       'flymake-allowed-file-name-masks
       (list key 'cheeso-flymake-css-init)))))


(eval-after-load "flymake"
  '(progn
     (cheeso-css-flymake-install)))

This runs a fn when flymake is loaded. The fn installs an entry in flymake's associative list for CSS files. The entry in that list tells flymake what command to run.

There's a little bit more to tell flymake how to parse the CSS lint error messages. But that's the general idea.

Cheeso
  • 189,189
  • 101
  • 473
  • 713