help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing whitespace-mode style in mode hook?


From: Peter Hardy
Subject: Re: Changing whitespace-mode style in mode hook?
Date: Thu, 11 Mar 2021 09:04:01 +1100
User-agent: mu4e 1.4.15; emacs 27.1

Peter Hardy writes:
> First, in my init.el I'm turning on global whitespace mode like this:
>
> (global-whitespace-mode t)
> (setq whitespace-style (quote (face trailing tabs lines-tail newline empty 
> indentation space-after-tab space-before-tab))))
>
> But for some modes I don't want long lines to be highlighted - usually
> because I'm using visual-line-mode instead. So I wrote a quick function
> to toggle off the lines-tail option, and added it to a mode hook:
>
> (defun my/disable-long-line-mark ()
>   (whitespace-toggle-options 'lines-tail))
>
> (add-hook 'org-mode-hook 'my/disable-long-line-mark)

I later realised that it's probably because turning on local
whitespace-mode with `whitespace-toggle-options` was getting clobbered
by having global-whitespace-mode active in the buffer as well. So I've
set whitespace-global-modes to ignore org-mode:

(setq whitespace-global-modes '(not org-mode))

And now I'm getting the behaviour I was expecting. I'm still not sure if
this is the best way to modify whitespace settings per-mode, but it's a
start.

Thanks,
--
Pete



reply via email to

[Prev in Thread] Current Thread [Next in Thread]