Emacs Ruby方法参数缩进

Mik*_*ade 27 ruby emacs code-formatting

我想制作emacs缩进ruby方法调用,如:

foo(
  :blah => 'bar',
  :shibby => 'baz'
)
Run Code Online (Sandbox Code Playgroud)

我能得到的最接近的是:

foo(
  :blah => 'bar',
  :shibby => 'baz'
  )
Run Code Online (Sandbox Code Playgroud)

这是使用ruby-deep-indent-paren,ruby-deep-indent-paren-style,ruby-deep-arglist全部设置为nil.

哈希缩进我喜欢的方式...如果我可以像哈希那样使方法调用缩进我会很高兴.有任何想法吗?

Luk*_*vin 12

Dmitry Gutov使用建议发布了此修复程序,这似乎有效:

(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)))))
Run Code Online (Sandbox Code Playgroud)


Dmi*_*try 6

当前Emacs主干中的Ruby缩进(将作为24.4发布)就像你要求的那样没有任何额外的调整.