[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eglot-inactive-regions 2346944d4b 05/66: Add clean up and
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eglot-inactive-regions 2346944d4b 05/66: Add clean up and refresh functions |
Date: |
Fri, 6 Dec 2024 06:59:50 -0500 (EST) |
branch: elpa/eglot-inactive-regions
commit 2346944d4b79cb77477658a0fabc44c7d0eb83cd
Author: Filippo Argiolas <filippo.argiolas@gmail.com>
Commit: Filippo Argiolas <filippo.argiolas@gmail.com>
Add clean up and refresh functions
After a face or theme change the inactive region colors become
obsolete. Add a couple of function to refresh them. Still not sure
about if and how to refresh them automatically, maybe from a
load-theme advice?
---
eglot-clangd-inactive-regions.el | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/eglot-clangd-inactive-regions.el b/eglot-clangd-inactive-regions.el
index 1e0243aa86..1160034dbc 100644
--- a/eglot-clangd-inactive-regions.el
+++ b/eglot-clangd-inactive-regions.el
@@ -40,6 +40,7 @@ region. The lower the blending factor the more text will look
dim.")
(defvar-local eglot-clangd-inactive-regions-overlays '())
+(defvar-local eglot-clangd-inactive-regions-ranges '())
;; let's shorten namespace to ecir for private functions:
;; [e]glot-[c]langd-[i]nactive-[r]egions
@@ -60,6 +61,7 @@ create an overlay with a darkened face for each region with a
different face. Current face foreground is blended with
background with OPACITY as a blending factor. Results may vary
depending on current theme."
+ (push (cons beg end) eglot-clangd-inactive-regions-ranges)
(save-excursion
(goto-char beg)
(let ((cur-face (face-at-point))
@@ -91,6 +93,23 @@ depending on current theme."
(setq cur-face new-face)))
(forward-char)))))
+(defun eglot-clangd-inactive-regions-refresh ()
+ "Force a refresh of known inactive regions without waiting for a
+new notification from the server. Useful to update colors after a
+face or theme change."
+ (let ((ranges (copy-tree eglot-clangd-inactive-regions-ranges)))
+ (eglot-clangd-inactive-regions-cleanup)
+ (dolist (range ranges)
+ (let ((beg (car range))
+ (end (cdr range)))
+ (ecir--darken-region beg end eglot-clangd-inactive-regions-opacity)))))
+
+(defun eglot-clangd-inactive-regions-cleanup ()
+ "Clean up inactive regions."
+ (mapc #'delete-overlay eglot-clangd-inactive-regions-overlays)
+ (setq eglot-clangd-inactive-regions-overlays '())
+ (setq eglot-clangd-inactive-regions-ranges '()))
+
(cl-defmethod eglot-client-capabilities :around (server)
(let ((base (cl-call-next-method)))
(when (cl-find "clangd" (process-command (jsonrpc--process server))
@@ -107,8 +126,7 @@ depending on current theme."
(cl-getf textDocument :uri))))
(buffer (find-buffer-visiting path)))
(with-current-buffer buffer
- (mapc #'delete-overlay eglot-clangd-inactive-regions-overlays)
- (setq eglot-clangd-inactive-regions-overlays '())
+ (eglot-clangd-inactive-regions-cleanup)
(cl-loop
for r across regions
for (beg . end) = (eglot--range-region r)
- [nongnu] elpa/eglot-inactive-regions 2e52c1a10a 19/66: Use my own forward function, (continued)
- [nongnu] elpa/eglot-inactive-regions 2e52c1a10a 19/66: Use my own forward function, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3876101626 31/66: Update README., ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions b0ade8c12e 21/66: Handle face list properties, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3d3280c415 48/66: rename to eglot-inactive-regions.el, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 475864a1a3 65/66: exclude screenshots from the tarball, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 17c9db32d3 02/66: initial commit, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions e15124a898 07/66: Rewrite the darkening logic using fontify-region, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions e7be73b354 15/66: Invert shading factor, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions b81249c566 23/66: Update README with caveats section, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 4b01aba42f 29/66: Fix package-lint warnings, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 2346944d4b 05/66: Add clean up and refresh functions,
ELPA Syncer <=
- [nongnu] elpa/eglot-inactive-regions 3ba8e528f1 06/66: allow to change opacity on the fly, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 10f1772888 09/66: Drop eglot from the name, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 2736b46310 10/66: Update dependencies and some minor changes, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 15d6db2d6d 13/66: Add some helper methods to set UI options, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions ae67afac14 12/66: Use overlays instead of changing text properties, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 343abb100c 26/66: Update README.md, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions e25016ddb8 22/66: Do not flush all inactive regions, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions d021d96fef 25/66: Update screenshots, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 52d2f80ccb 28/66: Tentatively limit global fontification hook to classic c modes, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 4ae3491ae3 39/66: doc and function names cleanup, ELPA Syncer, 2024/12/06