Function: c-brace-newlines
c-brace-newlines is a byte-compiled function defined in cc-cmds.el.gz.
Signature
(c-brace-newlines SYNTAX)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-brace-newlines (syntax)
;; A brace stands at point. SYNTAX is the syntactic context of this brace
;; (not necessarily the same as the S.C. of the line it is on). Return
;; NEWLINES, the list containing some combination of the symbols `before'
;; and `after' saying where newlines should be inserted.
(c-save-buffer-state
((syms
;; This is the list of brace syntactic symbols that can hang.
;; If any new ones are added to c-offsets-alist, they should be
;; added here as well.
;;
;; The order of this list is important; if SYNTAX has several
;; elements, the element that "wins" is the earliest in SYMS.
'(arglist-cont-nonempty ; e.g. an array literal.
class-open class-close defun-open defun-close
inline-open inline-close
brace-list-open brace-list-close
brace-list-intro brace-entry-open
block-open block-close
substatement-open statement-case-open
extern-lang-open extern-lang-close
namespace-open namespace-close
module-open module-close
composition-open composition-close
inexpr-class-open inexpr-class-close
;; `statement-cont' is here for the case with a brace
;; list opener inside a statement. C.f. CASE B.2 in
;; `c-guess-continued-construct'.
statement-cont))
;; shut this up too
(c-echo-syntactic-information-p nil)
symb-newlines) ; e.g. (substatement-open . (after))
(setq symb-newlines
;; Do not try to insert newlines around a special
;; (Pike-style) brace list.
(if (and c-special-brace-lists
(save-excursion
(c-safe (if (= (char-before) ?{)
(forward-char -1)
(c-forward-sexp -1))
(c-looking-at-special-brace-list))))
nil
;; Seek the matching entry in c-hanging-braces-alist.
(or (c-lookup-lists
syms
;; Substitute inexpr-class and class-open or
;; class-close with inexpr-class-open or
;; inexpr-class-close.
(if (assq 'inexpr-class syntax)
(cond ((assq 'class-open syntax)
'((inexpr-class-open)))
((assq 'class-close syntax)
'((inexpr-class-close)))
(t syntax))
syntax)
c-hanging-braces-alist)
'(ignore before after)))) ; Default, when not in c-h-b-l.
;; If syntax is a function symbol, then call it using the
;; defined semantics.
(if (and (not (consp (cdr symb-newlines)))
(functionp (cdr symb-newlines)))
(let ((c-syntactic-context syntax))
(funcall (cdr symb-newlines)
(car symb-newlines)
(point)))
(cdr symb-newlines))))