emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/eglot-inactive-regions 4ae3491ae3 39/66: doc and function


From: ELPA Syncer
Subject: [nongnu] elpa/eglot-inactive-regions 4ae3491ae3 39/66: doc and function names cleanup
Date: Fri, 6 Dec 2024 06:59:55 -0500 (EST)

branch: elpa/eglot-inactive-regions
commit 4ae3491ae3e8091ab3f0f23dec814b6ad1353f35
Author: Filippo Argiolas <filippo.argiolas@gmail.com>
Commit: Filippo Argiolas <filippo.argiolas@gmail.com>

    doc and function names cleanup
---
 README.md                  | 22 ++++++++++------------
 clangd-inactive-regions.el | 40 ++++++++++++++++++++--------------------
 2 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/README.md b/README.md
index 59179af5e7..e8c12c4dda 100644
--- a/README.md
+++ b/README.md
@@ -34,19 +34,16 @@ Windows code is correctly disabled.
 
 ## Installation
 
-You will need at least emacs 29.1 and clangd-17.
-
-At the moment the package is little more than an experiment. If you
-want to try it just copy the .el file somewhere in the load path.
+```lisp
+(unless (package-installed-p 'clangd-inactive-regions)
+  (package-vc-install 
"https://github.com/fargiolas/clangd-inactive-regions.el";))
+```
 
-Feedback, issues and pull requests more than welcome!
+You will need at least emacs 29.1 and clangd-17.
 
 ## Usage
 
 ```lisp
-(unless (package-installed-p 'clangd-inactive-regions)
-  (package-vc-install 
"https://github.com/fargiolas/clangd-inactive-regions.el";))
-
 (use-package clangd-inactive-regions
   :init
   (add-hook 'eglot-managed-mode-hook #'clangd-inactive-regions-mode)
@@ -60,7 +57,7 @@ Feedback, issues and pull requests more than welcome!
 
 As far as I know Emacs doesn't have a way to set foreground text
 opacity. Best would be a face attribute so that you can set it in an
-overlay covering each whole region and be done with it. Unfortunately
+overlay covering each inactive region and be done with it. Unfortunately
 there is no attribute for this yet.
 
 Hence `darken-foreground` method is a fragile and inefficient hack around
@@ -68,7 +65,8 @@ fontification: for each inactive region it looks for symbols 
with
 different faces and applies to each of them a different overlay with a
 dimmed foreground color.
 
-It seems to work with cc and c-ts modes (albeit a little slower than
-I'd like) but could totally break other modes or features I'm not aware of.
+It seems to work with cc and c-ts modes and I've been using it daily
+for more than a year now, but could totally break other modes or
+features I'm not aware of.
 
-If you know a better way please do let me know.
+If you know a better way please do let me know.
\ No newline at end of file
diff --git a/clangd-inactive-regions.el b/clangd-inactive-regions.el
index 54c45670a6..a4a5256521 100644
--- a/clangd-inactive-regions.el
+++ b/clangd-inactive-regions.el
@@ -1,12 +1,12 @@
 ;;; clangd-inactive-regions.el --- Highlight inactive code regions with clangd 
power   -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2023 Filippo Argiolas <filippo.argiolas@gmail.com>
+;; Copyright (C) 2024 Filippo Argiolas <filippo.argiolas@gmail.com>
 ;; Based on an example implementation from João Távora
 ;; <joaotavora@gmail.com> (see bug#65418)
 
 ;; Author: Filippo Argiolas <filippo.argiolas@gmail.com>
-;; Version: 0.4
-;; URL: https://github.com/fargiolas/clangd-inactive-regions
+;; Version: 0.5
+;; URL: https://github.com/fargiolas/clangd-inactive-regions.el
 ;; Package-Requires: ((emacs "29.1"))
 
 ;; clangd-inactive-regions.el is free software: you can redistribute
@@ -61,11 +61,11 @@ Allowed methods:
 
 (defface clangd-inactive-regions-shadow-face
   '((t (:inherit shadow)))
-  "Base face used to fontify inactive code when `shadow' method is enabled.")
+  "Base face used to fontify inactive code with `shadow' method.")
 
 (defface clangd-inactive-regions-shade-face
   '((t (:extend t)))
-  "Base face used to fontify inactive code when `shade-background' method is 
enabled.")
+  "Base face used to fontify inactive code with `shade-background' method.")
 
 (define-minor-mode clangd-inactive-regions-mode
   "Minor mode to enable Eglot support for clangd inactiveRegions extension."
@@ -76,7 +76,7 @@ Allowed methods:
          (clangd-inactive-regions--disable))))
 
 (defun clangd-inactive-regions-set-method (method)
-"Interactively select a shading METHOD to render inactive code regions."
+  "Interactively select a shading METHOD to render inactive code regions."
   (interactive
    (list (let ((completion-ignore-case t)
               (prompt "Set inactive regions shading method: "))
@@ -89,7 +89,7 @@ Allowed methods:
 
 (defun clangd-inactive-regions-set-opacity (opacity)
   "Interactively set a new OPACITY value for inactive regions.
-Only applies when `darken-foreground' method is enabled."
+Only applies to `darken-foreground' method."
   (interactive "nNew inactive region foreground color opacity [0-1.0]: ")
   (unless (and (>= opacity 0.0) (<= opacity 1.0))
     (error "Opacity should be between 0.0 and 1.0"))
@@ -99,7 +99,7 @@ Only applies when `darken-foreground' method is enabled."
 
 (defun clangd-inactive-regions-set-shading (shading)
   "Interactively set a new SHADING value for inactive regions.
-Only applies when `shade-background' method is enabled."
+Only applies to `shade-background' method."
   (interactive "nNew inactive region background color shading [0-1.0]: ")
   (unless (and (>= shading 0.0) (<= shading 1.0))
     (error "Shading factor should be between 0.0 and 1.0"))
@@ -171,7 +171,7 @@ we don't want to include whitespace in fontification."
       (setq next-face (get-text-property (point) 'face)))))
 
 (defun clangd-inactive-regions--fontify (start end &optional verbose)
-  "Fontify inactive region with semitransparent faces."
+  "Fontify inactive region (START END) with semitransparent faces."
   ;; sometimes font lock fontifies in chunks and each fontification
   ;; functions takes care of extending the region to something
   ;; syntactically relevant... guess we need to do the same, extend to
@@ -248,15 +248,15 @@ Useful to update colors after a face or theme change."
           (overlay-put ov 'face 'clangd-inactive-regions-shade-face)
           (push ov clangd-inactive-regions--overlays)))))))
 
-;; FIXME: cc-mode.el replaces local fontify-region-function with one
-;; that extends it contextually to a syntactially relevant bigger
-;; region. Then it calls the global fontify-region-function on the new
-;; region boundaries. So if we want to get the extended region we need
-;; to advice the global function while our mode is inherently a buffer
-;; local one. Only limit this to c-mode and c++-mode while I look for
-;; a better alternative.
 (defun clangd-inactive-regions--enable ()
   "Helper method to enable inactive regions minor mode."
+  ;; FIXME: cc-mode.el replaces local fontify-region-function with one
+  ;; that extends it contextually to a syntactially relevant bigger
+  ;; region. Then it calls the global fontify-region-function on the new
+  ;; region boundaries. So if we want to get the extended region we need
+  ;; to advice the global function while our mode is inherently a buffer
+  ;; local one. Only limit this to c-mode and c++-mode while I look for
+  ;; a better alternative.
   (if (memq major-mode '(c-mode c++-mode))
       (add-function :after (default-value 'font-lock-fontify-region-function)
                     #'clangd-inactive-regions--fontify)
@@ -272,7 +272,7 @@ Useful to update colors after a face or theme change."
               '(:inactiveRegions t)))
       base)))
 
-(defun clangd-inactive-regions--enabled-anywhere ()
+(defun clangd-inactive-regions--enabled-anywhere-p ()
   "Check if our mode is enabled in any classic C mode buffers."
   (let ((enabled nil))
     (dolist (buffer (buffer-list))
@@ -288,7 +288,7 @@ Useful to update colors after a face or theme change."
 (defun clangd-inactive-regions--disable ()
   "Helper method to enable inactive regions minor mode."
   (if (memq major-mode '(c-mode c++-mode))
-      (unless (clangd-inactive-regions--enabled-anywhere)
+      (unless (clangd-inactive-regions--enabled-anywhere-p)
         (remove-function (default-value 'font-lock-fontify-region-function)
                          #'clangd-inactive-regions--fontify))
     (remove-function (local 'font-lock-fontify-region-function)
@@ -301,7 +301,7 @@ Useful to update colors after a face or theme change."
   (_server (_method (eql textDocument/inactiveRegions))
            &key regions textDocument &allow-other-keys)
   "Update inactive regions when clangd reports them."
-    (if-let* ((path (expand-file-name (eglot--uri-to-path
+    (if-let* ((path (expand-file-name (eglot-uri-to-path
                                        (cl-getf textDocument :uri))))
               (buffer (find-buffer-visiting path)))
         (with-current-buffer buffer
@@ -309,7 +309,7 @@ Useful to update colors after a face or theme change."
             (setq clangd-inactive-regions--ranges '())
             (cl-loop
              for r across regions
-             for (beg . end) = (eglot--range-region r)
+             for (beg . end) = (eglot-range-region r)
              do
              (push (cons beg end) clangd-inactive-regions--ranges))
             (clangd-inactive-regions-refresh)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]