Skip to content

Compilation Error Highlighting

randomphrase edited this page Mar 16, 2014 · 4 revisions

Getting early notification of compilation errors is a big timesaver.

The built-in Emacs Flymake mode enables on-the-fly background compilation of your source files as you are editing them, and when errors are encountered they are highlighted. The additional flymake-cursor package is needed to display the specific error in the minibuffer:

This uses the compilation database (see Opening Projects) to provide the command line to be used for compilation. The EDE-compdb package provides a ede-compdb-flymake-init function do to exactly that. The following init code will set up flymake mode:

(require 'flymake)
(setq flymake-allowed-file-name-masks
      (cons '("\\.[ch]\\(pp\\)?$" ede-compdb-flymake-init)
            flymake-allowed-file-name-masks))

;; Enable flymake
(add-hook 'find-file-hook 'flymake-find-file-hook)

;; Use flymake-cursor to show error at cursor
(require 'flymake-cursor)

TODO: In general, it seems that Flycheck is a superior alternative to Flymake, however getting it working with EDE-compdb is not as simple. See discussion here.

Clone this wiki locally