emacs-devel
[Top][All Lists]
Advanced

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

Re: global-whitespace-mode should show whitespace when switching to new


From: Jefferson Carpenter
Subject: Re: global-whitespace-mode should show whitespace when switching to new buffer
Date: Fri, 30 Mar 2018 21:57:33 +0000
User-agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Sorry, this is pretty minor, all things considered. (I have a much more interesting project that I would also like some feedback on, but this is something I happened to crash into while I was formatting my question for that project.)

On 3/30/2018 9:51 PM, Jefferson Carpenter wrote:
This is probably the worst patch you've ever seen - not sure whether the "advice" I added is the optimal one to add, it just seems to solve the problem for me.  Adding unused "&rest args" to a function so that it can be used as advice is probably incorrect as well.

Problem was, with global-whitespace-mode enabled, when I switched to a new buffer (say C-x b asdf <RET>), whitespace was not visible.  The `whitespacesturn-on-if-enabled' function is already added to after-change-major-mode-hook, but apparently that isn't triggered when a new buffer is created in fundamental-mode.  If I turn global-whitespace-mode off and back on again, or if I type "M-x fundamental-mode", then whitespace is visible.

The fix I came up with in my init file was to add the code:

     (defun whitespace-turn-on-if-enabled-2 (&rest args)
       (whitespace-turn-on-if-enabled))
     (advice-add 'switch-to-buffer :after 'whitespace-turn-on-if-enabled-2)

But I figured I would create a patch and let you guys look at it and decide what should be done.  I have attached it.  It works for me, but might not fix a wider root cause, and is almost certainly not the optimal elisp code in any case.


Jefferson Carpenter

P.S. Even with the above fix (either init file or whitespace.el patch), when I switch to a new buffer, whitespace is shown but in the wrong color.  It remains the wrong color if I turn global-whitespace-mode off and on again, but uses the "whitespace-space" face, etc. as it should, when I run "M-x fundamental-mode" (the buffer already being in fundamental-mode).



reply via email to

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