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

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

RE: Disabling show-wspace for a specific mode or buffer


From: Drew Adams
Subject: RE: Disabling show-wspace for a specific mode or buffer
Date: Wed, 27 Jun 2012 13:27:12 -0700

> I am using the package show-wspace (
> http://www.emacswiki.org/emacs/show-wspace.el ) to visually show
> trailing whitespace and tab characters in all my files. I achieve this
> by adding the following line to the ~/.emacs file:
> 
> (add-to-list 'load-path "~/.emacs.d/") ;; show-wspace.el can 
> be found here
> (require 'show-wspace)
> 
> (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
> (add-hook 'font-lock-mode-hook 'show-ws-highlight-trailing-whitespace)
> 
> My problem is that in 99% of buffers I want this behavior, but
> sometimes I don't. For example, when I run the command M-x w3m to
> browse the web, I don't want to see trailing whitespace highlighted.
> Can anyone suggest a solution for this problem?

Sorry, but there is no simple way to do that.  But you can do it in this
roundabout way (ugly!):

(add-hook 'change-major-mode-hook
          (lambda ()
            (add-hook 'font-lock-mode-hook
                      'show-ws-highlight-trailing-whitespace)))

(add-hook 'after-change-major-mode-hook
          (lambda ()
            (when (eq major-mode 'THE-MODE)
              (remove-hook 'font-lock-mode-hook
                           'show-ws-highlight-trailing-whitespace)
              (show-ws-dont-highlight-trailing-whitespace)))
          'append)

where THE-MODE is the mode of the buffer where you do not want the highlighting.

It's an old library - the code should probably be rewritten to define a minor
mode (and a globalized version of it).




reply via email to

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