highlighting lines that are too long

When writing code, I don't like my lines to be too long; the Linux Coding Style famously asserts that:
The limit on the length of lines is 80 columns and this is a hard limit.
In this case (and many others), I can heartily agree with this coding style. Longer lines are hard to understand (I use a limit of 100 for C++/Java).

As a small variation on the trick for highlighting "TODO", "FIXME" and friends, we can also highlight lines that are too long:

(add-hook 'c-mode-hook
  (lambda ()
    (font-lock-add-keywords nil
      '(("^[^\n]\\{80\\}\\(.*\\)$" 1 font-lock-warning-face t)))))

No comments: