2

If I get emacs 24.1.1 to indent the following

$config = {
    b  => [
           "123",
           ],
    c => "123",
    };

then it will turn it into

$config = {
    b  => [
           "123",
           ],
        c => "123",
    };

Question

Why does it not indent so b and c is aligned?

Update

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption                                   
File-Name-Shadow Font-Lock Global-Font-Lock Line-Number Menu-Bar                                         
Transient-Mark                                                                                           

(Information about these minor modes follows the major mode info.)

Perl mode defined in `perl-mode.el':
Major mode for editing Perl code.
Jasmine Lognnes
  • 6,597
  • 9
  • 38
  • 58

2 Answers2

3

Because the indentation algorithm did not understand this case.

I have just installed a patch to perl-mode.el (in Emacs's trunk, i.e. won't be in the upcoming Emacs-24.4 but only in Emacs-24.5) which seems to fix it. You can try the new code at http://bzr.savannah.gnu.org/lh/emacs/trunk/annotate/head:/lisp/progmodes/perl-mode.el.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • If I add that file to one of the search paths, then perl mode is disabled. Do I need to do something besides adding the `perl-mode.el`? – Jasmine Lognnes Jul 09 '14 at 10:36
  • 1
    No, that should be it. What happens if you `M-x load-file RET ..the/new/perl-mode.el RET`? – Stefan Jul 09 '14 at 13:31
  • That worked =) How do I add it to my `.emacs` so it is loaded correct? – Jasmine Lognnes Jul 10 '14 at 11:38
  • 1
    Hmm.. don't know why just putting the file in the search path disables the mode while loading it explicitly works fine. The simplest is probably to `(load "../the/new/perkl-mode.el")`. Otherwise, try to ask for debugging help on gnu.emacs.help (which tends to work better for that than stackoverflow). – Stefan Jul 10 '14 at 14:55
2

The solution is to use cperl-mode instead of perl-mode: put

(fset 'perl-mode 'cperl-mode)

in your .emacs.

sds
  • 58,617
  • 29
  • 161
  • 278
  • This works, but also changes how indentation is done on `b`. Before `b` were at column 5 and after it is aligned with the `{`. Can that be avoided? – Jasmine Lognnes Jul 09 '14 at 10:35