mmccoo
mmccoo

Reputation: 8536

How do I stop auto-formatting in emacs cperl mode?

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.

Upvotes: 1

Views: 1125

Answers (5)

mmccoo
mmccoo

Reputation: 8536

(setq cperl-break-one-line-blocks-when-indent nil)

Upvotes: 5

Chris Lutz
Chris Lutz

Reputation: 75439

Without sounding like I'm giving a copout answer, why not just do this?

next if $x;

Same code, same effect, and just as readable (to me, at least), but I bet emacs won't try to reformat it.

Upvotes: 0

Joe Casadonte
Joe Casadonte

Reputation: 16869

I can't find anything in cperl-mode that would do this. Try starting emacs with no customizations:

$ emacs -q

and then turn on cperl-mode in the scratch buffer:

M-x cperl-mode

Paste your text; it should look like the original (i.e. all on one line). Then start customizing cperl-mode:

M-x customize-group<RET>cperl<RET>

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....

Upvotes: 2

Charlie Martin
Charlie Martin

Reputation: 112404

Assuming you don't want it to autoformat when you type that kind of code either, simply change the bindings of {} to self-insert-command instead of perl-electric-terminator.

Upvotes: 2

Nathan
Nathan

Reputation: 3920

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?

Upvotes: 0

Related Questions