From 2c980815f5c88c14cf7567aa12eb23fc1d41d5d1 Mon Sep 17 00:00:00 2001 From: YugaEgo Date: Sun, 24 Jul 2022 11:01:50 +0200 Subject: Add new user option 'diff-whitespace-style' * lisp/vc/diff-mode.el (diff-whitespace-style): New user option. (diff-setup-whitespace): Use it (Bug#56679). (top level): require 'whitespace. (whitespace-style, whitespace-trailing-regexp): Remove defvars. --- lisp/vc/diff-mode.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/vc/diff-mode.el') diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 30ba4153a9e..8d9caf35a3b 100644 --- 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) (autoload 'vc-find-revision "vc") (autoload 'vc-find-revision-no-save "vc") @@ -147,6 +148,11 @@ and hunk-based syntax highlighting otherwise as a fallback." (const :tag "Highlight syntax" t) (const :tag "Allow hunk-based fallback" hunk-also))) +(defcustom diff-whitespace-style '(face trailing) + "Specify `whitespace-style' variable for the current Diff mode buffer." + :type (get 'whitespace-style 'custom-type) + :version "29.1") + (defvar diff-vc-backend nil "The VC backend that created the current Diff buffer, if any.") @@ -1476,9 +1482,6 @@ See `after-change-functions' for the meaning of BEG, END and LEN." ;; Added when diff--font-lock-prettify is non-nil! (cl-pushnew 'display font-lock-extra-managed-props))) -(defvar whitespace-style) -(defvar whitespace-trailing-regexp) - (defvar-local diff-mode-read-only nil "Non-nil when read-only diff buffer uses short keys.") @@ -1572,7 +1575,7 @@ a diff with \\[diff-reverse-direction]. This sets `whitespace-style' and `whitespace-trailing-regexp' so that Whitespace mode shows trailing whitespace problems on the modified lines of the diff." - (setq-local whitespace-style '(face trailing)) + (setq-local whitespace-style diff-whitespace-style) (let ((style (save-excursion (goto-char (point-min)) ;; FIXME: For buffers filled from async processes, this search -- cgit v1.2.3