d12frosted / vulpea

A collection of functions for note taking based on `org` and `org-roam`.
GNU General Public License v3.0
236 stars 12 forks source link

Preview notes as in consult-org-roam when searching or inserting #163

Open Cletip opened 1 year ago

Cletip commented 1 year ago

Hi! Yes, it's me again x)

I wanted to know if it was possible to visualize the note selected during the vulpea-find and vulpea-insert commands. Indeed, when you do org-roam-node-find and org-roam-node-insert, you can choose the desired node of course, but the current buffer teleports instantly to the node so you can immediately know which one it is.

I find this feature really useful, and it can save a lot of time if some notes look similar in the title.

Will it be possible to add a variable to have this feature?

I looked in org-roam, and I think the function that allows this feature would be "org-roam-node-read", but I don't see exactly how it does it. Also, I'm not sure if the implementation with org-roam is as efficient/simple with vulpea. I'm even less sure, because I haven't looked long and you know vulpea much better than I do, but maybe the "vulpea-select-from" function should be modified? I hope I don't offend you by saying this sentence, sorry if it offended you x). I'm just giving you some hints ^^

Thanks you (again) in advance for your answer.

d12frosted commented 1 year ago

Hey @Cletip

I wanted to know if it was possible to visualize the note selected during the vulpea-find and vulpea-insert commands. Indeed, when you do org-roam-node-find and org-roam-node-insert, you can choose the desired node of course, but the current buffer teleports instantly to the node so you can immediately know which one it is.

If you are talking about 'live preview' (e.g. when the buffer visits current note from completion), then it depends on your completion framework (ido/vertico/ivy/helm/etc). Which one do you use?

But I will take a look, maybe there are common ways to provide this functionality for completion frameworks, though I doubt there is general solution. And what you see might be something specifically implemented for Org Roam + your completion framework.

I find this feature really useful, and it can save a lot of time if some notes look similar in the title.

Indeed, sometimes I would enjoy this feature as well haha.

Cletip commented 1 year ago

If you are talking about 'live preview' (e.g. when the buffer visits current note from completion), then it depends on your completion framework (ido/vertico/ivy/helm/etc). Which one do you use?

I use Vertico.

To make sure my problem is well understood and at the risk of repeating myself, I will make the following comparison:

That's why I'm surprised when you say it comes from my completion framework: why would it work with org-roam and not vulpea if it's the same system between both?

Should I test with a neutral configuration? Do you have this famous "live preview" feature? In which case, my configuration must be the problem.

But I will take a look, maybe there are common ways to provide this functionality for completion frameworks, though I doubt there is general solution. And what you see might be something specifically implemented for Org Roam + your completion framework.

Yes you may be right, so the problem would come from the fact that this functionality should be implemented under vulpea?

But, I just did a search with "vertico" on the whole org-roam package. Vertico never appears :(

I find this feature really useful, and it can save a lot of time if some notes look similar in the title.

Indeed, sometimes I would enjoy this feature as well haha.

So you have it with Vulpea?

d12frosted commented 1 year ago

To make sure my problem is well understood and at the risk of repeating myself, I will make the following comparison:

Cool. This is exactly what I thought. Thanks for the clarification.

That's why I'm surprised when you say it comes from my completion framework:

Well, this is behaviour of completion system, right? Default completion system in Emacs doesn't do that. Ivy, Helm and Vertico (actually through Consult package) support 'live preview' for certain completions (like buffer, line, etc.). But someone needs to 'explain' what 'live preview' means in the current context. I also use Vertico, but I don't have such behaviour even with org-roam-node-find command. I suspect you are using some configuration (either one that you created or you just pulled it from somewhere) that implements 'live preview' of Org Roam nodes in your completion system.

why would it work with org-roam and not vulpea if it's the same system between both?

Because org-roam-node-find and vulpea-find are different 'completions'. Besides vulpea-note and org-roam-node are also different types and you need different functions to access note/node location (e.g. vulpea-note-path vs org-roam-node-file). It doesn't happen automagically :)

Yes you may be right, so the problem would come from the fact that this functionality should be implemented under vulpea?

Don't know. I need to take a look. I definitely will not add anything for specific completion systems. E.g. if it turns out that there is no common API to achieve this, then I may just provide some snippets in the README that people can use. Why? Because vulpea can't depend on all completion systems. Alternatively, I can release packages vulpea-consult, vulpea-ivy (just like I do with flyspell-correct).

So I need to investigate :)

So you have it with Vulpea?

No, I would enjoy :)

d12frosted commented 1 year ago

Ok, googled for consult and org-roam and found this package - https://github.com/jgru/consult-org-roam. And then checked your configurations and found that you are using it :)

https://github.com/Cletip/.emacs.d/blob/fec90bf3cfe432a546f907d23792fd71d405f860/config/org-mode.el#L2189-L2191

This is what gives you this behaviour 😸

Cletip commented 1 year ago

Ok, googled for consult and org-roam and found this package - https://github.com/jgru/consult-org-roam. And then checked your configurations and found that you are using it :)

https://github.com/Cletip/.emacs.d/blob/fec90bf3cfe432a546f907d23792fd71d405f860/config/org-mode.el#L2189-L2191

This is what gives you this behaviour smile_cat

Oh man, I didn't see your last post. I looked for myself, and indeed, it is exactly this package that allows to do this. You are a machine to have found this by yourself xD Thank you for that :)

So, org-roam doesn't allow to do live-preview without configuration. You see, I discover new things about my configuration every day xD

Well, that solves (maybe) part of the problem.

I looked at the code a little bit, and there is this: "(advice-add #'org-roam-node-read :override #'consult-org-roam-node-read)" So it was indeed the "org-roam-node-read" function that was the "problem" xD

What do you think to do? (Edit: I don't want to force your hand, you probably have other things to do and this is not an essential feature. It's just to have an idea of what I could do to lighten your time ^^). I would need a "consult-vulpea-node-read" function, but there is no such function on vulpea (a "vulpea-node-read" function). I can't see at which level it would be necessary to make moddification in vulpea to do this... Damn x) Do you have an idea how to do this? Is there anything I can do to help make this feature available ?