|
|
|
|
@ -281,34 +281,34 @@ Returns t if char at loc meets one of the following conditions: |
|
|
|
|
Used by font-lock for dynamic highlighting." |
|
|
|
|
(setq rainbow-delimiters-escaped-char-predicate |
|
|
|
|
(cdr (assoc major-mode rainbow-delimiters-escaped-char-predicate-list))) |
|
|
|
|
(let ((inhibit-point-motion-hooks t)) |
|
|
|
|
;; Point can be anywhere in buffer; determine the nesting depth at point. |
|
|
|
|
(let* ((last-ppss-pos (point)) |
|
|
|
|
(ppss (syntax-ppss)) |
|
|
|
|
;; Ignore negative depths created by unmatched closing delimiters. |
|
|
|
|
(depth (max 0 (nth 0 ppss)))) |
|
|
|
|
(while (re-search-forward rainbow-delimiters--delim-regex end t) |
|
|
|
|
(let* ((delim-pos (match-beginning 0)) |
|
|
|
|
(delim-syntax (syntax-after delim-pos))) |
|
|
|
|
(setq ppss (save-excursion |
|
|
|
|
(parse-partial-sexp last-ppss-pos delim-pos nil nil ppss))) |
|
|
|
|
(setq last-ppss-pos delim-pos) |
|
|
|
|
(unless (rainbow-delimiters--char-ineligible-p delim-pos ppss (car delim-syntax)) |
|
|
|
|
(if (= 4 (logand #xFFFF (car delim-syntax))) |
|
|
|
|
(progn |
|
|
|
|
(setq depth (1+ depth)) |
|
|
|
|
(rainbow-delimiters--apply-color delim-pos |
|
|
|
|
depth |
|
|
|
|
t)) |
|
|
|
|
;; Not an opening delimiter, so it's a closing delimiter. |
|
|
|
|
(let ((matching-opening-delim (char-after (nth 1 ppss)))) |
|
|
|
|
(let* ((inhibit-point-motion-hooks t) |
|
|
|
|
;; Point can be anywhere in buffer; determine the nesting depth at point. |
|
|
|
|
(last-ppss-pos (point)) |
|
|
|
|
(ppss (syntax-ppss)) |
|
|
|
|
;; Ignore negative depths created by unmatched closing delimiters. |
|
|
|
|
(depth (max 0 (nth 0 ppss)))) |
|
|
|
|
(while (re-search-forward rainbow-delimiters--delim-regex end t) |
|
|
|
|
(let* ((delim-pos (match-beginning 0)) |
|
|
|
|
(delim-syntax (syntax-after delim-pos))) |
|
|
|
|
(setq ppss (save-excursion |
|
|
|
|
(parse-partial-sexp last-ppss-pos delim-pos nil nil ppss))) |
|
|
|
|
(setq last-ppss-pos delim-pos) |
|
|
|
|
(unless (rainbow-delimiters--char-ineligible-p delim-pos ppss (car delim-syntax)) |
|
|
|
|
(if (= 4 (logand #xFFFF (car delim-syntax))) |
|
|
|
|
(progn |
|
|
|
|
(setq depth (1+ depth)) |
|
|
|
|
(rainbow-delimiters--apply-color delim-pos |
|
|
|
|
depth |
|
|
|
|
(eq (cdr delim-syntax) |
|
|
|
|
matching-opening-delim)) |
|
|
|
|
;; Don't let `depth' go negative, even if there's an unmatched |
|
|
|
|
;; delimiter. |
|
|
|
|
(setq depth (max 0 (1- depth)))))))))) |
|
|
|
|
t)) |
|
|
|
|
;; Not an opening delimiter, so it's a closing delimiter. |
|
|
|
|
(let ((matching-opening-delim (char-after (nth 1 ppss)))) |
|
|
|
|
(rainbow-delimiters--apply-color delim-pos |
|
|
|
|
depth |
|
|
|
|
(eq (cdr delim-syntax) |
|
|
|
|
matching-opening-delim)) |
|
|
|
|
;; Don't let `depth' go negative, even if there's an unmatched |
|
|
|
|
;; delimiter. |
|
|
|
|
(setq depth (max 0 (1- depth))))))))) |
|
|
|
|
;; We already fontified the delimiters, tell font-lock there's nothing more |
|
|
|
|
;; to do. |
|
|
|
|
nil) |
|
|
|
|
|