[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eglot-inactive-regions 3569bd5dc7 24/66: Properly enable/c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eglot-inactive-regions 3569bd5dc7 24/66: Properly enable/clean up state on minor mode toggle |
Date: |
Fri, 6 Dec 2024 06:59:53 -0500 (EST) |
branch: elpa/eglot-inactive-regions
commit 3569bd5dc7b42bdc9a80fe922aaf91d9765a77b4
Author: Filippo Argiolas <filippo.argiolas@gmail.com>
Commit: Filippo Argiolas <filippo.argiolas@gmail.com>
Properly enable/clean up state on minor mode toggle
---
clangd-inactive-regions.el | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/clangd-inactive-regions.el b/clangd-inactive-regions.el
index 52d62bac70..e753e09678 100644
--- a/clangd-inactive-regions.el
+++ b/clangd-inactive-regions.el
@@ -66,17 +66,6 @@ Allowed methods:
'((t (:extend t)))
"Face used to inactive code with shade-background method.")
-(define-minor-mode clangd-inactive-regions-mode
- ""
- :global nil
- (cond (clangd-inactive-regions-mode
- (add-function :after (default-value
'font-lock-fontify-region-function)
- #'clangd-inactive-regions--fontify))
- (t
- (remove-function (default-value 'font-lock-fontify-region-function)
- #'clangd-inactive-regions--fontify)
- (clangd-inactive-regions-cleanup))))
-
(defun clangd-inactive-regions-set-method (method)
(interactive
(list (let ((completion-ignore-case t)
@@ -242,14 +231,33 @@ foreground colors, if the face doesn't exist yet create
it."
(push ov clangd-inactive-regions--overlays)))))))
-(cl-defmethod eglot-client-capabilities :around (server)
- (let ((base (cl-call-next-method)))
- (when (cl-find "clangd" (process-command (jsonrpc--process server))
- :test #'string-match)
- (setf (cl-getf (cl-getf base :textDocument)
- :inactiveRegionsCapabilities)
- '(:inactiveRegions t)))
- base))
+(define-minor-mode clangd-inactive-regions-mode
+ "Minor mode to enable Eglot support for clangd inactiveRegions extension."
+ :global nil
+ (cond (clangd-inactive-regions-mode
+ (clangd-inactive-regions--enable))
+ (t
+ (clangd-inactive-regions--disable))))
+
+(defun clangd-inactive-regions--enable ()
+ (add-function :after (default-value 'font-lock-fontify-region-function)
+ #'clangd-inactive-regions--fontify)
+
+ (cl-defmethod eglot-client-capabilities :around (server)
+ (let ((base (cl-call-next-method)))
+ (when (cl-find "clangd" (process-command (jsonrpc--process server))
+ :test #'string-match)
+ (setf (cl-getf (cl-getf base :textDocument)
+ :inactiveRegionsCapabilities)
+ '(:inactiveRegions t)))
+ base)))
+
+(defun clangd-inactive-regions--disable ()
+ (remove-function (default-value 'font-lock-fontify-region-function)
+ #'clangd-inactive-regions--fontify)
+ (clangd-inactive-regions-cleanup)
+ (cl-defmethod eglot-client-capabilities :around (server)
+ (cl-call-next-method)))
(cl-defmethod eglot-handle-notification
(_server (_method (eql textDocument/inactiveRegions))
- [nongnu] elpa/eglot-inactive-regions 437d09e552 53/66: revert to deprecated eglot functions, (continued)
- [nongnu] elpa/eglot-inactive-regions 437d09e552 53/66: revert to deprecated eglot functions, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions bf51947630 55/66: prefer when-let if no else clause is needed, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 193827fdeb 58/66: missing clangd references after rename, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 5c20f58422 60/66: clean up after review on emacs-devel, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 80c1b60009 44/66: Revert "revert to deprecated eglot functions", ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 26f3b61b45 51/66: readme update, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions badb4e403a 46/66: cleanup on major mode changes, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions a810593308 59/66: bump version to 0.6, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 7e4eb584e0 61/66: fallback to deprecated functions, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 6ac373dfd0 62/66: bump version after emacs-devel review, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3569bd5dc7 24/66: Properly enable/clean up state on minor mode toggle,
ELPA Syncer <=
- [nongnu] elpa/eglot-inactive-regions 3b248e0684 37/66: Update install section in README.md, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3ca295f189 45/66: switch to global minor mode, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 15259e94b2 50/66: move to defcustoms for customization, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 5b48f4940d 54/66: rename shading method to shading style, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 2d93c0cab0 04/66: forgot some package comment, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3cb6ed0bc4 34/66: update README.md, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 5e08869dd6 36/66: Bump version to 0.3, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 89ffc22d6f 49/66: rename main package file, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 7a9e3ac805 57/66: refactor and cleanup, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 12794454af 41/66: properly check if mode is enabled, ELPA Syncer, 2024/12/06