From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Peter Hardy Newsgroups: gmane.emacs.help Subject: Re: Changing whitespace-mode style in mode hook? Date: Thu, 11 Mar 2021 09:04:01 +1100 Message-ID: References: Reply-To: peter@hardy.dropbear.id.au Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36853"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 27.1 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 10 23:13:54 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK75W-0009Qx-90 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Mar 2021 23:13:54 +0100 Original-Received: from localhost ([::1]:48374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK75V-0006kt-3t for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Mar 2021 17:13:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK6w9-0001UQ-QG for help-gnu-emacs@gnu.org; Wed, 10 Mar 2021 17:04:15 -0500 Original-Received: from [2401:1801:7801:101:be76:4eff:fe18:42f] (port=58078 helo=mta1.hardy.dropbear.id.au) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK6w7-0004Qz-Ly for help-gnu-emacs@gnu.org; Wed, 10 Mar 2021 17:04:13 -0500 Original-Received: from graphite.lan (159-196-146-240.9fc492.syd.nbn.aussiebb.net [159.196.146.240]) (Authenticated sender: peter) by mta1.hardy.dropbear.id.au (Postfix) with ESMTPSA id 825F281709 for ; Wed, 10 Mar 2021 22:04:04 +0000 (UTC) In-reply-to: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2401:1801:7801:101:be76:4eff:fe18:42f (failed) Received-SPF: pass client-ip=2401:1801:7801:101:be76:4eff:fe18:42f; envelope-from=peter@hardy.dropbear.id.au; helo=mta1.hardy.dropbear.id.au X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_05=-0.5, DKIM_ADSP_ALL=0.8, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128387 Archived-At: Peter Hardy writes: > First, in my init.el I'm turning on global whitespace mode like this: > > (global-whitespace-mode t) > (setq whitespace-style (quote (face trailing tabs lines-tail newline empty indentation space-after-tab space-before-tab)))) > > But for some modes I don't want long lines to be highlighted - usually > because I'm using visual-line-mode instead. So I wrote a quick function > to toggle off the lines-tail option, and added it to a mode hook: > > (defun my/disable-long-line-mark () > (whitespace-toggle-options 'lines-tail)) > > (add-hook 'org-mode-hook 'my/disable-long-line-mark) I later realised that it's probably because turning on local whitespace-mode with `whitespace-toggle-options` was getting clobbered by having global-whitespace-mode active in the buffer as well. So I've set whitespace-global-modes to ignore org-mode: (setq whitespace-global-modes '(not org-mode)) And now I'm getting the behaviour I was expecting. I'm still not sure if this is the best way to modify whitespace settings per-mode, but it's a start. Thanks, -- Pete