From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Disabling show-wspace for a specific mode or buffer Date: Thu, 28 Jun 2012 00:23:52 +0200 Message-ID: <8762acz953.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1340835712 15014 80.91.229.3 (27 Jun 2012 22:21:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 27 Jun 2012 22:21:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 28 00:21:52 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sk0cR-0004H1-QR for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jun 2012 00:21:51 +0200 Original-Received: from localhost ([::1]:36448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sk0cR-0006gh-Jg for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jun 2012 18:21:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sk0cM-0006fz-G0 for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 18:21:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sk0cK-0005L1-Ts for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 18:21:46 -0400 Original-Received: from mout.web.de ([212.227.15.4]:50967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sk0cK-0005KQ-Jd for help-gnu-emacs@gnu.org; Wed, 27 Jun 2012 18:21:44 -0400 Original-Received: from snow.dragon ([89.204.130.168]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MCIYT-1Say3g06nh-008prW; Thu, 28 Jun 2012 00:21:42 +0200 In-Reply-To: (Drew Adams's message of "Wed, 27 Jun 2012 13:27:12 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-Provags-ID: V02:K0:x0MpXeQu1VCD0GtdHhlOgrAkpmpcuVlSts9R+VaYORX JZaqX6Vmg++u2n6TTv8R30oBR2TXlST7YXNCbRi30mwapMWFvb ijh/hQNKhr0xK2rdHkvoyYnRFKM+CMkal/JrqgSZS7zeY5agDl T3lf8nHiDMy7pFuMf7eIBaiAjIENqF9JLSOvifELs/6XRnc17O To8huteTCaY/4FSyzoSzUlWO7hccNbaP+g3qEF2rg0= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.15.4 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85542 Archived-At: "Drew Adams" 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.