d11wtq
d11wtq

Reputation: 35298

Emacs ruby-mode indenting customization for case..when and assignment from an if..else?

In Emacs, using ruby-mode, I can't find a way to stop this happening:

foo = if something?
        42
      else
        7
      end

When our in-house conventions are:

foo = if something?
  42
else
  7
end

(Same goes for begin..end and case..when).

Also, while it's less of a nuisance, our convention for case..when is to indent each when.

case whatever
  when foo
    "a"
  when bar
    "b"
  else
    "c"
end

I know people generally say you should align the when with the case, but it's not the convention of our company, so does anybody know how to customize this too? I can find very little customization for ruby-mode. The only thing I've really been able to customize is the indentation inside parentheses.

Upvotes: 3

Views: 732

Answers (2)

Dmitry
Dmitry

Reputation: 3665

In Emacs 24.4 and newer, you can set ruby-align-to-stmt-keywords to '(if begin case), or simply to t, to resolve the first part of your question.

It won't change the indentation offset of when, though. That would have to be a different option.

Upvotes: 5

Bozhidar Batsov
Bozhidar Batsov

Reputation: 56595

There is no way to customize this. ruby-mode is pretty barebone as far as indentation customizations are concerned and Matz (its original author) is totally adamant in supporting the standard style for case indentation.

Upvotes: 2

Related Questions