Function: js--end-of-do-while-loop-p

js--end-of-do-while-loop-p is an interactive and byte-compiled function defined in js.el.gz.

Signature

(js--end-of-do-while-loop-p)

Documentation

Return non-nil if point is on the "while" of a do-while statement.

Otherwise, return nil. A braceless do-while statement spanning several lines requires that the start of the loop is indented to the same column as the current line.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--end-of-do-while-loop-p ()
  "Return non-nil if point is on the \"while\" of a do-while statement.
Otherwise, return nil.  A braceless do-while statement spanning
several lines requires that the start of the loop is indented to
the same column as the current line."
  (interactive)
  (save-excursion
    (save-match-data
      (when (looking-at "\\s-*\\_<while\\_>")
	(if (save-excursion
	      (skip-chars-backward " \t\n}")
	      (looking-at "[ \t\n]*}"))
	    (save-excursion
	      (backward-list) (forward-symbol -1) (looking-at "\\_<do\\_>"))
          (js--re-search-backward "\\_<do\\_>" (line-beginning-position) t)
	  (or (looking-at "\\_<do\\_>")
	      (let ((saved-indent (current-indentation)))
		(while (and (js--re-search-backward "^\\s-*\\_<" nil t)
			    (/= (current-indentation) saved-indent)))
		(and (looking-at "\\s-*\\_<do\\_>")
		     (not (js--re-search-forward
                           "\\_<while\\_>" (line-end-position) t))
		     (= (current-indentation) saved-indent)))))))))