Function: diff-setup-whitespace

diff-setup-whitespace is a byte-compiled function defined in diff-mode.el.gz.

Signature

(diff-setup-whitespace)

Documentation

Set up Whitespace mode variables for the current Diff mode buffer.

This sets whitespace-style and whitespace-trailing-regexp(var)/whitespace-trailing-regexp(fun) so that Whitespace mode shows trailing whitespace problems on the modified lines of the diff.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/diff-mode.el.gz
;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun diff-setup-whitespace ()
  "Set up Whitespace mode variables for the current Diff mode buffer.
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))
  (let ((style (save-excursion
		 (goto-char (point-min))
                 ;; FIXME: For buffers filled from async processes, this search
                 ;; will simply fail because the buffer is still empty :-(
		 (when (re-search-forward diff-hunk-header-re nil t)
		   (goto-char (match-beginning 0))
		   (diff-hunk-style)))))
    (setq-local whitespace-trailing-regexp
                (if (eq style 'context)
                    "^[-+!] .*?\\([\t ]+\\)$"
                  "^[-+!<>].*?\\([\t ]+\\)$"))))