Function: c-lineup-java-throws

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

Signature

(c-lineup-java-throws LANGELEM)

Documentation

Line up Java throws declarations.

If exception names follow on the same line as the throws keyword, they are lined up under each other. Otherwise, they are indented by adding c-basic-offset to the column of the throws keyword. The throws keyword itself is also indented by c-basic-offset from the function declaration start if it doesn't hang. E.g.:

int foo() int foo() throws Cyphr,
    throws <-> Bar, <- c-lineup-java-throws
        Bar <-> Vlod <- c-lineup-java-throws
<--><--> c-basic-offset

Works with: func-decl-cont.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-align.el.gz
(defun c-lineup-java-throws (langelem)
  "Line up Java throws declarations.
If exception names follow on the same line as the throws keyword,
they are lined up under each other.  Otherwise, they are indented by
adding `c-basic-offset' to the column of the throws keyword.  The
throws keyword itself is also indented by `c-basic-offset' from the
function declaration start if it doesn't hang.  E.g.:

int foo()           int foo() throws Cyphr,
    throws     <->                   Bar,    <- c-lineup-java-throws
        Bar    <->                   Vlod    <- c-lineup-java-throws
<--><--> c-basic-offset

Works with: func-decl-cont."
  (save-excursion
    (let* ((lim (1- (c-point 'bol)))
	   (throws (catch 'done
		     (goto-char (c-langelem-pos langelem))
		     (while (zerop (c-forward-token-2 1 t lim))
		       (if (looking-at "throws\\>[^_]")
			   (throw 'done t))))))
      (if throws
	  (if (zerop (c-forward-token-2 1 nil (c-point 'eol)))
	      (vector (current-column))
	    (back-to-indentation)
	    (vector (+ (current-column) c-basic-offset)))
	c-basic-offset))))