@Konboi memo

主に技術に関してつらつらと。

ruby-modeのインデントがアレだったので

最近Rubyを書いているんですが、インデントが微妙にいけてないので
どうにかならないか調べてみた。

調整前

Hoge::Foo.new(
                     "hoge_key",
                     "foo_key",
                     )

参考にしたサイト
http://willnet.in/13
ほんとこのまま設定してみた。

(setq ruby-deep-indent-paren-style nil)

(defadvice ruby-indent-line (after unindent-closing-paren activate)
  (let ((column (current-column))
        indent offset)
    (save-excursion
      (back-to-indentation)
      (let ((state (syntax-ppss)))
        (setq offset (- column (current-column)))
        (when (and (eq (char-after) ?\))
                   (not (zerop (car state))))
          (goto-char (cadr state))
          (setq indent (current-indentation)))))
    (when indent
      (indent-line-to indent)
      (when (> offset 0) (forward-char offset)))))

こうなった

OAuth::Consumer.new(
  "hoge_key",
  "foo_key",
)

良い感じ。