All Projects → redguardtoo → imenu-extra

redguardtoo / imenu-extra

Licence: GPL-3.0 license
Add extra items into lsp-mode/js2-mode imenu items

Programming Languages

emacs lisp
2029 projects

Add extra items into existing imenu items

Extra imenu items can be easily added into existing imenu items generated by major/minor modes (lsp-mode, js2-mode, etc).

demo.png

Install and Setup

You could place imenu-extra.el under Load Path, then add (require 'imenu-extra) to your configuration.

But I recommend to use http://melpa.org/ to install the package.

Setup is simple,

At the end of minor/major mode hook, call imenu-extra-auto-setup which has one parameter “patterns”.

Patterns should be an alist of the same form as imenu-generic-expression.

For example, insert below code at the end of js2-mode-hook to extract unit test case as imenu items from javascript code,

(add-hook 'js2-mode-hook
          (lambda ()
            ;; original js2-mode setup ...

            ;; at the end of mode hook
            (require 'imenu-extra)
            (imenu-extra-auto-setup '(("tdd.it" "^[ \t]*it('\\([^']+\\)" 1)
                                      ("tdd.desc" "^[ \t]*describe('\\([^']+\\)" 1))))

Usage

Use imenu as usual.

Tips

  • Set imenu-extra-process-item-function to process extra imenu items

Contact me

Report bugs at https://github.com/redguardtoo/imenu-extra.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].