Teach js-mode about ES6 generators

* lisp/progmodes/js.el (js--function-heading-1-re)
(js--function-prologue-beginning): Parse ES6 generator function
declarations.  (That is, "function* name()").
This commit is contained in:
Daniel Colascione 2015-01-09 10:25:50 -08:00
parent d1f848ffb9
commit 9c64c52b27
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2015-01-09 Daniel Colascione <dancol@dancol.org>
* progmodes/js.el (js--function-heading-1-re)
(js--function-prologue-beginning): Parse ES6 generator function
declarations. (That is, "function* name()").
2015-01-08 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/eieio.el (defclass): Move from eieio-defclass all the code

View file

@ -248,7 +248,7 @@ name as matched contains
(defconst js--function-heading-1-re
(concat
"^\\s-*function\\s-+\\(" js--name-re "\\)")
"^\\s-*function\\(?:\\s-\\|\\*\\)+\\(" js--name-re "\\)")
"Regexp matching the start of a JavaScript function header.
Match group 1 is the name of the function.")
@ -796,6 +796,9 @@ determined. Otherwise, return nil."
(let ((name t))
(forward-word)
(forward-comment most-positive-fixnum)
(when (eq (char-after) ?*)
(forward-char)
(forward-comment most-positive-fixnum))
(when (looking-at js--name-re)
(setq name (match-string-no-properties 0))
(goto-char (match-end 0)))