How to highlight parts of the code that are longer than 80 characters?

In Emacs, I would like to highlight parts of long lines that are longer than 80 characters.

The package is highlight-80+

great for this. But how can I automatically enable it when loading the C ++ source file?

I tried adding highlight-80+

to C ++ mode, but that didn't work:

(require 'highlight-80+)
(defun my-c++-mode-common-hook ()
  (highlight-80+-mode 1))
(add-hook 'c++-mode-common-hook 'my-c++-mode-common-hook)

      

When I download the .cc file, it goes into C ++ mode, but highlight-80+

not enabled, so long lines are unchecked.

+3


source to share


3 answers


Note that the Highlight80Plus wiki says it is embedded in emacs starting at 23. I believe this refers to spatial mode; it does this and is built into emacs.

There is a function emacs-starter-kit that already does something like this, but you can easily duplicate it,



(defun esk-turn-on-whitespace ()
  (whitespace-mode t))

(add-hook 'prog-mode-hook 'esk-turn-on-whitespace)

      

+2


source


Can you try this:



(autoload 'highlight-80+)
(add-to-list 'auto-mode-alist '("\\.cpp$" . highlight-80+-mode))

      

+1


source


See whitespace-mode

, he does this highlight and more:

http://www.emacswiki.org/emacs/WhiteSpace

+1


source







All Articles