Emacs d-mode目前错误地缩进了模板限制,例如
auto f(T)(T x)
if (is(T == struct))
{
}作为
auto f(T)(T x)
if (is(T == struct))
{
}有没有人知道从哪里开始挖掘来解决这个问题?请注意,d-mode使用cc-mode。
发布于 2016-07-16 11:22:11
运行C-h f d-mode,它应该显示:d-mode is an interactive autoloaded compiled Lisp function in 'd-mode.el'.跟随d-mode.el链接。
通过在该文件中搜索“缩进”,看起来他们只是使用了cc-mode中定义的任何内容。您可以通过在d-mode buffer中运行以下命令来了解它们使用的是什么函数:
C-h v indent-line-function这表明他们确实使用了c-indent-line。也许解决这个问题的一种方法是尝试检测这一种情况,否则会退回到c-indent-line。类似这样的代码(未经测试的代码,仅用于说明目的):
(defun d-indent-line ()
(let* ((auto-if-curly
(save-excursion
(back-to-indentation
(when (looking-at "{")
(forward-line -1)
(back-to-indentation
(when (looking-at "if")
(forward-line -1)
(back-to-indentation
(looking-at "auto")))))))))
(if auto-if-curly
(ident-line-to 0)
(c-ident-line))))
(add-hook d-mode-hook (lambda () (setq-local indent-line-function 'd-indent-line)))https://stackoverflow.com/questions/38371139
复制相似问题