3

Starting with emacs -Q, I open a C file a.c and a Perl file a.pl. I turn on electric-pair-mode and electric-indent-mode in each.

In a.c, I enter the following, where the | shows the cursor position:

int foo() {
    if (bar) {|}
}

I press Enter and get:

int foo() {
    if (bar) {
        |
    }
}

Well and good. But in the Perl file, I start with:

sub foo {
    if (bar) {|}
}

Then I press Enter and get:

sub foo {
    if (bar) {
        |
}
}

No matter the level of indentation, the closing brace is placed at the beginning of the line it's on.

I could hack my way around this irritation, but is there a simple way to get the same indenting behavior in perl-mode that I see in c-mode?

Stefan
  • 26,154
  • 3
  • 46
  • 84
Sean
  • 929
  • 4
  • 13

1 Answers1

2

I think it's just a bug in perl-mode. The definition below should fix it:

(defun perl-electric-noindent-p (_char)
  (unless (or (bolp) (eolp)) 'no-indent))

Should be fixed in Emacs-26.

Stefan
  • 26,154
  • 3
  • 46
  • 84
  • It's still broken in my 26.0.50, but your fix works, so thanks! – Sean Oct 30 '17 at 17:35
  • 1
    I just pushed the fix this morning, so unless you rebuild from a freshly updated `emacs-26` branch you won't have it. – Stefan Oct 30 '17 at 18:34