alezost / bui.el

Buffer interface library for Emacs
GNU General Public License v3.0
114 stars 10 forks source link

[[Inquiry]] Passing Entries Function to Interface After Creation? #3

Closed WammKD closed 5 years ago

WammKD commented 5 years ago

So I have this situation: I have a list of objects that have these properties, each property having a name and a value.

I want to go through said list and, upon selecting an object, open a buffer from BUI containing the properties of said object.

Relatively uniform, I could do something like:

(bui-define-interface node_properties list
  :buffer-name          "*Object Properties*"
  :format               '((name nil 30 t) (value nil 70 t))
  :sort-key             '(name)))

The issue, though, is :get-entries-function; because the BUI buffer is being triggered from the object in the list, what the entries are depends on which object is selected.

I may've missed something that might help me so I thought I'd ask if there's a way to pull this off.

alezost commented 5 years ago

Hello and sorry for the delay :-)

Sorry, I think I don't understand your situation. You have a list of object and each object has a list of properties, right? Then you can make one BUI buffer for objects (let's call it *objects*) and another for properties (let's call it *properties*). So when you press RET on *objects*, then *properties* buffer is opened for the selected object. But what is the problem then? Sorry, could you please explain more.

WammKD commented 5 years ago

No worries! Funnily enough, all the questions/PRs I've been waiting on have gotten responses today.

Yeah; absolutely.

So, basically, I've got a hierarchy library I'm using since, to the best of my knowledge, BUI doesn't handles hierarchy trees; just lists and info.

Each node can store the keys/values associated with it so easy retrieval.

Ideally, what I'd want to happen is someone could press a key and then a BUI list buffer would pop up with that info. So, basically, I need to get the associated properties of the widget in the tree to a BUI list interface – but I'm not going to know which widget is selected, naturally, since a user can pick any from the tree.

So I don't think I could use just a general function that I could attach to a :get-entries-function keyword, I don't think, because I won't know what those entries will be until the user selects a widget.

Does that make a bit more sense? Lemme know if I'm still unclear and I'm happy to clarify as best I can; thanks a ton!

WammKD commented 5 years ago

Ah! I figured it out; I think, because the example on the main page didn't include an example of passing anything to the function for the :get-entries-function, – for whatever reason – it took my brain a bit to realize that the :args of bui-list-get-display-entries, etc. get passed to the :get-entries-function/:describe-function functions. Maybe because the example is also receiving them as &rest so my brain wasn't seeing how the pair ((cons 'id bundles)) was getting received by the function, as opposed to if it had specific and individual parameters.

I dunno; either way, I got my example working. And, since I don't think I've said so – yet –, thanks a ton for this library. It made representing what data I have super easy and, undoubtedly, saved me a lot of time, otherwise.

alezost commented 5 years ago

Thank you, I'm glad to see that you got it working. The example does not show all the features of BUI. So if you have more questions, you are welcome to ask. But if you will open a new issue, please mention me with @alezost tag, otherwise I could miss the issue.