0

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?

Flowneee
  • 247
  • 1
  • 9

3 Answers3

4

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)))
Basil
  • 12,383
  • 43
  • 69
0

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.

stevoooo
  • 737
  • 3
  • 8
0

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.

erikstokes
  • 12,927
  • 2
  • 36
  • 56