;; Autoloading perltidy (autoload #'perltidy "perltidy" nil t) (autoload #'perltidy-mode "perltidy" nil t) (autoload #'perltidy-unless-readonly-mode "perltidy" nil t) (eval-after-load "cperl-mode" '(add-hook 'cperl-mode-hook #'perltidy-unless-readonly-mode)) (eval-after-load "perl-mode" '(add-hook 'perl-mode-hook #'perltidy-unless-readonly-mode)) ;; Autoloading perl-syntax (autoload #'perl-syntax "perl-syntax-mode" nil t) (autoload #'perl-syntax-region "perl-syntax-mode" nil t) (autoload #'perl-syntax-mode "perl-syntax-mode" nil t) (defalias 'perlsyntax-mode 'perl-syntax-mode) (eval-after-load "cperl-mode" '(add-hook 'cperl-mode-hook #'perl-syntax-mode)) (eval-after-load "perl-mode" '(add-hook 'perl-mode-hook #'perl-syntax-mode)) ;; Autoloading perlcritic (autoload 'perlcritic "perlcritic" "" t) (autoload 'perlcritic-region "perlcritic" "" t) (autoload 'perlcritic-mode "perlcritic" "" t) (eval-after-load "cperl-mode" '(add-hook 'cperl-mode-hook #'perlcritic-mode)) (eval-after-load "perl-mode" '(add-hook 'perl-mode-hook #'perlcritic-mode)) (defun perl-interpreter (&rest interpreter-else) (save-restriction (widen) (save-excursion (goto-char (point-min)) (if (looking-at auto-mode-interpreter-regexp) (match-string 2) (car interpreter-else))))) (defun perl (start end) "Runs the current region or buffer with perl" (interactive (if (if (boundp 'mark-active) mark-active (mark)) (list "r") (setq start (point-min)) (setq end (point-max)) (list "i"))) (shell-command-on-region start end (perl-interpreter "perl"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Parrots ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'pasm-mode "pasm-mode" nil t) (add-to-list 'auto-mode-alist '("\\.pasm" . pasm-mode)) (add-to-list 'interpreter-mode-alist (cons "pasm" 'pasm-mode)) (autoload 'pir-mode "pir-mode" nil t) (add-to-list 'auto-mode-alist '("\\.\\(imc\\|pir\\)" .pir-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Pod ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'pod-mode "pod-mode" nil t) (add-to-list 'auto-mode-alist '("\\.pod" . pod-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Associate cperl-mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'auto-mode-alist '("\\.[Pp][LlMm][Cc]?$" . cperl-mode)) (while (let ((orig (rassoc 'perl-mode auto-mode-alist))) (if orig (setcdr orig 'cperl-mode)))) (while (let ((orig (rassoc 'perl-mode interpreter-mode-alist))) (if orig (setcdr orig 'cperl-mode)))) (dolist (interpreter '("perl" "perl5" "miniperl")) (unless (assoc interpreter interpreter-mode-alist) (add-to-list 'interpreter-mode-alist (cons interpreter 'cperl-mode)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Associate pod-mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'auto-mode-alist '("\\.[Pp][Oo][Dd]$" . pod-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Autocomplete ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defadvice cperl-indent-command (around cperl-indent-or-complete) "Changes \\[cperl-indent-command] so it autocompletes when at the end of a word." (if (looking-at "\\>") (dabbrev-expand nil) ad-do-it)) (defun cperl-dabbrev-installer () (set (make-local-variable 'dabbrev-case-fold-search) nil) (set (make-local-variable 'dabbrev-case-replace) nil)) (eval-after-load "cperl-mode" '(progn (require 'dabbrev) (ad-activate 'cperl-indent-command) (add-hook 'cperl-mode-hook #'cperl-dabbrev-installer))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Prove ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun cperl-prove () "Run the current test." (interactive) (shell-command (concat "prove -v " (buffer-file-name)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Devel::Graph ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun devel-graph () (interactive) (shell-command-on-region (point-min) (point-max) "perl -MDevel::Graph -0777 -pe '$_=Devel::Graph->graph(\\$_)'")) (eval-after-load "cperl-mode" '(add-hook 'cperl-mode-hook (lambda () ;;(local-set-key "\C-cp" 'cperl-prove) ;;(local-set-key "\C-cdg" 'devel-graph) (local-set-key "\C-ctp" 'toggle-test-plan) ))) (defun toggle-test-plan () (interactive) (let ((new-pos)) (save-excursion (goto-char (point-min)) (cond ((re-search-forward "More[ \t]+tests[ \t]*=>[ \t]*" nil t) (replace-match "More 'no_plan'; # tests => " t t)) ((re-search-forward "More[ \t]+'no_plan';[ \t]*#[ \t]*" nil t) (replace-match "More " t t) (setq new-pos (point))))) (if new-pos (goto-char new-pos))))