After reading this thread, I hooked up a small Devel::Refactor script to emacs at the weekend. It works, but I haven't used it seriously, and I'm not convinced it provides a huge productivity leap
Anyway, here's how...
in your .emacs:
(defun refactor-extract ()
"Change region into a subroutine"
(shell-command-on-region (point) (mark) "./refactor-extract" t)
and some Perl in refactor-extract:
### Rewrite code block as a subroutine
# This is mostly intended to be used through emacs'
#(defun refactor-extract ()
# "Change region in to a subroutine"
# (shell-command-on-region (point) (mark) "./refactor-extract" t))
#Based on a Perlmonks node: http://www.perlmonks.org/?node_id=622772
use warnings FATAL => 'all';
my $code = join '', <>;
my $name = "refactored_" . sprintf( "%04d", rand() * 10000 );
print join "\n", Devel::Refactor->new->extract_subroutine( $name, $cod
This was a quick hack, quickly hacked. Use at your peril.