reddit / emacs

magit-section for creating an interface

Alric-Rahl · 2022-10-23 15:11
I've been tinkering with making simple interfaces with `transient` and `tabulated-list-mode`, things like a list of scripts with some information on them as columns, and key bindings/transients to edit, lint or execute them. While this is nice, for something more elaborate `tabulated-list-mode` is not enough. I am trying to get a view inspired by `magit`'s status buffer, so I thought I could use `magit-section` for this. However, I couldn't find any guides on how to make something with it, and I am not savy enough to extract the exact usage from the `magit` code (I did try). So my question is, does anyone have any guides or any simple elisp code that I can use for reference to create a new derived mode out of `magit-section`? Edit: Fixed formatting.
akirakom · 2022-10-23 16:58
The best example I've seen so far is taxy-magit-section. It uses cl-labels to handle nested structures using recursion.
Alric-Rahl · 2022-10-24 13:56
Thanks! It looks at least easier than `magit` to go over. I wonder if trying to create something from scratch over the `special-mode` basic mode would be easier than understanding an existing code base.
abrochard · 2022-10-24 15:59
I remember trying to figure it out too in the past and getting confused. I put together some of my old notes in a quick gist. It's not 100% working but maybe it'll help. ​ [https://gist.github.com/abrochard/4b3858e155fa76697058673866f55d2f](https://gist.github.com/abrochard/4b3858e155fa76697058673866f55d2f)
github-alphapapa · 2022-10-24 16:36
As Akira said, `taxy-magit-section` is designed to do exactly this. I'd recommend looking at this example application and modifying it to suit your needs: https://github.com/alphapapa/taxy.el/blob/master/examples/bookmarky.el
Alric-Rahl · 2022-10-24 21:38
This looks so helpful, I will give it a shot asap!
abrochard · 2022-10-24 21:39
Good luck! I'd be curious to learn what you'll find
Alric-Rahl · 2022-10-24 21:43
Oh, so `taxy` is kinda like an extra layer built on top of `magit-section` to make it easier to use to build things?
github-alphapapa · 2022-10-27 20:04
`taxy` is not a layer on top of `magit-section`, but it offers a library to use `magit-section` to render `taxy`-based structures. See https://github.com/alphapapa/taxy.el