In ~/.emacs I've globally enabled whitespace-mode:

(require 'whitespace)
(setq whitespace-style '(face empty tabs lines-tail trailing))
(global-whitespace-mode t)

Example buffer content:

-*- fill-column: 100; whitespace-line-column: nil -*-
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua.

According to documentation for whitespace-line-column: If nil, the `fill-column' variable value is used. However, that doesn't happen. In the buffer with the above sample content, highlight starts at column 80 (default value):

Screenshot with highlight starting at column 80

What I already tried, to no avail:

  • Enabled whitespace-mode for that buffer explicitly.

  • Buffer local: whitespace-line-column: 100

  • In ~/.emacs: whitespace-line-column: nil, whitespace-line-column: 100

Version: GNU Emacs 24.4.1 (i686-pc-mingw32) of 2014-10-24 on LEG570

How can I specify line length for whitespace-mode for an individual buffer?

1 Answer 1


First off, since you didn't mention it: Using the same version of Emacs (24.4.1), the behavior you describe can be reproduced in emacs -Q.

Secondly, what you are doing should work (AFAICT). It seems that turning on whitespace-mode globally (or even in a mode hook) before visiting a file with a custom whitespace-line-column is what's causing the problem. You might want to consider reporting the issue to the Emacs devs via M-x report-emacs-bug.

Finally, you can get the behavior you want by doing the following:

  1. Change your config to

    (require 'whitespace)
    (setq whitespace-style '(face empty tabs lines-tail trailing))
    (add-hook 'hack-local-variables-hook 'whitespace-mode)
  2. Change headers of any files that should use a custom whitespace-line-column to

    -*- whitespace-line-column: 100; -*-
  • Thanks for the suggestions! However, manually enabling whitespace-mode every time I open a new file is really not an option for me.
    – feklee
    Jan 28, 2015 at 9:26
  • 1
    Works great so far! Starting whitespace-mode from hack-local-variables-hook makes it also respect a global setting of whitespace-line-column: nil. So I don't need to specify an explicit value in every file.
    – feklee
    Jan 28, 2015 at 11:39
  • 1
    aha! I had :safe local variables set, and this needs to be added to the safe list.
    – fommil
    Jun 17, 2015 at 16:55
  • 1
    FYI (put 'whitespace-line-column 'safe-local-variable #'integerp) lets me use these settings as safe variables.
    – fommil
    Jun 17, 2015 at 17:08
  • 1
    I have also run into the same problem and have reported the bug here: debbugs.gnu.org/cgi/bugreport.cgi?bug=24904
    – DeX3
    Nov 9, 2016 at 9:36

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.