>From 86a90344673a8ca9645f11ec790c16eda6a4120e Mon Sep 17 00:00:00 2001 From: YugaEgo Date: Sat, 23 Jul 2022 22:25:10 +0300 Subject: [PATCH] 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. --- etc/NEWS | 7 +++++++ lisp/vc/diff-mode.el | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 412a93bbf9..dcece83767 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1190,6 +1190,13 @@ the run/continue command. This is bound to 'H' and toggles whether to hide or show the widget contents. +** Diff mode + +--- +*** New user option 'diff-whitespace-style'. +This option determines buffer-local 'whitespace-style' value. + + ** Ispell --- diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 30ba4153a9..8d9caf35a3 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 @@ diff-font-lock-syntax (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 @@ diff--font-lock-cleanup ;; 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 @@ diff-setup-whitespace 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 -- 2.34.1