Flymake Versus the Catalyst Restarter

I recently started using flymake-mode in emacs, which does a “make on the fly” for the buffer you’re currently editing. For Perl, that basically means checking the code by running perl -c on it. If it sees any errors or warnings, it highlights this in the buffer. This is pretty handy for catching typos, although I’ve seen some weird false positive. Anyway, it’s a great tool, except that it does its checking by creating a file in the same directory as the one you’re editing. So if you’re editing MyApp/lib/, flymake will create (and delete) a MyApp/lib/ Catalyst’s Restarter watches the lib directory for file changes, and restarted the dev server on each change. Combined with flymake, this means a lot of useless restarting. Fortunately, it’s easy enough to get flymake to create its files elsewhere. Here’s a snippet that includes some code off the FlymakeRuby page on the Emacs Wiki:

You can change the perl path to just be

perl or /usr/bin/perl. Obviously, I’m using perlbrew. I got most of this bit from Damien Krotkine’s post on perlbrew and flymake, but I replaced the use of “flymake-create-temp-inplace” with “flymake-create-temp-intemp”, defined below.

This is the bit from the Emacs Wiki (thanks, whoever wrote this!). It tells flymake to make its files in a temp directory.

You can set this to whatever you want. And poof, flymake is no longer making the Catalyst Restarter work so hard.

Updated on

5 thoughts on “Flymake Versus the Catalyst Restarter

  1. I stopped using Flymake because I’m using local::lib heavily, and flymake kept throwing errors about not finding libraries in @INC, sadly ignoring those in ~/perl5/lib. I take it this workaround is for the binary, not the libs, so it might not resolve my issue.

  2. @Eretz: The last line of the first chunk constructs the arguments passed to the Perl binary. You could change that to be smarter.

    You might also consider just changing your PERL5LIB env var to include your local libs.

  3. Have a look at Project::Libs, it also helps putting local libs in @INC on the fly

  4. @dams: I was actually having the same problems that Erez having, even with Project::Libs. I’ve since disabled flymake, but I plan to go back and figure out the problem at some point.

  5. Okay, I think I’ve finally got something based on Dave’s code above that works for me. Assumes use of Git in order to find a base project directory, and assumes libraries are found in $BASE/lib:

Comments are closed.