minad / cape

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

company-bibtex #30

Closed mclearc closed 2 years ago

mclearc commented 2 years ago

I'm trying to get company-bibtex working with cape-company-to-capf but so far have been unsuccessful (this is likely entirely my fault). Here's my config for company-bibtex:

(use-package company-bibtex
  :bind (("<C-tab>" . company-bibtex))
  :after corfu
  :config
  ;; use with corfu/cape
  (setq-local completion-at-point-functions
              (mapcar #'cape-company-to-capf
                      (list #'company-bibtex)))
  (setq company-bibtex-bibliography cpm-bibliography)
  (setq company-bibtex-org-citation-regex "-?@"))

This doesn't seem to work unless I call company-mode (and then it works via company and not corfu....). Any help is appreciated.

minad commented 2 years ago

It ist wrong to bind company-bibtex to a key. You have to define instead:

(defalias 'bibtex-capf (cape-interactive-capf (cape-company-to-capf 'company-bibtex)))

And bind that to a key.

minad commented 2 years ago

@mclearc Did you consider porting company-bibtex to the Capf API? This is generally the best way forward in particular for relatively simple backends like this bibtex backend, since it would help most users in the long term. Of course cape-company-to-capf is always a viable stop gap measure, but from what I've seen it can be avoided in most cases with little effort.

There are a few sophisticated package like company-coq or purescript-ide which come with more complex Company backends. For such complex packages porting to Capf is more work. Furthermore it does not seem to be a good idea in those cases to creating competing packages or forks. For such packages it would be better to ask the authors to consider the move to the Emacs API.

mclearc commented 2 years ago

Thanks so much -- that worked perfectly. Agreed that a port seems like a good idea here. If I can find the time I'll do so and put a link here. But thanks for the great stop-gap solution!

mclearc commented 2 years ago

FYI: this should be helpful for those looking for a replacement for company-bibtex....