*.tのときはmode-compileでperlじゃなくてproveを実行したい

インスパイア: unwind-protect: Emacs の中から prove

emacs-proveはそのまんまいただいて、~/.emacsにこんな感じで。(lisp 10級)

これでいつでもC-cC-cで、ファイル名を見て適宜perl -wかprove -vlを実行してくれます。

(autoload 'mode-compile "mode-compile"
  "Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-c\C-c" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
  "Command to kill a compilation launched by `mode-compile'" t)
(setq mode-compile-always-save-buffer-p t)
(setq mode-compile-never-edit-command-p t)
(setq mode-compile-reading-time 0)

(eval-after-load "mode-compile"
  '(progn
     (defun my-perl-compile ()
       (let* ((testfile-p (string-match "\\.t$" (buffer-name)) )
              (perl-command   (if testfile-p "emacs-prove" "perl"))
              (perl-dbg-flags (if testfile-p "-v"          "-w"  )))
         (mc--shell-compile perl-command perl-dbg-flags
                            perl-compilation-error-regexp-alist)))
     (setq mode-compile-modes-alist
           (append '((cperl-mode . (my-perl-compile kill-compilation))
                     (perl-mode  . (my-perl-compile kill-compilation)))
                   mode-compile-modes-alist))))