今天在使用spacemacs写c++中的 enum class时发现一个缩进的问题:
enum class kind:char{
//expressions
};
我需要的是
enum class kind:char{
//expressions
};
在stackoverflow上查了一下,找到了如下一段elisp代码:
(defun inside-class-enum-p (pos)
"Checks if POS is within the braces of a C++ \"enum class\"."
(ignore-errors
(save-excursion
(goto-char pos)
(up-list -1)
(backward-sexp 1)
(looking-back "enum[ \t]+class[ \t]+[^}]+"))))
(defun align-enum-class (langelem)
(if (inside-class-enum-p (c-langelem-pos langelem))
0
(c-lineup-topmost-intro-cont langelem)))
(defun align-enum-class-closing-brace (langelem)
(if (inside-class-enum-p (c-langelem-pos langelem))
'-
'+))
(defun fix-enum-class ()
"Setup `c++-mode' to better handle \"class enum\"."
(add-to-list 'c-offsets-alist '(topmost-intro-cont . align-enum-class))
(add-to-list 'c-offsets-alist
'(statement-cont . align-enum-class-closing-brace)))
(add-hook 'c++-mode-hook 'fix-enum-class)
翻了一下底下的issue,修改了一下里面用到的正则,但是还是不能运行,求教一下具体是哪里有问题?应该怎么改?
先谢谢各位解答的大神。