ITeye博客

emacs中格式化perl代码

jedy · 2005-12-01 07:52 · Markdown

首先需要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
   )
  )

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。