Open vindarel opened 6 years ago
Hello,
I'm pretty unfamiliar with imenu's programming interface, but I agree that it'd be a useful addition, especially because newer extensions like treemacs are so reliant on it. Perhaps we could hijack the submodes' imenu entries for ourselves? I'd definitely be open to any ideas on that front.
Perhaps we could hijack the submodes' imenu entries for ourselves?
well thought, but I guess it would not be the best, because we'd like to catch vue specific stuff (props, which is not a function) and cleanly organize the imenu: a section for html tags, a section for computed properties, for methods,…
I had a look at this to see how it's done: https://github.com/elixir-editors/emacs-elixir/blob/master/elixir-mode.el#L60
I'll explain what I understood so far, it may help me too :)
("methods" "^\\s-*\\([a-zA-Z0-9_]+\\): function" 1)
\\(
and \\)
) will appear in the imenu entry. So, we try to catch the function name but not "function".1
is an index: "a non-negative integer that indicates which subexpression in regexp matches the definition's name." I want to catch the first group of parens, so I put 1 (and verification with elixir-mode's code).Note: there's a pb on my side, I could not see imenu entries in web-mode before I loaded it in emacs -Q
. It already shows all the JS functions that are present.
Adding menus for data, props, computed and methods would be added sugar.
Apologies if out-of-context... vindarel - could you please elaborate "could not see imenu entries in web-mode before I loaded it". In blee.vue, in Githubissues.
Hi, Currently the imenu shows some html tags. I'd like it to show javascript functions, and possibly different sub-menus for computed properties or methods.
I tried something but it is unclear to me how to add regular imenu entries.
I have a regexp, checked with the regexp-builder:
I don't know how to override the existing entries and use just that. I tried:
as discussed on emacswiki and SE and as seen in a couple of other packages, with no luck.
An example file:
there would be functions and data to catch, hence a few imenu regexps to write.
Any ideas ?
imenu doc: https://www.gnu.org/software/emacs/manual/html_node/elisp/Imenu.html
edit: I tried what you can see in the following commit.