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: Changing whitespace-mode style in mode hook? Date: Thu, 11 Mar 2021 00:23:52 +1100 Message-ID: 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="2350"; 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 14:35:11 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 1lJyzX-0000S2-22 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Mar 2021 14:35:11 +0100 Original-Received: from localhost ([::1]:55908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJyzW-0005rE-3j for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Mar 2021 08:35:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJyxc-0004E2-JD for help-gnu-emacs@gnu.org; Wed, 10 Mar 2021 08:33:12 -0500 Original-Received: from [119.9.27.184] (port=59070 helo=mta1.hardy.dropbear.id.au) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJyxa-0000gS-Ga for help-gnu-emacs@gnu.org; Wed, 10 Mar 2021 08:33:12 -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 9ABAE81EA4 for ; Wed, 10 Mar 2021 13:23:54 +0000 (UTC) X-Host-Lookup-Failed: Reverse DNS lookup failed for 119.9.27.184 (failed) Received-SPF: pass client-ip=119.9.27.184; envelope-from=peter@hardy.dropbear.id.au; helo=mta1.hardy.dropbear.id.au X-Spam_score_int: 30 X-Spam_score: 3.0 X-Spam_bar: +++ X-Spam_report: (3.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_ALL=0.8, RCVD_IN_PBL=3.335, 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:128384 Archived-At: Hey folks. I'm having trouble understanding how to modify whitespace-mode styles for specific modes. 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've checked the value of `org-mode-hook` with describe-variable, and I know that my function is being run when I visit an org file. But the lines-tail option is still active (confirmed by running whitespace-toggle-options interactively and checking what's enabled). I've also checked with just evaluating (my/disable-long-line-mark) in a buffer, and it behaves how I would expect; lines-tail is toggled off, local whitespace-mode is turned on, and marks on long lines in the buffer disappear. I guess I'm misusing whitespace-toggle-options or something here. Or there's a better way to achieve what I'm trying to do. But I'm currently at a loss. Any advice would be appreciated! Thanks, -- Pete