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

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

[nongnu] elpa/rainbow-delimiters ed5dd72f79 119/188: Restore the ability


From: ELPA Syncer
Subject: [nongnu] elpa/rainbow-delimiters ed5dd72f79 119/188: Restore the ability to disable the highlighting of selected delimiters.
Date: Sat, 1 Jan 2022 00:58:58 -0500 (EST)

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

    Restore the ability to disable the highlighting of selected delimiters.
    
    Please note that the new way is not compatible with the old way.
---
 rainbow-delimiters-test.el | 11 ++-----
 rainbow-delimiters.el      | 71 +++++++++++++---------------------------------
 2 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/rainbow-delimiters-test.el b/rainbow-delimiters-test.el
index 3fd02a1087..2cf27c9d74 100644
--- a/rainbow-delimiters-test.el
+++ b/rainbow-delimiters-test.el
@@ -184,14 +184,9 @@
                  0 1 (face (rainbow-delimiters-depth-1-face))
                  1 2 (face (rainbow-delimiters-mismatched-face))))))))
 
-(defmacro doesnt-highlight-disabled-delimiters (name opening)
-  `(ert-deftest ,(intern (format "doesnt-highlight-disabled-%s" name)) ()
-     (let ((,(intern (format "rainbow-delimiters-highlight-%s-p" name)) nil))
-       (should-do-nothing 'text-mode ,(format "%c" opening)))))
-
-(doesnt-highlight-disabled-delimiters "parens" ?\()
-(doesnt-highlight-disabled-delimiters "brackets" ?\[)
-(doesnt-highlight-disabled-delimiters "braces" ?\{)
+(ert-deftest doesnt-highlighlight-disabled-delimiters ()
+  (let ((rainbow-delimiters-delimiter-blacklist '(?\( ?\))))
+    (should-do-nothing 'text-mode "(((())))")))
 
 (ert-deftest doesnt-highlight-escaped-delimiters ()
   (should-do-nothing 'emacs-lisp-mode "?\("))
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index a7d113f7be..a223516677 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -106,44 +106,15 @@ When depth exceeds innermost defined face, colors cycle 
back through."
   :tag "Color Scheme"
   :group 'rainbow-delimiters
   :link '(custom-group-link "rainbow-delimiters")
-  :link '(custom-group-link :tag "Toggle Delimiters" 
"rainbow-delimiters-toggle-delimiter-highlighting")
   :prefix "rainbow-delimiters-")
 
-;; Choose which delimiters you want to highlight in your preferred language:
+(defcustom rainbow-delimiters-delimiter-blacklist '()
+  "Disable highlighting of selected delimiters.
 
-(defgroup rainbow-delimiters-toggle-delimiter-highlighting nil
-  "Choose which delimiters to highlight."
-  :tag "Toggle Delimiters"
-  :group 'rainbow-delimiters
-  :link '(custom-group-link "rainbow-delimiters")
-  :link '(custom-group-link :tag "Color Scheme" "rainbow-delimiters-faces"))
-
-(defcustom rainbow-delimiters-highlight-parens-p t
-  "Enable highlighting of nested parentheses -- ().
-
-Non-nil (default) enables highlighting of parentheses.
-Nil disables parentheses highlighting."
-  :tag "Highlight Parentheses?"
-  :type 'boolean
-  :group 'rainbow-delimiters-toggle-delimiter-highlighting)
-
-(defcustom rainbow-delimiters-highlight-brackets-p t
-  "Enable highlighting of nested brackets -- [].
-
-Non-nil (default) enables highlighting of brackets.
-Nil disables bracket highlighting."
-  :tag "Highlight Brackets?"
-  :type 'boolean
-  :group 'rainbow-delimiters-toggle-delimiter-highlighting)
-
-(defcustom rainbow-delimiters-highlight-braces-p t
-  "Enable highlighting of nested braces -- {}.
-
-Non-nil (default) enables highlighting of braces.
-Nil disables brace highlighting."
-  :tag "Highlight Braces?"
-  :type 'boolean
-  :group 'rainbow-delimiters-toggle-delimiter-highlighting)
+Delimiters in this list are not highlighted."
+  :tag "Delimiter Blacklist"
+  :type '(repeat character)
+  :group 'rainbow-delimiters)
 
 
 ;;; Faces:
@@ -368,8 +339,9 @@ MATCH is nil iff it's a mismatched closing delimiter."
   (eq (char-before loc) ?\\))
 
 (defun rainbow-delimiters--char-ineligible-p (loc ppss delim-syntax-code)
-  "Return t if char at LOC should be skipped, e.g. if inside a comment.
-PPSS should be the `parse-partial-sexp' state at LOC.
+  "Return t if char at LOC should not be highlighted.
+PPSS is the `parse-partial-sexp' state at LOC.
+DELIM-SYNTAX-CODE is the `car' of a raw syntax descriptor at LOC.
 
 Returns t if char at loc meets one of the following conditions:
 - Inside a string.
@@ -392,19 +364,16 @@ Returns t if char at loc meets one of the following 
conditions:
    (when rainbow-delimiters-escaped-char-predicate
      (funcall rainbow-delimiters-escaped-char-predicate loc))))
 
-(defun rainbow-delimiters--apply-color (delim depth loc match)
-  "Apply color for DEPTH to DELIM at LOC following user settings.
+(defun rainbow-delimiters--apply-color (depth loc match)
+  "Apply color to the delimiter following user settings.
 
-DELIM is a symbol of the variable specifying whether to highlight this 
delimiter
-type.
-DEPTH is the delimiter depth, or corresponding face # if colors are repeating.
-LOC is location of character (delimiter) to be colorized.
+DEPTH is the delimiter depth.
+LOC is the location of delimiters to be highlighted.
 MATCH is nil iff it's a mismatched closing delimiter."
-  ;; Ensure user has enabled highlighting of this delimiter type.
-  ;; (when (symbol-value delim)
-  (rainbow-delimiters--propertize-delimiter loc
-                                            depth
-                                            match));; )
+  (unless (memq (char-after loc) rainbow-delimiters-delimiter-blacklist)
+    (rainbow-delimiters--propertize-delimiter loc
+                                              depth
+                                              match)))
 
 ;;; Font-Lock functionality
 
@@ -434,14 +403,12 @@ Used by font-lock for dynamic highlighting."
             (if (= 4 (logand #xFFFF (car delim-syntax)))
                 (progn
                   (setq depth (1+ depth))
-                  (rainbow-delimiters--apply-color nil
-                                                   depth
+                  (rainbow-delimiters--apply-color depth
                                                    delim-pos
                                                    t))
               ;; Not an opening delimiter, so it's a closing delimiter.
               (let ((matching-opening-delim (char-after (nth 1 ppss))))
-                (rainbow-delimiters--apply-color nil
-                                                 depth
+                (rainbow-delimiters--apply-color depth
                                                  delim-pos
                                                  (eq (cdr delim-syntax)
                                                      matching-opening-delim))



reply via email to

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