[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kind-icon f080f3d 15/51: Remove minor mode in favor of
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kind-icon f080f3d 15/51: Remove minor mode in favor of c-in-r-f wrapper function |
Date: |
Wed, 17 Nov 2021 15:57:41 -0500 (EST) |
branch: externals/kind-icon
commit f080f3df508edc7ebce54f17d4626e466aa0e694
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Remove minor mode in favor of c-in-r-f wrapper function
---
kind-icon.el | 49 +++++++++++++++++++------------------------------
1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/kind-icon.el b/kind-icon.el
index b24782e..7d85a74 100644
--- a/kind-icon.el
+++ b/kind-icon.el
@@ -263,36 +263,25 @@ and its result used as the affixation suffix, first
setting the
suffix))))
candidates)))
-(defvar-local kind-icon--orig-completion-function nil
- "The prior completion-in-region-function we are wrapping.")
+(defun kind-icon-enhance-completion (completion-function)
+ "A wrapper for completion-in-region-functions.
+This wrapper sets a custom affixation-function which places an
+icon in the prefix slot. Use it like:
-(defun kind-icon--completion-in-region-function (start end table &optional
pred)
- "Set a custom affixation function for kind-icon.
-Only operates if no affixation function is already set."
- (let* ((str (buffer-substring start (point)))
- (metadata (completion-metadata str table pred))
- (kind-func (kind-icon--metdata-get metadata "company-kind"))
- (ann-func (kind-icon--metdata-get metadata "annotation-function"))
- (aff-func (kind-icon--metdata-get metadata "affixation-function")))
- (if (and kind-func (not aff-func)) ;; add a custom affixation function
- (setq completion-extra-properties
- (plist-put completion-extra-properties :affixation-function
- (kind-icon--affixation-function kind-func ann-func)))))
- (funcall kind-icon--orig-completion-function start end table pred))
-
-(define-minor-mode kind-icon-mode
- "Minor mode enabling kind prefix by wrapping the
completion-in-region-function."
- :init-value nil
- (if completion-in-region-function
- (if kind-icon-mode
- (progn
- (kind-icon-reset-cache)
- (setq-local
- kind-icon--orig-completion-function completion-in-region-function
- completion-in-region-function
#'kind-icon--completion-in-region-function))
- (setq-local
- completion-in-region-function kind-icon--orig-completion-function
- kind-icon--orig-completion-function nil))
- (error "Cannot enable kind-icon: no completion-in-region-function found")))
+ (setq completion-in-region-function
+ (kind-icon-enhance-completion
+ #'original-completion-in-region-function))"
+ (lambda (start end table &optional pred)
+ (let* ((str (buffer-substring start (point)))
+ (metadata (completion-metadata str table pred))
+ (kind-func (kind-icon--metdata-get metadata "company-kind"))
+ (ann-func (kind-icon--metdata-get metadata "annotation-function"))
+ (aff-func (kind-icon--metdata-get metadata "affixation-function")))
+ (when (and kind-func (not aff-func)) ;; add a custom affixation function
+ (kind-icon-reset-cache)
+ (setq completion-extra-properties
+ (plist-put completion-extra-properties :affixation-function
+ (kind-icon--affixation-function kind-func
ann-func)))))
+ (funcall completion-function start end table pred)))
(provide 'kind-icon)
- [elpa] externals/kind-icon 962c209 20/51: Add custom variable watcher for instant updates, (continued)
- [elpa] externals/kind-icon 962c209 20/51: Add custom variable watcher for instant updates, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon c0d50c6 40/51: minor reformat, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon be77196 19/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon ea06e81 47/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon dce91ac 49/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 4896e1e 32/51: Switch module & ruler icons, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 21a2861 34/51: Require svg-lib, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 12aa1a9 42/51: Mention how to clear cache, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 8087c8e 44/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon ba37562 09/51: more docs, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon f080f3d 15/51: Remove minor mode in favor of c-in-r-f wrapper function,
ELPA Syncer <=
- [elpa] externals/kind-icon b88965b 28/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon ab3c6d5 24/51: Expand material icon description and mention text-based icons, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 5bf075d 16/51: Add some two character short-text codes, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon e4d941b 45/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 3746bd4 43/51: Fix function name typo, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 4b3a770 51/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 5defd86 23/51: Clean up install info, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 15de78d 22/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon ec8b77e 25/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 51f77db 50/51: Update README.md, ELPA Syncer, 2021/11/17