0

At the end of one of my files for loops stop being highlighted, aren't automatically indented when I enter them, and TAB won't indent four spaces either. I don't have this issue in any other of my python buffers. How do I figure out what's wrong, and how do I fix it?

  • Comment out or remove everything but the offending lines. If the problem goes away, recursively bisect the rest of the file to isolate the problem. – Dan May 24 '17 at 21:55
  • I finally spotted a syntax error in the previous line. Please post your comment in answer form so I can accept it; I would like to know more about how you would recursively bisect a file in Emacs. – Miprog12 May 25 '17 at 7:56
1

If syntax highlighting or indentation suddenly stops working as expected at some point in your buffer/file, there's a very good chance you have a syntax error somewhere above it.

In these situations, the most straightforward way to identify the offending lines is to bisect your buffer/file recursively. What that means is to comment out all the material above the lines that are giving you problems. Uncomment one half. If the problem comes back, the error is probably somewhere in that half. Repeat the procedure in the offending half by uncommenting one half of the half until you isolate the error.

Note that this procedure is a common remedy for a problems in your init file, but the principle is similar for any source code.

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.