简体   繁体   English

如何防止牙套在Emacs cperl模式下移动?

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

I'm using GNU Emacs 22.2.1 and cperl 5.23. 我正在使用GNU Emacs 22.2.1和cperl 5.23。

I have perl code like this: 我有这样的Perl代码:

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

I'd like to reindent the code to a 2-space indent. 我想将代码重新缩进2位缩进。 But when I run cperl-indent-region on this code, I get: 但是,当我在此代码上运行cperl-indent-region时,我得到:

sub foo
  {
    if ($x) {
      print "x";
    } else {
      print "y";
    }
  }
  1. How can I keep the outer brace at the left margin / column 0? 如何将外部支撑保持在左边缘/第0列?
  2. How can I prevent the opening brace for the if and else from moving up to the previous line? 如何防止if和else的开括号移至上一行?

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 Mx customize-group <ENTER> cperl <ENTER> . 您可以使用Mx customize-group <ENTER> cperl <ENTER> custom Mx customize-group <ENTER> cperl <ENTER>定义cperl模式。 The indentation variables are in the Cperl Indentation Details subgroup. 缩进变量位于“ Cperl缩进详细信息”子组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM