Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望 emacs 像这样缩进我的 c/c++ 代码:
auto LoopMatcher = forStmt(hasLoopInit(declStmt(hasSingleDecl(varDecl( hasInitializer(integerLiteral(equals(0)))))))).bind("forLoop");
(代码取自 clang 的 AST 匹配器教程)。
换句话说,我希望 emacs 在一个或多个左括号后缩进默认偏移量。
在这里,您有一个解决方案:
(defun custom-indent (langelem) (save-excursion (goto-char (cdr langelem)) (vector (+ (current-column) c-basic-offset)))) (c-add-style "custom" '((c-offsets-alist . ((arglist-intro . custom-indent))))) (c-set-style "custom")