From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Disabling show-wspace for a specific mode or buffer
Date: Thu, 28 Jun 2012 00:23:52 +0200 [thread overview]
Message-ID: <8762acz953.fsf@web.de> (raw)
In-Reply-To: <mailman.3588.1340828845.855.help-gnu-emacs@gnu.org> (Drew Adams's message of "Wed, 27 Jun 2012 13:27:12 -0700")
"Drew Adams" <drew.adams@oracle.com> writes:
> > (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)
Maybe an alternative approach would be to add the highlighting functions
to the text-mode-hook:
(add-hook 'text-mode-hook 'show-ws-highlight-tabs)
(add-hook 'text-mode-hook 'show-ws-highlight-trailing-whitespace)
Since most editing modes run `text-mode-hook', and other modes don't,
maybe this way you can get along with less exceptions? Just an idea.
Michael.
next prev parent reply other threads:[~2012-06-27 22:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 18:27 Disabling show-wspace for a specific mode or buffer Valera Rozuvan
2012-06-27 20:01 ` Alp Aker
2012-06-27 20:10 ` Valera Rozuvan
2012-06-27 20:31 ` Alp Aker
2012-06-27 20:41 ` Alp Aker
2012-06-27 20:56 ` Valera Rozuvan
2012-06-27 21:16 ` Drew Adams
2012-06-27 21:45 ` Valera Rozuvan
2012-06-27 22:12 ` Drew Adams
2012-06-27 20:27 ` Drew Adams
[not found] ` <mailman.3588.1340828845.855.help-gnu-emacs@gnu.org>
2012-06-27 22:23 ` Michael Heerdegen [this message]
2012-06-28 2:11 ` John Wiegley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8762acz953.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).