首先需要
perltidy
#!perl.exe
# perltidy.pl
use Tidy;
Tidy::perltidy();
将下面这个函数加到emacs中
调用此函数,如果选择了region,就格式化region,否则格式化全文。
;; emacs
(defun wh-perl-format ()
(interactive)
(message "Formatting, please wait...")
(shell-command-on-region
(if mark-active (region-beginning) (point-min))
(if mark-active (region-end)(point-max))
(concat "perl c:/perltemp/finished/perltidy.pl -i=4 -nt -ci=2 -ce -pt=2 -l=100 -st ")
(current-buffer)
t
"*Messages*"
nil
)
)