]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new user option 'diff-whitespace-style'
authorYugaEgo <yet@ego.team>
Sun, 24 Jul 2022 09:01:50 +0000 (11:01 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 24 Jul 2022 09:06:57 +0000 (11:06 +0200)
* 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
lisp/vc/diff-mode.el

index 27046894ad4a9db1a9def3628e0788842ee98196..1d0e45fdcc497d8ce1f4662ba683a566c44ae1f1 100644 (file)
--- 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
 
 ---
index 30ba4153a9e0a93e37b64a796379ea390fc8bca7..8d9caf35a3be7f58b531e9cc8eeffd0353ee090b 100644 (file)
@@ -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