yorel
yorel

Reputation: 323

Indenting deeply nested function calls

I would like emacs to indent my c/c++ code like this:

auto LoopMatcher = forStmt(hasLoopInit(declStmt(hasSingleDecl(varDecl(
    hasInitializer(integerLiteral(equals(0)))))))).bind("forLoop");

(code taken from clang's AST matcher tutorial).

In other words, I want emacs to indent by the default offset after one or more open parentheses.

Upvotes: 3

Views: 223

Answers (1)

juanleon
juanleon

Reputation: 9410

Here you have a solution for that:

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

Upvotes: 2

Related Questions