Building notes, projects, and occasional rants

tidyall: TextMate command, and other tidbits

I've started using Jonathan Swartz excellent tidyall for all my tidy needs. This is TextMate command that I use to replace the Tidy command distributed with the Perl bundle.

require_cmd tidyall 'Requires tidyall, install from CPAN'

### Have a default tidyall.ini on your home, override per project
for ini in tidyall.ini .tidyall.ini ; do
  if [ -e "${TM_PROJECT_DIRECTORY}/${ini}" ] ; then

## Override target file if the current scope is perl: useful when
## tidying a selection of perl code inside a Mason document
if [ "${TM_SCOPE:0:11}" == "source.perl" ] ; then

tidyall --root "$TM_PROJECT_DIRECTORY" \
        --conf-file "${config}"        \
        --pipe "$target"

To use it, create a new command in your own personal bundle, and set:

  • Save: Nothing;
  • Command(s): the above code;
  • Input: Selected Text or Document
  • Output: Replace Selected Text
  • Activation: Key Equivalent Ctrl+Shift+H (the same as Tidy);
  • Source: source.perl, comment.documentation.perl

The last one, Source, you should also add other scopes that your tidyall config covers.

My current tidyall.ini is this:

select = **/*.{pl,pm,t}

argv = --column=100
select = **/*.{pm,pod}

select = **/*.pm

select = **/*.{pl,pm,t}

select = **/*.{mc,mi,html}
select = **/{autohandler,dhandler}

The MasonTidy section is still new to me, I'm not sure if I like it or not. The rest is very good, specially the clean integration to tidy Method::Signatures declarations provided by the Perl::IgnoreMethodSignaturesSimple plugin.

Although this plugin targets the Method::Signatures::Simple, I'm using it with Method::Signatures, my preferred version of the concept, without problems

I've also used the recent git pre-commit hooks code for a bit, but I'm having problems with it and haven't had the time to really look into it. The code stashes stuff that is not in the index before running, to make sure it is only tidying the parts you are going to commit, and then pops the rest from the stash. This last part causes me a lot of merge failures.

If you don't use hunk or line-based commit building, you should be fine though.