felko / neuron-mode

An emacs mode for editing Zettelkasten notes with neuron
GNU General Public License v3.0
118 stars 21 forks source link

Counsel dep #39

Closed bbuccianti closed 4 years ago

bbuccianti commented 4 years ago

I just wanted to ask if this is strictly necessary. I'm not a user of counsel, actually I use selectrum. Would be great to at least have the option of use other completion systems kindof.

It makes sense?

felko commented 4 years ago

I have no idea how to implement this but I'll look into it, thanks for the suggestion

bbuccianti commented 4 years ago

Maybe we can start replacing ivy-read with completing-read? It's built-in and I think (I'm not sure) we can achieve the same that ivy-read does easily.

Also, changing it would enable users to set completing-read-function as wanted, in order to use the ivy, helm, selectrum or whatever.

felko commented 4 years ago

I didn't know emacs had native support for this kind of completion, I just tried with completing-read and everything works exactly like ivy. In fact, I'm pretty sure ivy somehow overrides completing-read, since I get all the highlighting and fuzzy matching which is obviously not builtin behavior. That may also come from my emacs distribution (doom).

As for customizing the completion function directly, how would that look like? I'm afraid that, by providing a variable that would point either to ivy-read or to whatever helm and selectrum use, I need to write a lot of glue code to adapt the agrument to each particular interface. Also, I'm not sure how to handle dependencies in that case, can I just drop the counsel dependency and dynamically require the corresponding modules?

bbuccianti commented 4 years ago

Emacs has the ability to change the completion function!

In docs: completing-read-function is a variable defined in ‘minibuffer.el’. Documentation: The function called by ‘completing-read’ to do its work. It should accept the same arguments as ‘completing-read’.

So the user can choose which completing read function to use! Maybe your completing-read-function is ivy-read so nothing changes for you. Making sure that we use completing-read arguments it's up to ivy, helm or selectrum adapt to that function and use those arguments for completion. This makes sense?

I don't know how to handle dependencies. If completing-read has worked, that means that we have only this functions from counsel?

'counsel--find-file-matcher

counsel-find-file-map

(I've just grepped for counsel, maybe they are more)

felko commented 4 years ago

Ok that makes sense, thanks a lot for the explanation, this should be easy to implement then

felko commented 4 years ago

Alright, this should be working now in https://github.com/felko/neuron-mode/commit/27e288cfd5f67a54e63c087460052ceef195c46c Let me know if it works with your completion backend

bbuccianti commented 4 years ago

That was fast!

It's working!

Thanks

felko commented 4 years ago

Cool, thanks for helping me implement this