Function: c-lineup-close-paren

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

Signature

(c-lineup-close-paren LANGELEM)

Documentation

Line up the closing paren under its corresponding open paren if the open paren is followed by code. If the open paren ends its line, no indentation is added. E.g.:

main (int, main (
      char ** int, char **
     ) <-> ) <- c-lineup-close-paren

As a special case, if a brace block construct starts at the same line as the open parenthesis of the argument list, the indentation is c-basic-offset instead of the open paren column. See c-lineup-arglist for further discussion of this "DWIM" measure.

Works with: All *-close symbols.

Probably introduced at or before Emacs version 20.3.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-align.el.gz
(defun c-lineup-close-paren (langelem)
  "Line up the closing paren under its corresponding open paren if the
open paren is followed by code.  If the open paren ends its line, no
indentation is added.  E.g.:

main (int,              main (
      char **               int, char **
     )           <->    )                 <- c-lineup-close-paren

As a special case, if a brace block construct starts at the same line
as the open parenthesis of the argument list, the indentation is
`c-basic-offset' instead of the open paren column.  See
`c-lineup-arglist' for further discussion of this \"DWIM\" measure.

Works with: All *-close symbols."
  (save-excursion
    (if (memq (c-langelem-sym langelem)
	      '(arglist-cont-nonempty arglist-close))
	(goto-char (c-langelem-2nd-pos c-syntactic-element))
      (beginning-of-line)
      (c-go-up-list-backward))

    (let (special-list arglist-start)
      (if (and c-special-brace-lists
	       (setq special-list (c-looking-at-special-brace-list)))
	  ;; Cope if we're in the middle of a special brace list
	  ;; opener like "({".
	  (progn
	    (goto-char (setq arglist-start (car (car special-list))))
	    (c-forward-token-2)
	    (forward-char))
	(setq arglist-start (point))
	(forward-char))

      (cond ((looking-at c-syntactic-eol)
	     0)				; The arglist is "empty".

	    ((c-block-in-arglist-dwim (point))
	     c-basic-offset)		; DWIM case.

	    (t
	     ;; Normal case.  Indent to the arglist open paren.
	     (goto-char arglist-start)
	     (vector (current-column)))))))