minad / cape

🦸cape.el - Completion At Point Extensions
GNU General Public License v3.0
584 stars 20 forks source link

Make cape-char-define available publicly. #61

Closed jpoiret closed 1 year ago

jpoiret commented 1 year ago

This makes cape-char-define available publicly, so that people are able to translate their own input methods to capfs. This can be used with e.g. Agda's own input method.

minad commented 1 year ago

There is no need to make the API public. You can use it anyway but I won't give guarantees about API stability.

jpoiret commented 1 year ago

I don't think that there is no need for such a feature, I gave an example in the MR description, although not very fleshed out: Agda provides its own input method, and it is well suited to input the usual Unicode characters needed for Agda, but I don't like the input method mechanism itself, and would prefer a capf to be used with corfu. I understand why you would not want to stabilize this part of the API though. Do you think a MR that only modifies eval-when-compileto eval-and-compile for the helper function so that it's possible to use cape-char--define at runtime would be okay? That way one could still use those internals, without making any guarantees still.

minad commented 1 year ago

I see the need, but now that you reminded me about how brittle the code is, I don't want to provide it at all. It is a hack with a fake pure function. It is amazing that I am not getting miscompilation reports. Sorry!

There are two possible solutions:

  1. We rewrite the code used here, such that it is more robust. This will mainly involve accessing the input method data in a more robust way. If a more satisfactory solution would be found, making the API public would be okay. Unfortunately I don't know if there is a better way. See also the comment:

https://github.com/minad/cape/blob/3ccb3bbd6633e63444de3112a50a6b0f18d8122b/cape-char.el#L29-L31

  1. Instead write a Capf based on the raw data in agda-mode. I am sure this will lead to a much better result in the end, also since you can integrate more cleanly with other Agda synthesis/completion features.

https://github.com/agda/agda/blob/fff069926156b5a7ef4f56a2397b8f38fe1e3691/src/data/emacs-mode/agda-input.el#L182

jpoiret commented 1 year ago

I see the need, but now that you reminded me about how brittle the code is, I don't want to provide it at all. It is a hack with a fake pure function. It is amazing that I am not getting miscompilation reports. Sorry!

I didn't realize that at first (I'm not an elisp expert in any way) but I totally see your point now.

  1. Instead write a Capf based on the raw data in agda-mode. I am sure this will lead to a much better result in the end, also since you can integrate more cleanly with other Agda synthesis/completion features.

I realized that this should actually be the way to go right after writing my comment, so I ended up doing that instead. It's not as easy as just adding one elisp line to my config, but should definitely be cleaner and may end up in upstream if I find the time to do that. I took inspiration from your code to add annotations and the :exit-function :) thanks for your feedback