Subject: bug#56679: 28.1; [PATCH] whitespace-style cannot be configured for diff-mode via hook

From: Eli Zaretskii <[email-masked]>
Date: Sun, 24 Jul 2022 12:08:27 +0300

> Cc: [email-masked], [email-masked]
> Date: Sun, 24 Jul 2022 10:49:33 +0300
> From:  YE via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> > I think you don't need a duplication.  You can reuse an existing type
> > definition by looking up the `custom-type` symbol property of an already
> > defined option.  See e.g. "lisp/eshell/em-cmpl.el" for a few example
> > definitions.
> 
> Thanks for the advice.
> 
> The proposed patch is attached.

Thanks.

> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -56,6 +56,7 @@
>  (eval-when-compile (require 'cl-lib))
>  (eval-when-compile (require 'subr-x))
>  (require 'easy-mmode)
> +(require 'whitespace)

Can we delay loading whitespace.el until the user actually wants to
turn on whitespace-mode, or until he/she customizes this option?
AFAIU, whitespace-mode is not turned on unconditionally by diff-mode,
so this 'require' is not needed for users who don't turn that minor
mode in Diff buffers.

> +(defcustom diff-whitespace-style '(face trailing)
> +  "Specify `whitespace-style' variable for the current Diff mode buffer."

AFAIU, this style will be applied to all Diff mode buffers, not just
the "current" one.  Right?

> +** Diff mode
> +
> +---
> +*** New user option 'diff-whitespace-style'.
> +This option determines buffer-local 'whitespace-style' value.

Should we tell that if someone was using whitespace-style directly for
this purpose, they should use this new option instead?