Function: js--function-prologue-beginning

js--function-prologue-beginning is a byte-compiled function defined in js.el.gz.

Signature

(js--function-prologue-beginning &optional POS)

Documentation

Return the start of the JavaScript function prologue containing POS.

A function prologue is everything from start of the definition up to and including the opening brace. POS defaults to point. If POS is not in a function prologue, return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--function-prologue-beginning (&optional pos)
  "Return the start of the JavaScript function prologue containing POS.
A function prologue is everything from start of the definition up
to and including the opening brace.  POS defaults to point.
If POS is not in a function prologue, return nil."
  (let (prologue-begin)
    (save-excursion
      (if pos
          (goto-char pos)
        (setq pos (point)))

      (when (save-excursion
              (forward-line 0)
              (or (looking-at js--function-heading-2-re)
                  (looking-at js--function-heading-3-re)))

        (setq prologue-begin (match-beginning 1))
        (when (<= prologue-begin pos)
          (goto-char (match-end 0))))

      (skip-syntax-backward "w_")
      (and (or (looking-at "\\_<function\\_>")
               (js--re-search-backward "\\_<function\\_>" nil t))

           (save-match-data (goto-char (match-beginning 0))
                            (js--forward-function-decl))

           (<= pos (point))
           (or prologue-begin (match-beginning 0))))))