Perhaps you aren't properly associating cperl-mode with your file. Here's some lisp-fu for you. The file is also available at http://diotalevi.isa-geek.net/~josh/emacs/my-cperl.el ;; 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))))
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|