Function: c-get-syntactic-indentation

c-get-syntactic-indentation is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-get-syntactic-indentation LANGELEMS)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-get-syntactic-indentation (langelems)
  ;; Calculate the syntactic indentation from a syntactic description
  ;; as returned by `c-guess-basic-syntax'.
  ;;
  ;; Note that topmost-intro always has an anchor position at bol, for
  ;; historical reasons.  It's often used together with other symbols
  ;; that have more sane positions.  Since we always use the first
  ;; found anchor position, we rely on that these other symbols always
  ;; precede topmost-intro in the LANGELEMS list.
  ;;
  ;; This function might do hidden buffer changes.
  (let ((indent 0) anchor)

    (while langelems
      (let* ((c-syntactic-element (car langelems))
	     (res (c-calc-offset c-syntactic-element)))

	(if (vectorp res)
	    ;; Got an absolute column that overrides any indentation
	    ;; we've collected so far, but not the relative
	    ;; indentation we might get for the nested structures
	    ;; further down the langelems list.
	    (setq indent (elt res 0)
		  anchor (point-min))	; A position at column 0.

	  ;; Got a relative change of the current calculated
	  ;; indentation.
	  (setq indent (+ indent res))

	  ;; Use the anchor position from the first syntactic
	  ;; element with one.
	  (unless anchor
	    (setq anchor (c-langelem-pos (car langelems)))))

	(setq langelems (cdr langelems))))

    (if anchor
	(+ indent (save-excursion
		    (goto-char anchor)
		    (current-column)))
      indent)))