如何在 emacs cperl 模式下停止自动格式化?
当我在 cperl 模式下执行 indent-region 操作时,
if ($x) { next; }
Emacs 将其重新格式化为:
if ($x) { next; }
我怎样才能让它停止这样做?
注意:问题最初是说这种重新格式化是在猛拉时发生的。 我也将设置拉到缩进区域。
When I do indent-region in cperl-mode
if ($x) { next; }
Emacs reformats it to:
if ($x) { next; }
How can I make it stop doing that?
Note: the question originally said that this reformatting happens when yanking. I have yank setup to indent-region as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在 cperl 模式中找不到任何可以做到这一点的东西。 尝试在不进行任何自定义的情况下启动 emacs:
然后在 scratch 缓冲区中打开 cperl 模式:
粘贴您的文本; 它应该看起来像原来的(即全部在一行上)。 然后开始自定义 cperl 模式:
仅为当前会话单独设置每个变量,并尝试在每个设置之间粘贴。 如果您突然发现了所看到的行为,那么您就有了进一步观察的起点(可能是选项的组合)。
如果您对 cperl 进行了完全自定义,但它仍然没有表现“不正确”,那么您需要开始查看其他软件包可能导致它。 可能需要一段时间......
I can't find anything in cperl-mode that would do this. Try starting emacs with no customizations:
and then turn on cperl-mode in the scratch buffer:
Paste your text; it should look like the original (i.e. all on one line). Then start customizing cperl-mode:
setting each variable individually for the current session only, and trying the paste in between each setting. If you suddenly find the behavior you're seeing, you have a starting place to look further (it could be a combination of options).
If you get cperl fully customized and it still doesn't behave "incorrectly" then you need to start looking at what other packages could be causing it. It could take a while....
它对我来说不起作用,我只是在 Perl 菜单下的 Toggle... 子菜单中尝试了各种设置。 除了 Cperl 模式之外还有其他什么东西可以实现这一点吗?
It doesn't work that way for me, I just tried it with various settings in the Toggle... submenu under the Perl menu. Could there be something other than Cperl mode that's making that happen?
听起来不像是我在逃避答案,为什么不这样做呢?
相同的代码,相同的效果,并且同样可读(至少对我来说),但我敢打赌 emacs 不会尝试重新格式化它。
Without sounding like I'm giving a copout answer, why not just do this?
Same code, same effect, and just as readable (to me, at least), but I bet emacs won't try to reformat it.
假设您也不希望在键入此类代码时自动格式化,只需将
{}
的绑定更改为self-insert-command
而不是perl-电子终结者
。Assuming you don't want it to autoformat when you type that kind of code either, simply change the bindings of
{}
toself-insert-command
instead ofperl-electric-terminator
.