Function: js-beginning-of-defun
js-beginning-of-defun is a byte-compiled function defined in js.el.gz.
Signature
(js-beginning-of-defun &optional ARG)
Documentation
Value of beginning-of-defun-function for js-mode.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js-beginning-of-defun (&optional arg)
"Value of `beginning-of-defun-function' for `js-mode'."
(setq arg (or arg 1))
(while (and (not (eobp)) (< arg 0))
(cl-incf arg)
(when (and (not js-flat-functions)
(or (eq (js-syntactic-context) 'function)
(js--function-prologue-beginning)))
(js-end-of-defun))
(if (js--re-search-forward
"\\_<function\\_>" nil t)
(goto-char (js--function-prologue-beginning))
(goto-char (point-max))))
(while (> arg 0)
(cl-decf arg)
;; If we're just past the end of a function, the user probably wants
;; to go to the beginning of *that* function
(when (eq (char-before) ?})
(backward-char))
(let ((prologue-begin (js--function-prologue-beginning)))
(cond ((and prologue-begin (< prologue-begin (point)))
(goto-char prologue-begin))
(js-flat-functions
(js--beginning-of-defun-flat))
(t
(js--beginning-of-defun-nested))))))