Function: c-indent-exp

c-indent-exp is an interactive and byte-compiled function defined in cc-cmds.el.gz.

Signature

(c-indent-exp &optional SHUTUP-P)

Documentation

Indent each line in the balanced expression following point syntactically.

If optional SHUTUP-P is non-nil, no errors are signaled if no balanced expression is found.

Probably introduced at or before Emacs version 19.23.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-indent-exp (&optional shutup-p)
  "Indent each line in the balanced expression following point syntactically.
If optional SHUTUP-P is non-nil, no errors are signaled if no
balanced expression is found."
  (interactive "*P")
  (let ((here (point-marker))
	end)
    (set-marker-insertion-type here t)
    (unwind-protect
	(let ((start (save-restriction
		       ;; Find the closest following open paren that
		       ;; ends on another line.
		       (narrow-to-region (point-min) (c-point 'eol))
		       (let (beg (end (point)))
			 (while (and (setq beg (c-down-list-forward end))
				     (setq end (c-up-list-forward beg))))
			 (and beg
			      (eq (char-syntax (char-before beg)) ?\()
			      (1- beg))))))
	  ;; sanity check
	  (if (not start)
	     (unless shutup-p
	       (error "Cannot find start of balanced expression to indent"))
	    (goto-char start)
	    (setq end (c-safe (scan-sexps (point) 1)))
	    (if (not end)
		(unless shutup-p
		  (error "Cannot find end of balanced expression to indent"))
	      (forward-line)
	      (if (< (point) end)
		  (c-indent-region (point) end)))))
      (goto-char here)
      (set-marker here nil))))