From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: YE via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56679: 28.1; whitespace-style cannot be configured for diff-mode via hook Date: Thu, 21 Jul 2022 17:46:17 +0300 Message-ID: Reply-To: YE Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22358"; mail-complaints-to="usenet@ciao.gmane.io" To: 56679@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 21 16:47:11 2022 Return-path: Envelope-to: geb-bug-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 1oEXSI-0005aF-H1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Jul 2022 16:47:10 +0200 Original-Received: from localhost ([::1]:44636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEXSH-0007Ic-7b for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Jul 2022 10:47:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEXSA-0007IO-HB for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 10:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEXSA-0003bA-8t for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 10:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oEXSA-000543-2d for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: YE Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Jul 2022 14:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56679 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165841480019433 (code B ref -1); Thu, 21 Jul 2022 14:47:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jul 2022 14:46:40 +0000 Original-Received: from localhost ([127.0.0.1]:38585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEXRo-00053M-5S for submit@debbugs.gnu.org; Thu, 21 Jul 2022 10:46:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEXRm-00053F-Hj for submit@debbugs.gnu.org; Thu, 21 Jul 2022 10:46:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEXRm-0007Fb-D8 for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 10:46:38 -0400 Original-Received: from out0.migadu.com ([2001:41d0:2:267::]:60668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEXRj-0003TQ-LI for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 10:46:38 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ego.team; s=key1; t=1658414784; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=hZM9l5Tn2yqLXpP7UAx7lDwmtsWzxaaND7RXQ5QppXs=; b=p1ob1Dqw86eHtUUVoT8lDO82mhIQX7UXmR/zf5TBoI/QmaKrOhewxpeP6Yo4QM0ZJAbFd2 S7JPJc+wmDxrMZwVJBvcx4gZRYf53wEwgTeiFgVuAmIt/U5J3/h0oFwNJLLMuErMs6aset hD909WqRRIk8ZSBwE4yXjPxiREf8swM= X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: ego.team Received-SPF: pass client-ip=2001:41d0:2:267::; envelope-from=yet@ego.team; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" X-ACL-Warn: , YE Xref: news.gmane.io gmane.emacs.bugs:237556 Archived-At: Steps To Reproduce: emacs -Q *diff-mode-hook* 1. #+begin_src emacs-lisp (defun my-diff-mode () (setq-local whitespace-style '(face trailing spaces)) (message "diff-mode-hook: %S" whitespace-style)) (add-hook 'diff-mode-hook 'my-diff-mode) #+end_src 2. 'M-x vc-dir ' 3. Activate diff view (f.i. 'M-x vc-diff' or 'M-x log-view-diff') 4. See that 'C-h v whitespace-style' outputs '(face trailing)' instead of the expected value '(face trailing spaces)'. Additional Information A bit of investigation showed that 'diff-setup-whitespace' always sets 'whitespace-style' to '(face trailing)'. The debugged order of setting 'whitespace-style' value: - diff-setup-whitespace: (face trailing) - diff-mode-hook: (face trailing spaces) - diff-setup-whitespace: (face trailing) So might be the order of the value setting can be fixed? Or maybe adding a defcustom 'diff-whitespace-style' would be a proper solution here? I started working on such a patch but stuck disliking the probable need in the 'whitespace-style' large ':type' definition duplication. *whitespace-mode-hook* I also attempted another approach (though didn't investigate it, so probably it's a separate issue). It's also not functional. emacs -Q 1. #+begin_src emacs-lisp (defun my-whitespace-mode () (when (eq major-mode 'diff-mode) (setq-local whitespace-style '(face trailing spaces)))) (add-hook 'whitespace-mode-hook 'my-whitespace-mode) #+end_src 2. In diff-mode 'C-h v whitespace-style' outputs expected '(face trailing)'. 3. Enable whitespace-mode 'M-x whitespace-mode'. 4. See that 'C-h v whitespace-style' outputs expected '(face trailing spaces)'. But this doesn't change the buffer's output. 5. Eval '(whitespace-turn-on)' to see the expected buffer output (or toggle the mode twice with 'M-x whitespace-mode'). *Current Workaround* The workaround I currently use adds a keybinding to set 'whitespace-style' and toggle 'whitespace-mode'. #+begin_src emacs-lisp (defun my-diff-whitespace () "Toggle whitespace visualization with local `whitespace-style'." (interactive) (setq-local whitespace-style '(face trailing spaces)) (whitespace-mode 'toggle)) (define-key diff-mode-map (kbd "C-c b w") 'my-diff-whitespace) #+end_src