views:

108

answers:

1

I edit my Perl scripts in Emacs, using CPerl mode. But the Emacs function indent-region is broken in that mode. If I have a variable:

my $num_elements;

it becomes

my $num_ elements;

It's very annoying, especially since I am used to using underscores in variable names, and I press the keyboard shortcut for indent-region all the time (actually, a custom indent-whole-buffer function based on it), it's already automatic.

Does anyone know how to fix it?

I am using this Emacs:

GNU Emacs 21.4.1 (x86_64-redhat-linux-gnu, X toolkit, Xaw3d scroll bars) 
  of 2007-12-10 on hs20-bc1-5.build.redhat.com

UPDATE: Actually this happens only after a foreach (or similar):

foreach my $num_elements (1,2) {}

becomes:

foreach my $num_ elements (1,2) {}
+5  A: 

Updated versions of cperl-mode are available. The official version and an unofficial version that's aware of 5.10 and Moose. Updating to one of those should fix your problem.

M-x describe-variable cperl-version will show what version of cperl-mode you're using.

Schwern
Thanks. I guess I'll have to install the latest version of cperl (although I probably won't since that sounds like an annoying thing to spend time on ...) BTW, my Emacs version does not have the command `describe-version`.
Sorry, `describe-variable`. Installing a new copy of cperl-mode is easy. In `~/.emacs` put `(add-to-list 'load-path "~/emacs")` and then put `cperl-mode.el` into `~/emacs`.
Schwern
Thanks! You convinced me, I installed cperl 5.14, and it's fixed now.
@dehmann 5.14 is 5 years old. Might as well use the latest else later on down the road you'll hit some other bug that's already been fixed.
Schwern