jdtsmith / outli

Simple comment-based outline folding for Emacs
GNU General Public License v3.0
104 stars 6 forks source link

use imenu-generic-expression for sub-heading? #9

Closed QiangF closed 1 year ago

QiangF commented 1 year ago

To get an in buffer tree view like: https://github.com/emacsmirror/imenu-tree

jdtsmith commented 1 year ago

Have a picture of how it looks? Here I follow org, which uses the normal outline folded view by default.

QiangF commented 1 year ago
img_2023_09_14__10_44_07

On the left is the imenu-tree, it is in a side window. I'd prefer it in the same window, it would be nice to have folding on function definition.

jdtsmith commented 1 year ago

That's looks nice. So there is some way to indent the higher depth heading nodes more? Do you have an example?

QiangF commented 1 year ago

Maybe customize outline-level? I am not sure. I think indentation doesn't matter that much. Folding function definition and easily navigating between function definition would be nice.

jdtsmith commented 1 year ago

I think indentation doesn't matter that much.

Then I'm not sure what you are asking for. I do use imenu-generic-expression, which is why you see headings in imenu. Org does heading nesting down to some configurable level in its imenu, using an imenu-create-index-function.

Folding function definition and easily navigating between function definition would be nice.

Function definitions are out of scope for outli, which concerns itself only with heading-separated sections. But you might look at hideshow-minor-mode which is built-in and lets you fold functions, and which outli works fine with. E.g. hs-hide-all gives a very nice condensed overview, and you can still collapse and navigate outline sections containing hidden functions:

image

There are lots of function navigation commands, e.g. I use lispy. But even C-M-a and repeat-mode works great.

QiangF commented 1 year ago

Thank you for the suggestion. Hideshow-minor-mode is a lot slower than outline-minor-mode for large files. Lispy only works for lisp. Imenu is both fast and works everywhere.

jdtsmith commented 1 year ago

Imenu's job isn't the same as hs-minor-mode's. But if that is slow it's worth looking into why. From a top down view, hs shouldn't be any slower that outline's native section hiding, modulo searching for "block" units to hide.

I just ran hs-hide-all in the largest file in Emacs progmodes directory: cc-engine.el, with 15.6k lines. It took less that 50ms. hs-show-all took less than 2ms. So maybe something is wrong with your config or setup.