1

How do I make Emacs give me live feedback on my syntax?

Like, after I finish typing a line of code, how can I make it so that Emacs tells me if that line isn't using correct syntax?

For example, in Eclipse, it'll tell you before you compile when a line is not correct (in Java, at least). How can I mimic that behavior in Java, C, etc. for Emacs?

Thanks!

Running Emacs 24 in Terminal by the way. Installed via HomeBrew on OSX.

erikstokes
  • 12,927
  • 2
  • 36
  • 56
CodeSammich
  • 365
  • 3
  • 12

1 Answers1

2

Emacs has a built-in mode called FlyMake that can do this, provided you have a properly configured makefile. Turn flymake on with M-x flymake-mode. It runs an external command (by default make check-syntax) collects the errors and warnings and highlights the buffer appropriately. It works pretty well for C and with some effort can be configured for other languages.

There is also an external package Flycheck that you can install with M-x package-install flycheck. Turn it on with M-x flycheck-mode. With most languages it Just Works with no further configuration. You may need to install some external tool (for example pylint to check Python code).

erikstokes
  • 12,927
  • 2
  • 36
  • 56
  • It's working, but it's not working as it should, in my opinion. It highlights the words so much that I can't even read them properly, in full screen. Also highlights some function names and variable types for who knows why. – CodeSammich Oct 18 '15 at 00:29
  • For flycheck you can customize the faces flycheck-warning and flycheck-error to change the highlighting. There are similar faces for flymake. A description of the error should appear in the minibuffer when you put the cursor over it. – erikstokes Oct 18 '15 at 00:47
  • I enabled flymake, intentionally misspelled a variable, intentionally misspelled a word in a comment. Nothing is highlighted. Any suggestions on how I can even begin to debug this? – par Apr 29 '19 at 10:44