I want to force whitespace-mode highlight line after 99 character in rust-mode (cuz this length recommended by guidelines). For other modes i want to leave this variable with default value(80). How can i do this?

3 Answers 3


As erikstokes correctly points out, the variable that controls this behaviour is whitespace-line-column. If you unconditionally set this variable in your user-init-file, however, it will affect all modes.

The standard mechanism that Emacs provides for mode-specific customisations is hooks. So, to modify the variable in question for rust-mode only, you can write something like the following:

(add-hook 'rust-mode-hook
          (lambda ()
            (setq-local whitespace-line-column 99)))

or, in Emacs versions prior to 24.3:

(add-hook 'rust-mode-hook
          (lambda ()
            (set (make-local-variable 'whitespace-line-column) 99)))

Rather than whitespace-mode, try column-enforce-mode which can be installed from Emacs MELPA. See https://github.com/jordonbiondo/column-enforce-mode for more details.

  • 1
    Why is that better than using whitespace-mode?
    – Qudit
    Commented Mar 27, 2018 at 18:00

The variable you want is whitespace-line-column:

Specify column beyond which the line is highlighted.

It must be an integer or nil. If nil, the ‘fill-column’ variable value is used.

Used when ‘whitespace-style’ includes ‘lines’ or ‘lines-tail’.

Add (setq whitespace-line-column 99) to your .emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.