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

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

Changing whitespace-mode style in mode hook?


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

Hey folks. I'm having trouble understanding how to modify
whitespace-mode styles for specific modes.

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've checked the value of `org-mode-hook` with describe-variable, and I
know that my function is being run when I visit an org file. But the
lines-tail option is still active (confirmed by running
whitespace-toggle-options interactively and checking what's enabled).

I've also checked with just evaluating (my/disable-long-line-mark) in a
buffer, and it behaves how I would expect; lines-tail is toggled off,
local whitespace-mode is turned on, and marks on long lines in the
buffer disappear.

I guess I'm misusing whitespace-toggle-options or something here. Or
there's a better way to achieve what I'm trying to do. But I'm currently
at a loss. Any advice would be appreciated!

Thanks,
--
Pete



reply via email to

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