Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Emacs and perltidy-mode

by diotalevi (Canon)
on Aug 17, 2007 at 22:50 UTC ( #633406=note: print w/replies, xml ) Need Help??

in reply to Emacs and perltidy-mode

Perhaps you aren't properly associating cperl-mode with your file. Here's some lisp-fu for you. The file is also available at

;; 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-u +nless-readonly-mode)) (eval-after-load "perl-mode" '(add-hook 'perl-mode-hook #'perltidy-u +nless-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-synta +x-mode)) (eval-after-load "perl-mode" '(add-hook 'perl-mode-hook #'perl-synta +x-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 en +d 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::G +raph->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]*" ni +l t) (replace-match "More " t t) (setq new-pos (point))))) (if new-pos (goto-char new-pos))))

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633406]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2017-03-25 16:10 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (311 votes). Check out past polls.