GNU bug report logs -
#56679
28.1; whitespace-style cannot be configured for diff-mode via hook
Previous Next
Reported by: YE <yet <at> ego.team>
Date: Thu, 21 Jul 2022 14:47:01 UTC
Severity: normal
Found in version 28.1
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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 <any-repo>'
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
This bug report was last modified 2 years and 355 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.