aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-22 18:57:50 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-22 18:57:50 +0100
commitd3cda98308f5bdf604d3d69800454d827fe814e9 (patch)
tree886c65db13e4acc6b1db5e97efa8b23694c56775 /lisp
parent0d94aba8baadcfa6337ed6b6a6a54caa3a0540a3 (diff)
a rough crack at handling company to capf conversion if cape/corfu
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-toot.el22
1 files changed, 16 insertions, 6 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 6162f52..92cbc53 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -1469,14 +1469,24 @@ a draft into the buffer."
;; no need to fetch from `mastodon-profile-account-settings' as
;; `mastodon-toot--max-toot-chars' is set when we set it
(mastodon-toot--get-max-toot-chars))
- ;; set up company backends:
+ ;; set up completion backends:
(when (require 'company nil :noerror)
(when mastodon-toot--enable-completion
- (set (make-local-variable 'company-backends)
- (add-to-list 'company-backends 'mastodon-toot-mentions))
- (add-to-list 'company-backends 'mastodon-toot-tags))
- (unless (bound-and-true-p corfu-mode) ; don't clash w corfu mode
- (company-mode-on)))
+ ;; convert our company backends into capfs for use with corfu:
+ ;; FIXME replace this with a customize
+ (if (and (require 'cape nil :noerror)
+ (bound-and-true-p corfu-mode))
+ (dolist (company-backend (list #'mastodon-toot-tags #'mastodon-toot-mentions))
+ (add-hook 'completion-at-point-functions
+ (cape-company-to-capf company-backend)
+ nil
+ 'local))
+ ;; else stick with company:
+ (set (make-local-variable 'company-backends)
+ (add-to-list 'company-backends 'mastodon-toot-mentions))
+ (add-to-list 'company-backends 'mastodon-toot-tags))
+ (unless (bound-and-true-p corfu-mode) ; don't clash w corfu mode
+ (company-mode-on))))
(make-local-variable 'after-change-functions)
(push #'mastodon-toot--update-status-fields after-change-functions)
(mastodon-toot--refresh-attachments-display)