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: Valera Rozuvan
Subject: Re: Disabling show-wspace for a specific mode or buffer
Date: Wed, 27 Jun 2012 23:56:04 +0300

> Actually, that's not important.  But try Drew's suggestion, or my
> other suggestion.

Thanks for your replies! I have modified your suggestions, and came up
with the following:

(defun show-ws-dont-highlight-trailing-whitespace ()
    "Don't highlight whitespace characters at line ends."
    (interactive)
    (when (fboundp 'font-lock-remove-keywords)
        (font-lock-remove-keywords
            nil '(("[\240\040\t]+$" (0 'show-ws-trailing-whitespace t)))))
    (when (called-interactively-p 'any)
        (font-lock-fontify-buffer)))

(defun show-ws-highlight-trailing-whitespace ()
    "Highlight whitespace characters at line ends."
    (interactive)
    (font-lock-add-keywords
        nil '(("[\240\040\t]+$" (0 'show-ws-trailing-whitespace t))))
    (when (called-interactively-p 'any)
        (font-lock-fontify-buffer)))

(global-set-key (kbd "<f11>") 'show-ws-dont-highlight-trailing-whitespace)
(global-set-key (kbd "<f12>") 'show-ws-highlight-trailing-whitespace)

Now when I press F11 - the highlighting is turned off (F12 turns it
back on). I believe that this approach is the best for me because I
don't have to hard code into ~/.emacs the modes for which I want to
disable the highlighting functionality.

Thanks,
Valera Rozuvan



reply via email to

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