5

I am aware that org-mode derives from outline-mode, in the same way as outline-mode derives from text-mode, which derives from nil.

I have always wonder if there exists something similar to a documented tree of major modes allowing to follow hooks, so that fundamental-mode might be at the base of them all.

Is there a list of major-modes, with their respective hierarchies, documented anywhere?

  • The most definitive documentation for this would be from within emacs itself, though I don't know how to access such information comprehensively and automatically. – Sean Allred Oct 26 '14 at 19:28
4
(defun modes-tree ()
  (cl-loop
   with result = (make-hash-table)
   for maybe-mode in (apropos-internal "-mode$")
   ;; This doesn't really filter all non-modes, but it gets close
   when (fboundp maybe-mode) do
   (setf (gethash maybe-mode result)
         (get maybe-mode 'derived-mode-parent))
   finally (cl-return result)))

Something to get you started. This will produce a hash-map containing every symbol which looks like it is a mode as a key. And, if it is a derived, mode, then the value pointed by that symbol will be the parent mode.

But printing this is a much, much harder problem :) Graph printing is in general very non-trivial. Maybe you could export this as Dot and then use something like OGDF to print it nicely (Graphiz can also print graphs, but, quite frankly, it doesn't look very good / it's hard to get it to lay out the graph exactly the way you want).

  • I wish I could +1, but I'm all out of votes :) Printing actually isn't that hard of a problem if you don't complicate it. A simple tree-view will suffice; take a look the output of tree in your terminal. (Choose a small directory!) – Sean Allred Oct 26 '14 at 20:37
  • 1
    @SeanAllred for some reason I thought it's not necessarily an acyclic directed graph :) Yeah, printing this tree won't be too hard (especially so it seems that the hierarchy is more "bushy"), but in general, when there are loops and certain constraints wrt the area where the graph can be printed, it becomes difficult. – wvxvw Oct 26 '14 at 20:39
  • I created a tool for self-stabilizing algorithm simulation / visualization for my thesis. You aren't lying when you say that it becomes difficult. Crossings… ugh. – Sean Allred Oct 26 '14 at 20:42
  • 1
    I used neato to get a view of all modes (I took all symbols that had a 'derived-mode-parent property). The output is terrible, but it gives an idea: i.stack.imgur.com/PKr61.jpg – YoungFrog Dec 22 '14 at 14:10

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.