When my cod开发者_C百科e fails to compile and tells me that I am likely missing a closed brace, is there an easy way to find it in emacs?
For languages like C, C++, and Java, the command check-parens will check parens (()), brackets ([]), and braces ({}):
M-x check-parens <RET>
The point will move to a bracketing character that is unmatched, and the status line will report the problem.
It's a good idea to use this in conjunction with show-paren-mode as others have said.
If you use following code in your .emacs then if you are before or after a bracket it will highlight all of the expression between them - might help you find mismatched brackets.
(show-paren-mode t)
(setq show-paren-style 'expression)
Show Paren Mode will highlight bad braces as you type them. I don't know how to find them after the fact.
I use the rainbow-delimiters package mode exactly for that reason.
My settings:
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(set-face-attribute 'rainbow-delimiters-unmatched-face nil
            :foreground "red"
            :inherit 'error
            :box t)
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论