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/MyApp.pm, flymake will create (and delete) a
MyApp/lib/MyApp_flymake.pm. 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:
(defun flymake-perl-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
(list "-MProject::Libs" "-wc" local-file)))
You can change the perl path to just be
/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.
(defun flymake-create-temp-intemp (file-name prefix)
"Return file name in temporary directory for checking
FILE-NAME. This is a replacement for
`flymake-create-temp-inplace'. The difference is that it gives
a file name in `temporary-file-directory' instead of the same
directory as FILE-NAME.
For the use of PREFIX see that function.
Note that not making the temporary file in another directory
\(like here) will not if the file you are checking depends on
relative paths to other files \(for the type of checks flymake
(unless (stringp file-name)
(error "Invalid file-name"))
(setq prefix "flymake"))
(let* ((name (concat
(ext (concat "." (file-name-extension file-name)))
(temp-name (make-temp-file name nil ext))
(flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name)
This is the bit from the Emacs Wiki (thanks, whoever wrote this!). It tells flymake to make its files in a temp directory.
(setq temporary-file-directory "~/.emacs.d/tmp/")
You can set this to whatever you want. And poof, flymake is no longer making the Catalyst Restarter work so hard.