I am trying to associate CPerl mode with Perl source files in emacs (23.1.1 on CentOS 6).
If I include the following line in my .emacs
(defalias 'perl-mode 'cperl-mode)
then CPerl mode will be loaded when a Perl source file is opened.
However, the following line, which seems like ti should work, results in Perl mode being loaded instead:
(add-to-list 'auto-mode-alist '("\\.p[lm]$" . cperl-mode))
There's no error message - it just loads Perl mode instead of CPerl mode.
The reason I'm asking is that I've had some issues using cperl-set-style (works from the emacs menu but not if I add it as a hook to the CPerl mode when it's been aliased to perl-mode) and I wanted to try loading CPerl mode directly.
The statement I'm using in my .emacs to set the indenting style as a hook to CPerl mode is
(eval-after-load "cperl-mode"
add-hook 'cperl-mode-hook (lambda() (cperl-set-style 'C++))))
This obviously has no effect if CPerl mode is not loaded (when I use the auto-mode-alist approach) and does not do the right thing (seems to use GNU indent style) when I load CPerl mode by aliasing it to Perl mode.
You need to use
(cperl-set-style "C++")
instead of(cperl-set-style 'C++)
. If you look at the variablecperl-style-alist
(e.g. with C-hv) then you will see that thecar
's consist of strings rather than symbols. It seems unfortunate that your example failed silently rather than raising an error. Most of the time I would want to know that I tried to choose a non-existant style, but there's probably a good reason for it to be the way it is.