Function: js--ctrl-statement-indentation

js--ctrl-statement-indentation is a byte-compiled function defined in js.el.gz.

Signature

(js--ctrl-statement-indentation)

Documentation

Helper function for js--proper-indentation.

Return the proper indentation of the current line if it starts the body of a control statement without braces; otherwise, return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--ctrl-statement-indentation ()
  "Helper function for `js--proper-indentation'.
Return the proper indentation of the current line if it starts
the body of a control statement without braces; otherwise, return
nil."
  (save-excursion
    (back-to-indentation)
    (when (save-excursion
            (and (not (eq (line-beginning-position) (point-min)))
                 (not (looking-at "[{]"))
                 (js--re-search-backward "[[:graph:]]" nil t)
                 (progn
                   (or (eobp) (forward-char))
                   (when (= (char-before) ?\)) (backward-list))
                   (skip-syntax-backward " ")
                   (skip-syntax-backward "w_")
                   (looking-at js--possibly-braceless-keyword-re))
                 (memq (char-before) '(?\s ?\t ?\n ?\}))
                 (not (js--end-of-do-while-loop-p))))
      (save-excursion
        (goto-char (match-beginning 0))
        (+ (current-indentation) js-indent-level)))))