branch: externals/kind-icon commit 962c2094bc81f146ef664ad7a4eb9197dbc8280a Author: JD Smith <93749+jdtsm...@users.noreply.github.com> Commit: JD Smith <93749+jdtsm...@users.noreply.github.com>
Add custom variable watcher for instant updates --- README.md | 2 +- kind-icon.el | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5fdb026..8d2f0db 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The configuration defaults should work fine, but kind-icon can be customized to ### Variables -`kind-icon` has a few customization variables that allows you to configure its appearance. Note that since the styled icons are cached, changes to the mapping, font size, or other variables in an initialized buffer should be followed by `M-x kind-icon-reset-cache` (or just restart Emacs). +`kind-icon` has a few customization variables that allows you to configure its appearance. **Key configurations:** diff --git a/kind-icon.el b/kind-icon.el index 3e2f46a..7716211 100644 --- a/kind-icon.el +++ b/kind-icon.el @@ -54,7 +54,6 @@ ;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;;; Code: - (defgroup kind-icon nil "Completion prefixes from :company-kind." :group 'convenience @@ -284,4 +283,15 @@ 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 variable changes." + (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)