Here is an excerpt of my .emacs
CASE 1: With the config below, perl-completion mode works perfectly.
;;-------------------------------------------------------
;; -*-- CPerl mode
;;-------------------------------------------------------
(defalias 'perl-mode 'cperl-mode)
(add-to-list 'auto-mode-alist '("\\.[apP][Llm]$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.al$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.t$" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(defun my-cperl-hook-func()
(add-to-list 'load-path "~/.emacs.d/elpa/perl-completion-20090527.2336")
(require 'perl-completion)
(perl-completion-mode t)
;; (make-local-variable 'compile-command)
;; (setq compile-command
;; (concat "perl " (buffer-file-name)))
;; (cperl-define-key "\C-c\C-c" 'compile)
)
(add-hook 'cperl-mode-hook 'my-cperl-hook-func)
CASE 2: With the config below, C-c C-c in cperl-mode will successfully launch perl compilation.
;;-------------------------------------------------------
;; -*-- CPerl mode
;;-------------------------------------------------------
(defalias 'perl-mode 'cperl-mode)
(add-to-list 'auto-mode-alist '("\\.[apP][Llm]$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.al$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.t$" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(defun my-cperl-hook-func()
;; (add-to-list 'load-path "~/.emacs.d/elpa/perl-completion-20090527.2336")
;; (require 'perl-completion)
;; (perl-completion-mode t)
(make-local-variable 'compile-command)
(setq compile-command
(concat "perl " (buffer-file-name)))
(cperl-define-key "\C-c\C-c" 'compile)
)
(add-hook 'cperl-mode-hook 'my-cperl-hook-func)
CASE 3: However, with the code below to have both of perl-completion and C-c C-c to launch perl compilattion enabled by uncommenting all of lines in hook function (my-cperl-hook-func), it just ends up with that perl-completion would work fine while C-c C-c won't work at all (emacs says C-c C-c is undefined.)
How can I make both of actions valid in cperl-mode-hook?
;;-------------------------------------------------------
;; -*-- CPerl mode
;;-------------------------------------------------------
(defalias 'perl-mode 'cperl-mode)
(add-to-list 'auto-mode-alist '("\\.[apP][Llm]$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.al$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.t$" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(defun my-cperl-hook-func()
(add-to-list 'load-path "~/.emacs.d/elpa/perl-completion-20090527.2336")
(require 'perl-completion)
(perl-completion-mode t)
(make-local-variable 'compile-command)
(setq compile-command
(concat "perl " (buffer-file-name)))
(cperl-define-key "\C-c\C-c" 'compile)
)
(add-hook 'cperl-mode-hook 'my-cperl-hook-func)