diff options
| author | Chong Yidong | 2012-04-25 23:06:51 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-04-25 23:06:51 +0800 |
| commit | 07875ee72bffac01a1978d0367883d6ceb88cc55 (patch) | |
| tree | e0815f89a1b9d015e0fdbde6670bec3aeef74096 /lisp/vc/diff-mode.el | |
| parent | 5055880d396c98f9bacfd4d19aa4a9ae85d3a87c (diff) | |
| download | emacs-07875ee72bffac01a1978d0367883d6ceb88cc55.tar.gz emacs-07875ee72bffac01a1978d0367883d6ceb88cc55.zip | |
Fix whitespace highlighting of context diffs.
* lisp/vc/diff-mode.el (diff-setup-whitespace): New function.
(diff-mode): Use it.
* lisp/vc/diff.el (diff-sentinel):
* lisp/vc/vc.el (vc-diff-finish): Call diff-setup-whitespace to assign
Whitespace mode variables based on diff style.
Fixes: debbugs:8612
Diffstat (limited to 'lisp/vc/diff-mode.el')
| -rw-r--r-- | lisp/vc/diff-mode.el | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 8b6b85dd22e..c92371fc90b 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el | |||
| @@ -1283,11 +1283,7 @@ a diff with \\[diff-reverse-direction]. | |||
| 1283 | (set (make-local-variable 'end-of-defun-function) | 1283 | (set (make-local-variable 'end-of-defun-function) |
| 1284 | 'diff-end-of-file) | 1284 | 'diff-end-of-file) |
| 1285 | 1285 | ||
| 1286 | ;; Set up `whitespace-mode' so that turning it on will show trailing | 1286 | (diff-setup-whitespace) |
| 1287 | ;; whitespace problems on the modified lines of the diff. | ||
| 1288 | (set (make-local-variable 'whitespace-style) '(face trailing)) | ||
| 1289 | (set (make-local-variable 'whitespace-trailing-regexp) | ||
| 1290 | "^[-\+!<>].*?\\([\t ]+\\)$") | ||
| 1291 | 1287 | ||
| 1292 | (setq buffer-read-only diff-default-read-only) | 1288 | (setq buffer-read-only diff-default-read-only) |
| 1293 | ;; setup change hooks | 1289 | ;; setup change hooks |
| @@ -1332,6 +1328,22 @@ the mode if ARG is omitted or nil. | |||
| 1332 | 1328 | ||
| 1333 | ;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1329 | ;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1334 | 1330 | ||
| 1331 | (defun diff-setup-whitespace () | ||
| 1332 | "Set up Whitespace mode variables for the current Diff mode buffer. | ||
| 1333 | This sets `whitespace-style' and `whitespace-trailing-regexp' so | ||
| 1334 | that Whitespace mode shows trailing whitespace problems on the | ||
| 1335 | modified lines of the diff." | ||
| 1336 | (set (make-local-variable 'whitespace-style) '(face trailing)) | ||
| 1337 | (let ((style (save-excursion | ||
| 1338 | (goto-char (point-min)) | ||
| 1339 | (when (re-search-forward diff-hunk-header-re nil t) | ||
| 1340 | (goto-char (match-beginning 0)) | ||
| 1341 | (diff-hunk-style))))) | ||
| 1342 | (set (make-local-variable 'whitespace-trailing-regexp) | ||
| 1343 | (if (eq style 'context) | ||
| 1344 | "^[-\+!] .*?\\([\t ]+\\)$" | ||
| 1345 | "^[-\+!<>].*?\\([\t ]+\\)$")))) | ||
| 1346 | |||
| 1335 | (defun diff-delete-if-empty () | 1347 | (defun diff-delete-if-empty () |
| 1336 | ;; An empty diff file means there's no more diffs to integrate, so we | 1348 | ;; An empty diff file means there's no more diffs to integrate, so we |
| 1337 | ;; can just remove the file altogether. Very handy for .rej files if we | 1349 | ;; can just remove the file altogether. Very handy for .rej files if we |