Function: js--guess-function-name

js--guess-function-name is a byte-compiled function defined in js.el.gz.

Signature

(js--guess-function-name POSITION)

Documentation

Guess the name of the JavaScript function at POSITION.

POSITION should be just after the end of the word "function". Return the name of the function, or nil if the name could not be guessed.

This function clobbers match data. If we find the preamble begins earlier than expected while guessing the function name, set js--guess-function-name-start to that position; otherwise, set that variable to nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--guess-function-name (position)
  "Guess the name of the JavaScript function at POSITION.
POSITION should be just after the end of the word \"function\".
Return the name of the function, or nil if the name could not be
guessed.

This function clobbers match data.  If we find the preamble
begins earlier than expected while guessing the function name,
set `js--guess-function-name-start' to that position; otherwise,
set that variable to nil."
  (setq js--guess-function-name-start nil)
  (save-excursion
    (goto-char position)
    (forward-line 0)
    (cond
     ((looking-at js--function-heading-3-re)
      (and (eq (match-end 0) position)
           (setq js--guess-function-name-start (match-beginning 1))
           (match-string-no-properties 1)))

     ((looking-at js--function-heading-2-re)
      (and (eq (match-end 0) position)
           (setq js--guess-function-name-start (match-beginning 1))
           (match-string-no-properties 1))))))