emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9c64c52: Teach js-mode about ES6 generators


From: Daniel Colascione
Subject: [Emacs-diffs] master 9c64c52: Teach js-mode about ES6 generators
Date: Fri, 09 Jan 2015 18:25:57 +0000

branch: master
commit 9c64c52b27bbef0f252c19fd978feb81d53a4093
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    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()").
---
 lisp/ChangeLog       |    6 ++++++
 lisp/progmodes/js.el |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bca8d28..c7ad41a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-09  Daniel Colascione  <address@hidden>
+
+       * 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  <address@hidden>
 
        * emacs-lisp/eieio.el (defclass): Move from eieio-defclass all the code
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index de6a339..c25e52c 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]