2

I use both org-sidebar (https://github.com/alphapapa/org-sidebar/) and Speedbar to navigate Org files. Both have minor issues. However, I find Speedbar works best, but it has a terrible habit of sorting headers in an order different to that of the file. In particular, headings with no sub-headings (such as when drafting an outline) are always displayed after headings with sub-headings. Does anybody know how to force the headeings' sort order in Speedbar to match that of the file's?

  • Type C-h v and have a look at the doc-string for speedbar-tag-hierarchy-method ("List of hooks which speedbar will use to organize tags into groups."), which has options such as: speedbar-prefix-group-tag-hierarchy; speedbar-trim-words-tag-hierarchy; speedbar-simple-group-tag-hierarchy; speedbar-sort-tag-hierarchy. You can even write your own sorting functions .... Or, you can have no sorting order -- which may be what you want (although I am unsure from the question because there is no before and after example). – lawlist Nov 10 at 16:10
  • ... continued from comment above: To see what those functions do, type C-h f and read the doc-strings ... perhaps they will mention something you may find useful .... And, if you are super interested, you can type M-x find-function and peek at the source code .... – lawlist Nov 10 at 16:26
  • @lawlist, you are correct in your assumption. I don't want Speedbar to sort the headings. I assume this will force their display in the same order as they appear in the file. How do I accomplish this? Do I (setq speedbar-tag-hierarchy-method nil) – Pablo A Perez-Fernandez Nov 11 at 9:13
  • Because you have not provided a before/after example, I have no way to test your desired output and I don't even know what version of org-mode you are using. With that being said, you can see what the default value is for speedbar-tag-hierarchy-method and modify it with (setq speedbar-tag-hierarchy-method '(NAME-OF-FUNCTION-ONE NAME-OF-FUNCTION-TWO)). Eliminate the offending sorting function, save, restart Emacs and give it a whirl. – lawlist Nov 11 at 9:17
  • Let me try your suggestion. I will post examples following my test – Pablo A Perez-Fernandez Nov 11 at 9:19
1

The variable speedbar-tag-hierarchy-method has a doc-string that states in relevant part: "List of hooks which speedbar will use to organize tags into groups." The list can contain values such as: speedbar-prefix-group-tag-hierarchy; speedbar-trim-words-tag-hierarchy; speedbar-simple-group-tag-hierarchy; speedbar-sort-tag-hierarchy.

The original poster has stated a preference that the tags not be sorted; i.e., that the order in which they appear be the same as the order in the file from which they were gathered. In a comment underneath the question, the O.P. has indicated that he is happy with setting the above-mentioned variable to nil. It may be preferable, however, to nevertheless keep a non-offending value such as trimming the words; e.g.

(setq speedbar-tag-hierarchy-method '(speedbar-trim-words-tag-hierarchy))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.