开发者

How do I keep braces from moving in Emacs cperl mode?

开发者 https://www.devze.com 2023-02-14 21:14 出处:网络
I\'m using GNU Emacs 22.2.1 and cperl 5.23. I have perl code like this: sub foo { if($x) { print \"x\"; } else

I'm using GNU Emacs 22.2.1 and cperl 5.23.

I have perl code like this:

sub foo
{
    if($x)
    {
      print "x";
    }
    else
    {
      print "y";
    }
}

I'd like to reindent the code to a 2-space indent. But when I run cperl-indent-region on this code, I get:

sub foo
  {
    if ($x) {
      print "x";
   开发者_StackOverflow社区 } else {
      print "y";
    }
  }
  1. How can I keep the outer brace at the left margin / column 0?
  2. How can I prevent the opening brace for the if and else from moving up to the previous line?


I believe the customization you're looking for is:

(setq cperl-extra-newline-before-brace t
      cperl-brace-offset              -2
      cperl-merge-trailing-else        nil)

You can customize cperl mode with M-x customize-group <ENTER> cperl <ENTER>. The indentation variables are in the Cperl Indentation Details subgroup.

0

精彩评论

暂无评论...
验证码 换一张
取 消