Function: js--indent-in-array-comp
js--indent-in-array-comp is a byte-compiled function defined in
js.el.gz.
Signature
(js--indent-in-array-comp BRACKET)
Documentation
Return non-nil if we think we're in an array comprehension.
In particular, return the buffer position of the first for kwd.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--indent-in-array-comp (bracket)
"Return non-nil if we think we're in an array comprehension.
In particular, return the buffer position of the first `for' kwd."
(let ((end (point)))
(save-excursion
(goto-char bracket)
(when (looking-at "\\[")
(forward-char 1)
(js--forward-syntactic-ws)
(if (looking-at "[[{]")
(let (forward-sexp-function) ; Use Lisp version.
(condition-case nil
(progn
(forward-sexp) ; Skip destructuring form.
(js--forward-syntactic-ws)
(if (and (/= (char-after) ?,) ; Regular array.
(looking-at "for"))
(match-beginning 0)))
(scan-error
;; Nothing to do here.
nil)))
;; To skip arbitrary expressions we need the parser,
;; so we'll just guess at it.
(if (and (> end (point)) ; Not empty literal.
(re-search-forward "[^,]]* \\(for\\_>\\)" end t)
;; Not inside comment or string literal.
(let ((status (parse-partial-sexp bracket (point))))
(and (= 1 (car status))
(not (nth 8 status)))))
(match-beginning 1)))))))