bufler.el icon indicating copy to clipboard operation
bufler.el copied to clipboard

bufler-groups explanation

Open indigoviolet opened this issue 3 years ago • 2 comments

Thank you for bufler.

I wanted to adjust something with my bufler config today and it took me a while and a bunch of experimenting to understand how bufler-groups work; so I wrote up my understanding -- for future reference, or perhaps it will suggest some ideas for expanding the docs.


Bufler groups:

  • Constructs a tree, buffers are the leaves.

  • Each buffer is assigned its path from the root to the leaf; so bufler-groups is ultimately a function like (buf) -> [node], where each node is a string.

  • Each type function is (buf) -> node; they assign one step along this path. eg. auto-*, *-match, dir, hidden

  • A list of type functions will therefore return [node] - the simple case.

  • group*() functions define branching in this logic: if a buffer “matches” the group, it is then “captured” by this group and recurses into the type functions within that group for the remainder of its path.

  • “Matching” a group can mean:

    group(T1 T2...) -> if T1 returns non-nil group-and(T1 T2...) -> if all T* return non-nil group-or(T1 T2...) -> if any of T* return non-nil

    Note that T* above are returning steps in [node].

    Any node == nil is dropped.

  • Since groups will capture, their order matters, because buffers will recurse into the first group they match.

  • bufler-filter-name-regexps and bufler-filter-buffer-modes can specify rules to match buffers to the hidden entirely; bufler-filter-buffer-fns implement the above filters via bufler--buffer-{mode,name}-filtered-p

indigoviolet avatar Sep 22 '22 06:09 indigoviolet

Question: Is it possible in this scheme to (a) reorder groups (b) mark groups as collapsed/expanded in the config?

indigoviolet avatar Sep 22 '22 06:09 indigoviolet

Hi Venky,

Thanks for your thorough writeup. Describing the Bufler DSL is something I have been needing to do. However, I will be replacing Bufler's backend with one based on Taxy, which also needs documentation describing its "key"-based DSL. (Not to worry, Taxy's implementation is based on Bufler's, which served as the prototype, so it will be essentially the same.)

Question: Is it possible in this scheme to (a) reorder groups

Taxy allows groups to be sorted, as well as items within them. So when Bufler is updated to use it, it will support this.

(b) mark groups as collapsed/expanded in the config?

No, but that's a good idea. It would be fine to file an issue on Taxy's tracker suggesting it (or, more generally, a way to attach arbitrary data to Taxy structs, which could be used to record such data, which could later be used to set the initial visibility of sections).

alphapapa avatar Sep 23 '22 19:09 alphapapa