0

I would like to configure my Emacs whitespace options independently for C and python files, because the indent highlighting (space before tabs, etc.) does not apply to the Python coding style. I currently set the whitespace variables globally, but would like a separate (minimal) configuration for Python. Here is the relevant part of my .emacs:

(require 'whitespace)
(setq whitespace-line-column 80)
(setq whitespace-style '(face lines-tail indentation trailing space-before-tab))
(add-hook 'c-mode-hook 'whitespace-mode)

This works for C. Preferably I would have '(face lines-tail trailing) for Python, but I don't know how to setq just for a specific mode. What is the correct way to do this? Thanks. Using Emacs 23 in Ubuntu.

Drew
  • 29,895
  • 7
  • 74
  • 104
RawwrBag
  • 602
  • 5
  • 12

2 Answers2

2

I got it to work by putting the settings into the hook along with the evocation of whitespace-mode:

(add-hook 'python-mode-hook
          (lambda ()
            (progn
              (setq whitespace-line-column 79)
              (setq whitespace-style '(face lines-tail))
              (whitespace-mode))))
Alexei Boronine
  • 11,061
  • 4
  • 19
  • 14
1

Perhaps using File Local Variables could help you?

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547