Open cartolari opened 8 years ago
Hi there.
So far, this works really well, with the following caveats:
Scanning for dabbrevs...done
is echoed constantly.It's super fast, though, which is something my alternative method isn't yet. Don't worry about fixing your code. If my method doesn't work out, I can fix it myself.
Thanks for the reponse.
Regarding the issues:
thing-at-point
.message
with flet
inside the my/dabbrev-find-all
, and the issue is gone.One thing I've noted, and please correct me if I'm wrong, is that the completion-at-point-functions
return every possible completion (when company-flx is enabled) and you sort and filter them in a company transform, company-flx-transformer
, right?
So when you have two completion-at-point-functions
and the first provides no matching candidates there'd be no way for the next one to be used, because at the point that the flx score is calculated it's to late for the next one to be called.
The case I detected this was with the ggtags-completion-at-point
and with my/dabbrev-capf
.
@cartolari it seems that the snippet you originally posted is gone now. Do you still have it?
Sorry for the delay, I should have left the snippet here in the issue. One thing I've noticed is that this code is not so fast for large buffers, so it may require some tweaks to be implemented in company-flx.
(defun my/dabbrev-find-all (abbrev)
"Return a list of expansions matched by ABBREV."
(let ((dabbrev-check-other-buffers t)
(dabbrev-check-all-buffers nil))
(flet ((message (&rest args)))
(dabbrev--reset-global-variables)
(dabbrev--find-all-expansions abbrev t))))
(defun my/dabbrev-capf ()
"Dabbrev 'complete-at-point-functions' implementation."
(let ((bounds (bounds-of-thing-at-point 'symbol)))
(list
(car bounds)
(cdr bounds)
(my/dabbrev-find-all (substring (thing-at-point 'symbol t) 0 1))
:exclusive 'no)))
One thing I miss in company-flx is support for the
company-dabbrev
backend, so I implemented a really simple function forcompletion-at-point-functions
in terms of dabbrev.The capf function,
my/dabbrev-capf
, can be found in my dotfiles, inside init-company.el.Maybe company-flx could add something like this as an alternative to the
company-dabbrev
backend.