imenu-list
imenu-list copied to clipboard
Sorting?
I wonder how difficult would be that to add. Not "requesting" it, I may attempt to add it myself if get time to play with elisp. For now just throwing it here as an idea.
Sorry for late response, but here goes:
Leaving aside the question of how to sort the entries, adding sorting is pretty easy. In the function imenu-list-collect-entries
you just need to sort imenu--index-alist
before storing it in imenu-list--imenu-entries
.
However, how to sort the entries can prove very difficult. Different indexing functions create different structures of imenu--index-alist
(it can a flat list or an arbitrary tree), and you need to decide what sorting criterion you want. Sorting the entries is really the job of Imenu and its (buffer-local) indexing function, so it's not something I really want to put into imenu-list.
That said, if you do happen to write a sorter, we can make imenu-list-collect-entries
use an optional user-customizable sorter (but OOTB there will be no sorting).
Old issue but I'm wondering about this as well. For me all entries are sorted alphabetically which is really confusing. I'd like the functions sorted the same order as they appear in the source code. Is there a way to do this now?