Function: c-lineup-argcont

c-lineup-argcont is a byte-compiled function defined in cc-align.el.gz.

Signature

(c-lineup-argcont ELEM)

Documentation

Line up a continued argument.

foo (xyz, aaa + bbb + ccc
          + ddd + eee + fff); <- c-lineup-argcont

Only continuation lines like this are touched, nil is returned on lines which are the start of an argument.

Within a gcc asm block, ":" is recognized as an argument separator, but of course only between operand specifications, not in the expressions for the operands.

Works with: arglist-cont, arglist-cont-nonempty.

Probably introduced at or before Emacs version 22.1.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-align.el.gz
;; Contributed by Kevin Ryde <user42@zip.com.au>.
(defun c-lineup-argcont (elem)
  "Line up a continued argument.

foo (xyz, aaa + bbb + ccc
          + ddd + eee + fff);    <- c-lineup-argcont

Only continuation lines like this are touched, nil is returned on lines
which are the start of an argument.

Within a gcc asm block, \":\" is recognized as an argument separator,
but of course only between operand specifications, not in the expressions
for the operands.

Works with: arglist-cont, arglist-cont-nonempty."

  (save-excursion
    (beginning-of-line)

    (when (eq (car elem) 'arglist-cont-nonempty)
      ;; Our argument list might not be the innermost one.  If it
      ;; isn't, go back to the last position in it.  We do this by
      ;; stepping back over open parens until we get to the open paren
      ;; of our argument list.
      (let ((open-paren (c-langelem-2nd-pos c-syntactic-element))
	    (paren-state (c-parse-state)))
	(while (not (eq (car paren-state) open-paren))
	  (unless (consp (car paren-state)) ;; ignore matched braces
	    (goto-char (car paren-state)))
	  (setq paren-state (cdr paren-state)))))

    (let ((start (point)) c)

      (when (bolp)
	;; Previous line ending in a comma means we're the start of an
	;; argument.  This should quickly catch most cases not for us.
	;; This case is only applicable if we're the innermost arglist.
	(c-backward-syntactic-ws)
	(setq c (char-before)))

      (unless (eq c ?,)
	;; In a gcc asm, ":" on the previous line means the start of an
	;; argument.  And lines starting with ":" are not for us, don't
	;; want them to indent to the preceding operand.
	(let ((gcc-asm (save-excursion
			 (goto-char start)
			 (c-in-gcc-asm-p))))
	  (unless (and gcc-asm
		       (or (eq c ?:)
			   (save-excursion
			     (goto-char start)
			     (looking-at "[ \t]*:"))))

	    (c-lineup-argcont-scan (if gcc-asm ?:))
	    (vector (current-column))))))))