I'm experimenting with magit-section as the UI library for an Emacs package. Without going into too much detail, this package interfaces with a websocket and displays the data it receives as an expandable line in the buffer, preferably as a magit-section item. Nested inside it are more magit-section items with other data categories.

Unfortunately, I can't figure out, how to insert a section dynamically (on a websocket message). The following works well enough on buffer setup:

(magit-insert-section (root-section) ;; top-lvl section containing all buffer data
    (magit-insert-section (list-section) ;; first visible section with a heading
        (magit-insert-heading "Websocket messages:")
        (magit-insert-section (item-section nil t) ;; nested data is hidden
            (magit-insert-heading "List item:")
                ;; more data and sections

But adding an item-section to the list-section dynamically is very difficult.

Is it possible? If it is, how?

I'd really prefer magit-section because of it's ergonomics (setting a specific keymap for every section).



Your Answer

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

Browse other questions tagged or ask your own question.