2

So I have this huge file (a SharePoint rendering templates file, if you're interested). The problem is, it doesn't work, because somewhere inside that file, in a code block, there is an unmatched '('. How do I find it? I'm on a Windows machine, but I have all the GNU command-line utilities installed.

5
  • 4
    Obligatory XKCD.
    – slhck
    Mar 21 '12 at 18:30
  • You can always go through it by hand. ;) I have an effective mental algorithm that I use for this kind of debugging. I should code up a Perl script to automate it though, at some point. :) Mar 21 '12 at 19:03
  • @sidran32, you just keep a count, and see where it goes negative?
    – soandos
    Mar 21 '12 at 19:11
  • @soandos More or less. Or where it stays positive. :) It also helps that compilers will start throwing errors directly after the line where the error is. Before I realized how to do that kind of debugging properly, it really was a nightmare to try and fix. :P One mismatched curly brace, missing semicolon, or mismatched parenthesis can trigger hundreds of errors. Mar 21 '12 at 19:15
  • 1
    To be honest, with proper indentation, it is almost never hard to fix. If you don't have that, it can be a nightmare.
    – soandos
    Mar 21 '12 at 19:21
1

Use the emacs command M-x check-parens<RET>.

Turning on show-paren-mode would also probably be a good idea.

1
  • I'm more of a Vim person, but looks like this is my only option. Thanks!
    – Mihai
    Mar 21 '12 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.