This style variable takes a list of functions; these get called when you type a semicolon or comma. The functions are called in order without arguments. When these functions are entered, point is just after the newly inserted ‘;’ or ‘,’ and they must preserve point (e.g., by using
save-excursion). During the call, the variable
c-syntactic-contextis bound to the syntactic context of the current line1 see Custom Braces. These functions don't insert newlines themselves, rather they direct CC Mode whether or not to do so. They should return one of the following values:
- A newline is to be inserted after the ‘;’ or ‘,’, and no more functions from the list are to be called.
- No more functions from the list are to be called, and no newline is to be inserted.
- No determination has been made, and the next function in the list is to be called.
Note that auto-newlines are never inserted before a semicolon or comma. If every function in the list is called without a determination being made, then no newline is added.
In AWK mode, this variable is set by default to
nil. In the other modes, the default value is a list containing a single function,
c-semi&comma-inside-parenlist. This inserts newlines after all semicolons, apart from those separating
This is an example of a criteria function, provided by CC Mode. It prevents newlines from being inserted after semicolons when there is a non-blank following line. Otherwise, it makes no determination. To use, add this function to the front of the
c-hanging-semi&comma-criterialist.(defun c-semi&comma-no-newlines-before-nonblanks () (save-excursion (if (and (eq last-command-char ?\;) (zerop (forward-line 1)) (not (looking-at "^[ \t]*$"))) 'stop nil)))
c-semi&comma-inside-parenlistis what prevents newlines from being inserted inside the parenthesis list of
forstatements. In addition to
c-semi&comma-no-newlines-before-nonblanksdescribed above, CC Mode also comes with the criteria function
c-semi&comma-no-newlines-for-oneline-inliners, which suppresses newlines after semicolons inside one-line inline method definitions (e.g. in C++ or Java).
 This was first introduced in CC Mode 5.31.