Just a Theory

By David E. Wheeler

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."
      (interactive)
      (save-excursion
        (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.

More about…