|
|
|
|
@ -465,37 +465,36 @@ TYPE is the delimiter type string for `rainbow-delimiters-apply-color'.") |
|
|
|
|
Used by font-lock for dynamic highlighting." |
|
|
|
|
(setq rainbow-delimiters-escaped-char-predicate |
|
|
|
|
(cdr (assoc major-mode rainbow-delimiters-escaped-char-predicate-list))) |
|
|
|
|
(save-excursion |
|
|
|
|
(with-syntax-table rainbow-delimiters-syntax-table |
|
|
|
|
(let ((inhibit-point-motion-hooks t)) |
|
|
|
|
;; Point can be anywhere in buffer; determine the nesting depth at point. |
|
|
|
|
(let ((depth (rainbow-delimiters-depth (point)))) |
|
|
|
|
(while (and (< (point) end) |
|
|
|
|
(re-search-forward rainbow-delimiters-delim-regex end t)) |
|
|
|
|
(let ((delim-pos (match-beginning 0))) |
|
|
|
|
(let ((ppss (rainbow-delimiters-syntax-ppss delim-pos))) |
|
|
|
|
(unless (rainbow-delimiters-char-ineligible-p delim-pos ppss) |
|
|
|
|
(let* ((delim (char-after delim-pos)) |
|
|
|
|
(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 |
|
|
|
|
delim-pos |
|
|
|
|
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) |
|
|
|
|
(with-syntax-table rainbow-delimiters-syntax-table |
|
|
|
|
(let ((inhibit-point-motion-hooks t)) |
|
|
|
|
;; Point can be anywhere in buffer; determine the nesting depth at point. |
|
|
|
|
(let ((depth (rainbow-delimiters-depth (point)))) |
|
|
|
|
(while (and (< (point) end) |
|
|
|
|
(re-search-forward rainbow-delimiters-delim-regex end t)) |
|
|
|
|
(let ((delim-pos (match-beginning 0))) |
|
|
|
|
(let ((ppss (rainbow-delimiters-syntax-ppss delim-pos))) |
|
|
|
|
(unless (rainbow-delimiters-char-ineligible-p delim-pos ppss) |
|
|
|
|
(let* ((delim (char-after delim-pos)) |
|
|
|
|
(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 |
|
|
|
|
delim-pos |
|
|
|
|
(= (nth 1 closing-delim-info) |
|
|
|
|
matching-opening-delim)) |
|
|
|
|
(setq depth (or (and (<= depth 0) 0) ; unmatched delim |
|
|
|
|
(1- depth)))))))))))))) |
|
|
|
|
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 |
|
|
|
|
delim-pos |
|
|
|
|
(= (nth 1 closing-delim-info) |
|
|
|
|
matching-opening-delim)) |
|
|
|
|
(setq depth (or (and (<= depth 0) 0) ; unmatched delim |
|
|
|
|
(1- depth))))))))))))) |
|
|
|
|
;; We already fontified the delimiters, tell font-lock there's nothing more |
|
|
|
|
;; to do. |
|
|
|
|
nil) |
|
|
|
|
|