Emacs Ruby方法参数缩进



我想让emacs缩进ruby方法调用:

foo(
  :blah => 'bar',
  :shibby => 'baz'
)

我能得到的最接近的是:

foo(
  :blah => 'bar',
  :shibby => 'baz'
  )

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

哈希缩进我喜欢…如果我能让方法调用像哈希一样缩进,我会很高兴。什么好主意吗?

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

Ruby缩进在当前的Emacs主干(将作为24.4发布)中像您所要求的那样工作,无需任何额外的调整。

我相信有一个像C-c - o这样的键序列,您可以用光标按下关闭括号上的键序列,这将显示使用的变量并让您键入新值(如0或+)。试一试!

最新更新