In emacs there is a mode show-paren-mode
which colors the opposite matching parenthesis when the cursor is on the other. I wrote an example explaining show-paren-mode
:
( <-colored colored-> )| <-cursor
However it does not work when the cursor is not on the parenthesis:
( <-not colored cursor inside->| not colored-> )
How can I enable this? I find that when performing slurpage and barfage in paredit I cannot keep track of the parentheses very well because they are not colored unless I am on them.
This is optimal:
( <-colored cursor inside->| colored-> )
Edit: Thanks to the comment by @lawlist I have resolved this issue.
This works well for me (more recent Emacs version (than 25?) may be required for the new advice implementation):
(define-advice show-paren-function (:around (fn) fix)
"Highlight enclosing parens."
(cond ((looking-at-p "\\s(") (funcall fn))
(t (save-excursion
(ignore-errors (backward-up-list))
(funcall fn)))))
Thanks to a comment by lawlist I have added the code from his answer on another question into my init file.
It colors each set of matching parentheses in a rainbow pattern.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.