rainbow-delimiters does not properly highlight unmatched parenthesis
Closed this issue · 1 comments
The problem is too many parens at the beginning, and not too few at the end.
Would it be possible to highlight unmatched parenthesis if they are at the beginning of a function like func((((()
?
Related:
How can I find missing or mismatched braces / parens in emacs?
minimal.el //example is taken from the link above
(require 'package)
(setq user-init-file (or load-file-name (buffer-file-name)))
(setq user-emacs-directory (file-name-directory user-init-file))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(setq frame-background-mode 'dark)
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(set-face-attribute 'rainbow-delimiters-unmatched-face nil
:foreground "red"
:background "yellow"
:inherit 'error
:box t)
It find unmatcing parenthesis for print("Hello"))
when parenthesis at the end.
Find error:
But it does not do anything for if unmatched parenthesis are at the beginning: print(((((((((((((((((("Hello")
Would it be possible to highlight unmatched parenthesis if they are at the beginning of a function like
func((((()
?
Not easily, no. In the worst case it would require going through the entire buffer to determine that an opening parenthesis has no matching closing one, which is slow and doesn't play well with how font-lock
works.