[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rainbow-delimiters 4eae4bc56f 068/188: Reduce the amount o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rainbow-delimiters 4eae4bc56f 068/188: Reduce the amount of copy and paste in rainbow-delimiters-propertize-region. |
Date: |
Sat, 1 Jan 2022 00:58:53 -0500 (EST) |
branch: elpa/rainbow-delimiters
commit 4eae4bc56febcbe617b4d62f01208377f0501960
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Reduce the amount of copy and paste in rainbow-delimiters-propertize-region.
---
rainbow-delimiters.el | 67 +++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index b6e784e7a8..f95129afdc 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -542,6 +542,21 @@ MATCH is nil iff it's a mismatched closing delimiter."
(defconst rainbow-delimiters-delim-regex "\\(\(\\|\)\\|\\[\\|\\]\\|\{\\|\}\\)"
"Regex matching all opening and closing delimiters the mode highlights.")
+(defconst rainbow-delimiters-opening-delim-info
+ '((?\( . "paren") (?\{ . "brace") (?\[ . "bracket"))
+ "Open delimiter information: list of (DELIMITER . TYPE).
+
+DELIMITER is the opening delimiter.
+TYPE is the delimiter type string for `rainbow-delimiters-apply-color'.")
+
+(defconst rainbow-delimiters-closing-delim-info
+ '((?\) ?\( . "paren") (?\} ?\{ . "brace") (?\] ?\[ . "bracket"))
+ "Closing delimiter information: list of (DELIMITER OPENING . TYPE).
+
+DELIMITER is the closing delimiter.
+OPENING is the corresponding opening delimiter.
+TYPE is the delimiter type string for `rainbow-delimiters-apply-color'.")
+
;; main function called by jit-lock:
(defsubst rainbow-delimiters-propertize-region (start end)
"Highlight delimiters in region between START and END.
@@ -560,37 +575,27 @@ Used by jit-lock for dynamic highlighting."
(backward-char) ; re-search-forward places point after delim; go
back.
(let ((ppss (rainbow-delimiters-syntax-ppss (point))))
(unless (rainbow-delimiters-char-ineligible-p (point) ppss)
- (let ((delim (char-after (point))))
- (cond ((eq ?\( delim) ; (
- (setq depth (1+ depth))
- (rainbow-delimiters-apply-color "paren" depth (point)
t))
- ((eq ?\) delim) ; )
- (rainbow-delimiters-apply-color "paren"
- depth
- (point)
- (= ?\( (char-after
(nth 1 ppss))))
- (setq depth (or (and (<= depth 0) 0) ; unmatched paren
- (1- depth))))
- ((eq ?\[ delim) ; [
- (setq depth (1+ depth))
- (rainbow-delimiters-apply-color "bracket" depth
(point) t))
- ((eq ?\] delim) ; ]
- (rainbow-delimiters-apply-color "bracket"
- depth
- (point)
- (= ?\[ (char-after
(nth 1 ppss))))
- (setq depth (or (and (<= depth 0) 0) ; unmatched
bracket
- (1- depth))))
- ((eq ?\{ delim) ; {
- (setq depth (1+ depth))
- (rainbow-delimiters-apply-color "brace" depth (point)
t))
- ((eq ?\} delim) ; }
- (rainbow-delimiters-apply-color "brace"
- depth
- (point)
- (= ?\{ (char-after
(nth 1 ppss))))
- (setq depth (or (and (<= depth 0) 0) ; unmatched brace
- (1- depth))))))))
+ (let* ((delim (char-after (point)))
+ (opening-delim-info
+ (assq delim rainbow-delimiters-opening-delim-info)))
+ (if opening-delim-info
+ (progn
+ (setq depth (1+ depth))
+ (rainbow-delimiters-apply-color (cdr
opening-delim-info)
+ depth
+ (point)
+ t))
+ ;; Not an opening delimiters, so it's a closing delimiter.
+ (let ((closing-delim-info
+ (assq delim rainbow-delimiters-closing-delim-info))
+ (matching-opening-delim (char-after (nth 1 ppss))))
+ (rainbow-delimiters-apply-color (nthcdr 2
closing-delim-info)
+ depth
+ (point)
+ (= (nth 1
closing-delim-info)
+
matching-opening-delim))
+ (setq depth (or (and (<= depth 0) 0) ; unmatched delim
+ (1- depth))))))))
;; move past delimiter so re-search-forward doesn't pick it up
again
(forward-char)))))))
- [nongnu] elpa/rainbow-delimiters 3d6de240fb 043/188: Merge pull request #12 from crlf0710/master, (continued)
- [nongnu] elpa/rainbow-delimiters 3d6de240fb 043/188: Merge pull request #12 from crlf0710/master, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d38744e945 045/188: Remove middle initial from my name., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 59d8d64a84 033/188: Merge pull request #9 from To1ne/patch-1, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters df383f86f7 074/188: Clean up comments and whitespace., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 5a7d0131f8 050/188: README.markdown: minor wording changes., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 164b55be80 036/188: Double the speed of main jit-lock highlighting fn (see commit msg for benchmarks); eliminate bottleneck in large files., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 1d71bda98c 035/188: Rename syntax-table functions to be clearer., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 6345c1fa4b 040/188: Release rainbow-delimiters version 1.3.4 (2012-04-27)., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 9d0683d77d 034/188: 6-15x Speed improvement by enhancing two key functions, see commit message for benchmarks., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 89b748e401 065/188: Make rainbow-delimiters-outermost-only-face-count customizable., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 4eae4bc56f 068/188: Reduce the amount of copy and paste in rainbow-delimiters-propertize-region.,
ELPA Syncer <=
- [nongnu] elpa/rainbow-delimiters 506fef695f 049/188: Allow the user to define the number of faces used only for the outermost level., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 5ab3135986 061/188: Fix a bug that caused (rainbow-delimiters-syntax-ppss 1) to return nil., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 43b02d2d20 075/188: Rename rainbow-delimiters-keywords., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters a095a77dc9 066/188: Correct the prefix of the rainbow-delimiters-faces group., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d7946fdf94 078/188: Fix a typo in a comment., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 14e0f971f6 079/188: Call font-lock-{flush, fontify-buffer} only when font-lock-mode is on., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters b3f87cfe99 072/188: Highlight delimiters even in already highlighted text., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters a37d19b415 082/188: Add a comment explaining the previous change., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 36efff58a8 081/188: Don't highlight delimiters inside comments starting with two chars., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 24f6c5767e 083/188: Release version 1.3.8., ELPA Syncer, 2022/01/01