Last active
October 23, 2015 17:16
-
-
Save atelic/4d7988f35c00826a82e5 to your computer and use it in GitHub Desktop.
Get mocha test keywords to show in Emacs imenu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun js2-imenu-make-index () | |
(save-excursion | |
(imenu--generic-function '(("describe" "\\s-*describe\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1) | |
("it" "\\s-*it\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1) | |
("before" "\\s-*before\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1) | |
("after" "\\s-*after\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1) | |
;;add more keyword for mocha here | |
("Function" "function[ \t]+\\([a-zA-Z0-9_$.]+\\)[ \t]*(" 1) | |
("Function" "^[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*=[ \t]*function[ \t]*(" 1))))) | |
(add-hook 'js2-mode-hook | |
(lambda () | |
(setq imenu-create-index-function 'js2-imenu-make-index))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment