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

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

[nongnu] elpa/rainbow-delimiters 506fef695f 049/188: Allow the user to d


From: ELPA Syncer
Subject: [nongnu] elpa/rainbow-delimiters 506fef695f 049/188: Allow the user to define the number of faces used only for the outermost level.
Date: Sat, 1 Jan 2022 00:58:51 -0500 (EST)

branch: elpa/rainbow-delimiters
commit 506fef695f65605b2c0a8b4ee8a2e90f264f9e1e
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>

    Allow the user to define the number of faces used only for the outermost 
level.
    
    Fixes #19.
---
 rainbow-delimiters.el | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index b3f614651b..e11336fb5d 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -283,6 +283,11 @@ Nil disables brace highlighting."
 
 Determines depth at which to cycle through faces again.")
 
+(defvar rainbow-delimiters-outermost-only-face-count 0
+  "Number of faces to be used only for N outermost delimiter levels.
+
+This should be smaller than `rainbow-delimiters-max-face-count'.")
+
 ;;; Face utility functions
 
 (defsubst rainbow-delimiters-depth-face (depth)
@@ -291,22 +296,19 @@ Determines depth at which to cycle through faces again.")
 For example: 'rainbow-delimiters-depth-1-face'."
   (intern-soft
    (concat "rainbow-delimiters-depth-"
-          (number-to-string
-           (or
-            ;; Our nesting depth has a face defined for it.
-            (and (< depth rainbow-delimiters-max-face-count)
-                 depth)
-            ;; Deeper than # of defined faces; cycle back through to beginning.
-            ;; Depth 1 face is only applied to the outermost delimiter pair.
-            ;; Cycles infinitely through faces 2-9.
-            (let ((cycled-depth (mod depth rainbow-delimiters-max-face-count)))
-              (if (/= cycled-depth 0)
-                  ;; Return face # that corresponds to current nesting level.
-                  (mod depth rainbow-delimiters-max-face-count)
-                ;; Special case: depth divides evenly into max, correct face # 
is max.
-                rainbow-delimiters-max-face-count))))
-          "-face")))
-
+           (number-to-string
+            (or
+             ;; Our nesting depth has a face defined for it.
+             (and (<= depth rainbow-delimiters-max-face-count)
+                  depth)
+             ;; Deeper than # of defined faces; cycle back through to
+             ;; `rainbow-delimiters-outermost-only-face-count' + 1.
+             ;; Return face # that corresponds to current nesting level.
+             (+ 1 rainbow-delimiters-outermost-only-face-count
+                (mod (- depth rainbow-delimiters-max-face-count 1)
+                     (- rainbow-delimiters-max-face-count
+                        rainbow-delimiters-outermost-only-face-count)))))
+           "-face")))
 
 ;;; Nesting level
 



reply via email to

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