Just a Theory

Black lives matter

Posts about Perltidy

How Do I Tweak Perltidy Method/Funtion-call blocks?

Say I have some icky code like this:

my $process = Background->new($^X, "-I$lib",
                            "-e 1", "other", "arguments", "here");

Perltidy will turn it into this:

my $process = Background->new( $^X, "-I$lib", "-MMyLong:Namespace::Bar::Bat",
    "-e 1", "other", "arguments", "here" );

That’s a little better, but I’d much rather that it made it look like this:

my $process = Background->new(
    $^X,    "-I$lib", "-MMyLong:Namespace::Bar::Bat",
    "-e 1", "other",  "arguments", "here",

Or even this:

my $process = Background->new(
    "-e 1",

Anyone know how to get it to do that? If so, please leave a comment!

Looking for the comments? Try the old layout.

Use Perltidy in Emacs

Here’s how I integrated Perltidy into Emacs. Based on some examples from the Emacs Wiki, as well as a bit of help on #emacs, I came up with this function:

    (defun perltidy ()
      "Run perltidy on the current region or buffer."
        (unless mark-active (mark-defun))
        (shell-command-on-region (point) (mark) "perltidy -q" nil t)))

    (global-set-key "\C-ct" 'perltidy)

With Perltidy installed and this function thrown into your *\~/.emacs* file, you can run perltidy on a region by just hitting C-C t. If no region is selected, it’ll run perltidy on the whole buffer.

Looking for the comments? Try the old layout.