I want to customize the behavior of global-whitespace-mode on a per-major-mode basis, and also define some interactive commands that change what's being highlighted on a per-buffer basis. global-whitespace-mode does something rather more complicated than just turning on whitespace-mode in every buffer, I don't particularly understand why, but anyway it's getting in the way of me writing those interactive commands. Specifically, this function works as a mode hook but not as an interactive command:
(defun turn-off-highlight-long-lines () "Turn off highlighting of long lines via global-whitespace-mode." (interactive) (let* ((already-active-p (local-variable-p 'whitespace-active-style)) (desired-style (delq 'lines (copy-sequence (if already-active-p whitespace-active-style whitespace-style))))) (if already-active-p (progn (setq whitespace-active-style desired-style) (whitespace-color-on)) (setq-local whitespace-style desired-style))))
But this seems to be exactly what
(global-)whitespace-toggle-options does, except buffer-locally, so I'm stumped.
(I'm not using
(global-)whitespace-toggle-options because I want the effect to be buffer-local.)