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_")
      (let ((start nil))
        (and (or (looking-at "\\_<function\\_>")
                 (js--re-search-backward "\\_<function\\_>" nil t))
             (progn
               (setq start (match-beginning 0))
               (goto-char start)
               (when (looking-back "\\_<async\\_>[ \t\n]+" (- (point) 30))
                 (setq start (match-beginning 0)))
               (js--forward-function-decl))
             (<= pos (point))
             (or prologue-begin start))))))