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

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

[nongnu] elpa/rainbow-delimiters 36efff58a8 081/188: Don't highlight del


From: ELPA Syncer
Subject: [nongnu] elpa/rainbow-delimiters 36efff58a8 081/188: Don't highlight delimiters inside comments starting with two chars.
Date: Sat, 1 Jan 2022 00:58:54 -0500 (EST)

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

    Don't highlight delimiters inside comments starting with two chars.
    
    Fixes #32.
---
 rainbow-delimiters.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index 72ae2bae7a..064cae3595 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -362,12 +362,18 @@ The syntax table is constructed by the function
 (defun rainbow-delimiters-make-syntax-table (syntax-table)
   "Inherit SYNTAX-TABLE and add delimiters intended to be highlighted by mode."
   (let ((table (copy-syntax-table syntax-table)))
-    (modify-syntax-entry ?\( "()  " table)
-    (modify-syntax-entry ?\) ")(  " table)
-    (modify-syntax-entry ?\[ "(]" table)
-    (modify-syntax-entry ?\] ")[" table)
-    (modify-syntax-entry ?\{ "(}" table)
-    (modify-syntax-entry ?\} "){" table)
+    (when (/= ?\( (char-syntax ?\())
+      (modify-syntax-entry ?\( "()" table))
+    (when (/= ?\( (char-syntax ?\[))
+      (modify-syntax-entry ?\[ "(]" table))
+    (when (/= ?\( (char-syntax ?\{))
+      (modify-syntax-entry ?\{ "(}" table))
+    (when (/= ?\) (char-syntax ?\)))
+      (modify-syntax-entry ?\) ")(" table))
+    (when (/= ?\) (char-syntax ?\]))
+      (modify-syntax-entry ?\) ")[" table))
+    (when (/= ?\) (char-syntax ?\}))
+      (modify-syntax-entry ?\) "){" table))
     table))
 
 (defsubst rainbow-delimiters-depth (loc)
@@ -430,6 +436,10 @@ Returns t if char at loc meets one of the following 
conditions:
   (or
    (nth 3 ppss)                ; inside string?
    (nth 4 ppss)                ; inside comment?
+   (save-excursion             ; starting a comment?
+     (goto-char loc)
+     (let ((inhibit-changing-match-data t))
+       (looking-at comment-start-skip)))
    (and rainbow-delimiters-escaped-char-predicate
         (funcall rainbow-delimiters-escaped-char-predicate loc))))
 



reply via email to

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