branch: elpa/eglot-inactive-regions commit 878a9432aa5bc8a1d0e5d894920485b1899dd5f1 Author: Filippo Argiolas <filippo.argio...@gmail.com> Commit: Filippo Argiolas <filippo.argio...@gmail.com>
cache opacity for exiting shaded faces --- eglot-inactive-regions.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eglot-inactive-regions.el b/eglot-inactive-regions.el index 5d745cdbfd..544a3fa729 100644 --- a/eglot-inactive-regions.el +++ b/eglot-inactive-regions.el @@ -102,6 +102,8 @@ factor. All other face attributes you can customize.") (defvar eglot-inactive-regions-refresh-hook '()) (defvar eglot-inactive-regions-cleanup-hook '()) +(defvar eglot-inactive-regions-opacity-table (make-hash-table :test 'eq)) + (defvar-local eglot-inactive-regions--overlays '()) (setq-default eglot-inactive-regions--overlays '()) (defvar-local eglot-inactive-regions--ranges '()) @@ -189,14 +191,17 @@ If the correspondend \"eglot-inactive\" face doesn't not exist yet create it." (let* ((fg (face-foreground parent-face nil 'default)) (bg (face-background parent-face nil 'default)) (alpha eglot-inactive-regions-opacity) - (eglot-inactive-fg (eglot-inactive-regions--color-blend fg bg alpha)) + (current-alpha (gethash eglot-inactive-face eglot-inactive-regions-opacity-table))) (eglot-inactive-face-name (concat (face-name parent-face) "-eglot-inactive")) - (eglot-inactive-face (intern eglot-inactive-face-name))) + (eglot-inactive-face (intern eglot-inactive-face-name)) (unless (facep eglot-inactive-face) (let* ((doc-suffix " (eglot inactive region dimmed face)") (eglot-inactive-doc (concat (face-documentation parent-face) doc-suffix))) (custom-declare-face eglot-inactive-face '((t nil)) eglot-inactive-doc))) - (set-face-foreground eglot-inactive-face eglot-inactive-fg) + (unless (equal alpha current-alpha) + (let ((eglot-inactive-fg (eglot-inactive-regions--color-blend fg bg alpha))) + (set-face-foreground eglot-inactive-face eglot-inactive-fg) + (puthash eglot-inactive-face alpha eglot-inactive-regions-opacity-table))) eglot-inactive-face)) (defun eglot-inactive-regions--fontify (start end &optional verbose)