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.

2 Answers 2

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))))
1

Perhaps using File Local Variables could help you?

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.