[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kind-icon f6de892 37/51: Remove add-variable-watcher in
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kind-icon f6de892 37/51: Remove add-variable-watcher in favor of custom :set |
Date: |
Wed, 17 Nov 2021 15:57:46 -0500 (EST) |
branch: externals/kind-icon
commit f6de89210ac8ee23b95b55142f1930f671e39eae
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Remove add-variable-watcher in favor of custom :set
---
kind-icon.el | 49 +++++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/kind-icon.el b/kind-icon.el
index 0af3b1c..b431129 100644
--- a/kind-icon.el
+++ b/kind-icon.el
@@ -54,6 +54,19 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Code:
+(defvar kind-icon--cache nil
+ "The cache of styled and padded label (text or icon).
+An alist.")
+
+(defun kind-icon-reset-cache ()
+ "Remove all cached icons from `kind-icon-mapping'."
+ (interactive)
+ (setq kind-icon--cache nil))
+
+(defun kind-icon--set-default-clear-cache (&rest args)
+ (kind-icon-reset-cache)
+ (apply 'set-default args))
+
(defgroup kind-icon nil
"Completion prefixes from :company-kind."
:group 'convenience
@@ -61,6 +74,7 @@
(defcustom kind-icon-use-icons t
"Whether to use icons for prefix display."
+ :set #'kind-icon--set-default-clear-cache
:type 'boolean)
(defvar svg-lib-icon)
@@ -119,6 +133,7 @@ the background color is taken from the :face's background
in this
map, or, if that is missing or unspecified, from the frame's
background color."
:link '(url-link "https://materialdesignicons.com")
+ :set #'kind-icon--set-default-clear-cache
:type '(repeat
(list :tag "Mapping"
(symbol :tag "Kind")
@@ -131,15 +146,19 @@ background color."
:action kind-icon--preview))
(:face (face :tag "Face")))))))
+
+
(defcustom kind-icon-blend-background t
"Whether to set a custom background blended from foreground."
- :type 'boolean)
+ :type 'boolean
+ :set #'kind-icon--set-default-clear-cache)
(defcustom kind-icon-blend-frac 0.12
"Fractional blend between foreground and background colors.
This is used for the prefix background, if
kind-icon-blend-background is non-nil."
- :type 'float)
+ :type 'float
+ :set #'kind-icon--set-default-clear-cache)
(defcustom kind-icon-default-face nil
"The default face to use for coloring.
@@ -149,13 +168,15 @@ the foreground color is taken from the foreground of this
face,
or (if nil) to the default frame foreground color. The
background color is also taken from this face, if provided,
otherwise defaulting to the frame background color."
- :type 'face)
+ :type 'face
+ :set #'kind-icon--set-default-clear-cache)
(defcustom kind-icon-default-style
'(:padding 0 :stroke 0 :margin 0 :radius 0 :height 1.0 :scale 1.0)
"Default style parameters for building SVG icons.
See `svg-lib-style-compute-default'."
- :type 'plist)
+ :type 'plist
+ :set #'kind-icon--set-default-clear-cache)
(defun kind-icon--preview (widget _e)
(let* ((icon (widget-value widget)))
@@ -178,10 +199,6 @@ float FRAC."
(cdr (assq (intern type-name) metadata))
(plist-get completion-extra-properties (intern (format ":%s" type-name)))))
-(defvar kind-icon--cache nil
- "The cache of styled and padded label (text or icon).
-An alist.")
-
(defun kind-icon-formatted (kind)
"Return a formatted kind badge, either icon or text abbreviation.
Caches this badge in `kind-icon--cache', and returns the cached
@@ -245,11 +262,6 @@ background-color."
(setf (alist-get kind kind-icon--cache) disp)
(propertize (concat pad-left "??" pad-right) 'face
font-lock-warning-face))))))
-(defun kind-icon-reset-cache ()
- "Remove all cached icons from `kind-icon-mapping'."
- (interactive)
- (setq kind-icon--cache nil))
-
(defun kind-icon--affixation-function (kind-func &optional ann-func)
"Create and return a custom kind-icon affixation function.
The company-kind function should be passed in as KIND-FUNC and
@@ -292,15 +304,4 @@ icon in the prefix slot. Use it like:
(kind-icon--affixation-function kind-func
ann-func)))))
(funcall completion-function start end table pred)))
-(defun kind-icon--guard-config (_s _n _o where)
- "Dump the variable cache when the variables change."
- (if where
- (with-current-buffer where
- (kind-icon-reset-cache))
- (kind-icon-reset-cache)))
-
-(add-variable-watcher 'kind-icon-mapping #'kind-icon--guard-config)
-(add-variable-watcher 'kind-icon-use-icons #'kind-icon--guard-config)
-(add-variable-watcher 'kind-icon-blend-background #'kind-icon--guard-config)
-(add-variable-watcher 'kind-icon-blend-frac #'kind-icon--guard-config)
(provide 'kind-icon)
- [elpa] externals/kind-icon ffa75e7 21/51: Update README.md, (continued)
- [elpa] externals/kind-icon ffa75e7 21/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 01d76af 07/51: Make kind-prefix-reset-cache a command, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon eaeea12 12/51: Doc, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 3b0c9c3 11/51: Renamed kind-icon, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 366232c 36/51: Quiet svg-lib-icon warning, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 9a20879 30/51: Use widget-value in customize preview, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 9098597 33/51: Update kinds to match LSP spec, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon fcfe9ea 14/51: kind-icon-formatted: 3 char-width icon/centered 1 or 2 char text, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 8d6fa99 46/51: Update README.md, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon b88e809 48/51: kind-formatter -> margin-formatters, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon f6de892 37/51: Remove add-variable-watcher in favor of custom :set,
ELPA Syncer <=
- [elpa] externals/kind-icon 94ff0ac 13/51: customize interface for mappings, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon cfa3d73 38/51: Guard against network or other icon retrieval issues (text fallback), ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon ba0f94e 17/51: Re-enable mapping customization preview button, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 0921fe2 35/51: Separate kind-icon--cache, and return ?? when kind missing, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon 0d92763 31/51: add kinds constructor, event, reference, typeparameter, ELPA Syncer, 2021/11/17
- [elpa] externals/kind-icon c69da89 18/51: Updated docs, ELPA Syncer, 2021/11/17
- [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