Skip to content
jrockway edited this page Sep 13, 2010 · 19 revisions

Here’s what my Perl support looks like right now:

    (define-project-type perl (generic)
      (or (look-for "Makefile.PL") (look-for "Build.PL"))
      :relevant-files ("\\.pm$" "\\.t$" "\\.pl$" "\\.PL$")
      :is-mxdeclare-project (lambda (root)
                              (file-exists-p (concat root ".mxdeclare_project")))
      :main-file "Makefile.PL")

    (defun cperl-mxdeclare-project-p ()
      "Determine if this project should use MooseX::Declare class definitions."
      (ignore-errors
        (eproject-attribute :is-mxdeclare-project)))

I use the cperl-mxdelcare-project-p predicate in my auto-inserts to automatically generate the right code. (“use Moose” if it’s not MX::Declare, “class Foo” if it is.) Before eproject, I manually searched for the project root and the .mxdeclare_project file; now this is all handled for me. I could also write :is-mxdeclare-project t in a .eproject file, but I do it this way for compatibility with my other .emacs code.

It’s important to note that the lambda is only evaluated when the first project file is opened. If you want it to update after you add or delete the .mxdeclare_project file, go to a project buffer and say M-x eproject-reinitialize-project.

Clone this wiki locally