minad / cape

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

Company wrapper when used for thing starting with non-letter is sometimes inconsistent with original company command #72

Closed BlankSpruce closed 1 year ago

BlankSpruce commented 1 year ago

In my setup I have installed the following packages:

The last one provides a couple of templates for org-mode that start with <: image In particular I'm interested in this template: https://github.com/AndreaCrotti/yasnippet-snippets/blob/master/snippets/org-mode/src which has <src key.

I use cape-company-to-capf to get relevant yasnippet templates. For the purpose of this report I invoke it with M-: (call-interactively (cape-interactive-capf (cape-company-to-capf #'company-yasnippet))). Given the initial state of the buffer: image

I get a long list of candidates and among them is <src I'm looking for: image image

When my buffer is in this state: image

it immediately expands to: image which is associated to this snippet instead https://github.com/AndreaCrotti/yasnippet-snippets/blob/master/snippets/org-mode/setup (key set). This result is "kind of correct" since it's at least consistent with how company behaves here (example further in this report).

With buffer state: image

no candidates are offered but a cryptic message is printed instead: image

And with this buffer state: image

I don't get neither candidates nor it expands (because there should be the only candidate that matches <src) with similar cryptic message: image

Comparing that situation to invoking M-x company-yasnippet these are the results:

There's not much to do with unexpected suggestion at input <s because that's how company behaves here but at least the wrapper should offer the same candidates as company does. As far as I've experienced that it behaves like that with at least two letter inputs starting with non-letter.

minad commented 1 year ago

Thanks for the report. Unfortunately I need more information to act.

Can you try this with Corfu and provide me with a minimal self-contained example which I can actually test? I haven't used the Company Capf converter much, but in my basic tests of some common Company backends it went well. It exceeds my bandwidth to support and test additional packages like Yasnippet. Some parts of Cape are tricky, e.g., cape-company-to-capf and cape-super-capf. I am not sure, but I think some people already use Corfu+cape-company-to-capf+company-yasnippet successfully.

If you are interested it would be great if you dig deeper and figure out the reason for the deviation you observed. Ideally you could provide an example where cape-company-to-capf does the wrong thing for a Company backend, which does not depend on an additional package like Yasnippet?

(Maybe someone has written a yasnippet-capf in the meantime, which you could try. If not, you could also use my Tempel package, but that's maybe asking too much if you are already heavily invested in Yasnippet.)