[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kind-icon 0921fe2 35/51: Separate kind-icon--cache, an
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kind-icon 0921fe2 35/51: Separate kind-icon--cache, and return ?? when kind missing |
Date: |
Wed, 17 Nov 2021 15:57:45 -0500 (EST) |
branch: externals/kind-icon
commit 0921fe2cf8edacf63e6b64abae69165f20bb590c
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Separate kind-icon--cache, and return ?? when kind missing
---
kind-icon.el | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/kind-icon.el b/kind-icon.el
index 03ea6f9..ee77529 100644
--- a/kind-icon.el
+++ b/kind-icon.el
@@ -177,29 +177,35 @@ 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 as :display-icon in `kind-icon-mapping', and
-returns the cached value, if set. If
-`kind-icon-blend-background' is non-nil, computes a blend between
-a nominal background color (from either the background property
-of `kind-icon-default-face', if set, or frame background color)
-and foreground. For the foreground color, uses the :face
-mapping's :foreground color, the `kind-icon-default-face'
+Caches this badge in `kind-icon--cache', and returns the cached
+value, if set. If no matching kind is specified, returns a `??'
+warning label. For the foreground color of the badge, uses the
+:face mapping's :foreground color, the `kind-icon-default-face'
foreground, or the default frame foreground, in that order of
-priority. If `kind-icon-blend-background' is nil, the background
-is taken from the :face background, `kind-icon-default-face`, or
-frame background-color."
- (when-let ((map (assq kind kind-icon-mapping))
- (plist (cddr map)))
- (or (plist-get plist :display-icon)
+priority. If `kind-icon-blend-background' is non-nil, computes a
+blend between a nominal background color (from either the
+background property of `kind-icon-default-face', if set, or the
+frame background color) and the foreground. If
+`kind-icon-blend-background' is nil, the background is taken from
+the :face's background, `kind-icon-default-face', or the frame
+background-color."
+ (or (alist-get kind kind-icon--cache)
+ (when-let ((map (assq kind kind-icon-mapping))
+ (plist (cddr map)))
(let* ((kind-face (plist-get plist :face))
(col (if kind-face
(face-attribute kind-face :foreground nil t)
(if kind-icon-default-face
(face-attribute kind-icon-default-face :foreground
nil t)
(frame-parameter nil 'foreground-color))))
- (kind-face-bg (and kind-face (face-attribute kind-face
:background nil t)))
+ (kind-face-bg (and kind-face
+ (face-attribute kind-face :background nil t)))
(default-bg (if kind-icon-default-face
(face-attribute kind-icon-default-face
:background nil t)
(frame-parameter nil 'background-color)))
@@ -234,14 +240,14 @@ frame background-color."
(concat " " txt " "))))
(propertize txt-disp 'face
`(:weight bold :foreground ,col
:background ,bg-col))))))
- (plist-put plist :display-icon disp)
- disp))))
+ (if disp
+ (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)
- (cl-loop for item in kind-icon-mapping
- do (plist-put (cddr item) :display-icon nil)))
+ (setq kind-icon--cache nil))
(defun kind-icon--affixation-function (kind-func &optional ann-func)
"Create and return a custom kind-icon affixation function.
- [elpa] externals/kind-icon 366232c 36/51: Quiet svg-lib-icon warning, (continued)
- [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, 2021/11/17
- [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 <=
- [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
- [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