aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-23 11:03:12 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-23 11:03:12 +0100
commit9dd3db84b9164517239121188e58e188fe13b393 (patch)
tree8a9366694fddb09db4d8ce900554345023012032
parent2249680459ad9c46bfddb2c28c277b73ee9c4aa5 (diff)
clean up compose-buffer capf control flow
-rw-r--r--lisp/mastodon-toot.el39
1 files changed, 28 insertions, 11 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 96ff8fc..c13d43b 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -114,7 +114,19 @@ This is only used if company mode is installed."
:type 'boolean)
(defcustom mastodon-toot--use-company-for-completion nil
- "Whether to use company for completion.")
+ "Whether to use company completion backends directly.
+When non-nil, company backends `mastodon-toot-mentions' and
+`mastodon-toot-tags' are used for completion.
+
+A nil setting will use `completion-at-point-functions' for
+completion, which also work with company, provided that the
+backend `company-capf' is enabled.
+
+If setting this to non-nil, ensure `corfu-mode' is disabled as the
+two are incompatible.
+
+When the `completion-at-point-functions' backends are more
+complete, direct company backends will be removed.")
(defcustom mastodon-toot--completion-style-for-mentions
(if (require 'company nil :noerror) "following" "off")
@@ -1526,16 +1538,21 @@ a draft into the buffer."
(mastodon-toot--get-max-toot-chars))
;; set up completion:
(when mastodon-toot--enable-completion
- ;; (setq-local
- (set
- (make-local-variable 'completion-at-point-functions)
- (add-to-list
- 'completion-at-point-functions
- #'mastodon-toot--mentions-capf))
- (add-to-list
- 'completion-at-point-functions
- #'mastodon-toot--tags-capf)
- (when mastodon-toot--use-company-for-completion
+ (if (not mastodon-toot--use-company-for-completion)
+ ;; capf
+ (progn
+ (set ; (setq-local
+ (make-local-variable 'completion-at-point-functions)
+ (add-to-list
+ 'completion-at-point-functions
+ #'mastodon-toot--mentions-capf))
+ (add-to-list
+ 'completion-at-point-functions
+ #'mastodon-toot--tags-capf))
+ ;; company
+ (set (make-local-variable 'company-backends)
+ (add-to-list 'company-backends 'mastodon-toot-mentions))
+ (add-to-list 'company-backends 'mastodon-toot-tags)
(company-mode-on)))
;; after-change:
(make-local-variable 'after-change-functions)