art_else · 2022-03-18 20:08
`check-parens` is of course a very useful tool, but has two problems for me. 1. it also checks parens in comments which is not very useful and 2. one cannot skip over a detected mismatch to the next one. This means I get stuck 'fixing' parens that won't need to be fixed and even disrupts my comments.
Is there a solution, perhaps to just check a region instead of the whole buffer?
00-11 · 2022-03-18 20:39
I don't see that `check-parens` pays attention to parens in comments. It does pay attention to the current syntax table, however. In your current mode, are you sure the parens you think are commented out are in fact commented out?
----
If you do have some context where you want to ignore the text in comments, you can use library [`hide-comnt.el`](https://www.emacswiki.org/emacs/HideOrIgnoreComments) ([code](https://www.emacswiki.org/emacs/download/hide-comnt.el)) to do that for you. E.g., just wrap your code that you want to have ignore comments with macro `with-comments-hidden`.
----
You can also of course narrow the buffer to a region, and then use `check-parens`. Its effect is limited to the current buffer restriction (aka narrowing).
art_else · 2022-03-18 23:23
My .emacs is a config.org file and within this file `check-parens` ignores commented out lines. When I pop out the code section with `C-c '` it works as it should.
Similar things have bitten me in the tail before with .org config files. I don't think there is a solution to this problem?
00-11 · 2022-03-19 01:47
I can't help you with Org. Maybe someone else will. I don't even know what "pop out the code section with `C-c '` means. (Your question said nothing about Org, `C-c '` popping out, etc.)
oantolin · 2022-03-22 13:22
In case you're curious about "popping out", it's this: the Org mode syntax allows you to include code blocks in arbitrary languages (the language is specified in a header that indicates the start of the code block) and Org mode has a command that pops up a buffer containing just the contents of the code block at point; said buffer is put in the major mode appropriate for the language of the code block. When you're done editing you run another Org mode command that takes the new contents of the popped-up buffer and replaces the original code block with them.
Org mode will show correct syntax highlighting in these source code blocks (behind the scenes it fontifies them in an auxiliary buffer in the correct major mode), which can cause a sensation of having integrated all the major modes of the languages you use in source blocks, but it really hasn't, and in particular Org mode has, as usual, one fixed syntax table which mostly likely is wrong for each source block.