mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-11 09:20:51 +00:00
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
This commit is contained in:
parent
5055880d39
commit
07875ee72b
@ -1,3 +1,12 @@
|
||||
2012-04-25 Chong Yidong <cyd@gnu.org>
|
||||
|
||||
* vc/diff-mode.el (diff-setup-whitespace): New function.
|
||||
(diff-mode): Use it.
|
||||
|
||||
* vc/diff.el (diff-sentinel):
|
||||
* vc/vc.el (vc-diff-finish): Call diff-setup-whitespace to assign
|
||||
Whitespace mode variables based on diff style (Bug#8612).
|
||||
|
||||
2012-04-25 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* files.el (auto-mode-alist): Use javascript-mode instead.
|
||||
|
@ -1283,11 +1283,7 @@ a diff with \\[diff-reverse-direction].
|
||||
(set (make-local-variable 'end-of-defun-function)
|
||||
'diff-end-of-file)
|
||||
|
||||
;; Set up `whitespace-mode' so that turning it on will show trailing
|
||||
;; whitespace problems on the modified lines of the diff.
|
||||
(set (make-local-variable 'whitespace-style) '(face trailing))
|
||||
(set (make-local-variable 'whitespace-trailing-regexp)
|
||||
"^[-\+!<>].*?\\([\t ]+\\)$")
|
||||
(diff-setup-whitespace)
|
||||
|
||||
(setq buffer-read-only diff-default-read-only)
|
||||
;; setup change hooks
|
||||
@ -1332,6 +1328,22 @@ the mode if ARG is omitted or nil.
|
||||
|
||||
;;; 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."
|
||||
(set (make-local-variable 'whitespace-style) '(face trailing))
|
||||
(let ((style (save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward diff-hunk-header-re nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(diff-hunk-style)))))
|
||||
(set (make-local-variable 'whitespace-trailing-regexp)
|
||||
(if (eq style 'context)
|
||||
"^[-\+!] .*?\\([\t ]+\\)$"
|
||||
"^[-\+!<>].*?\\([\t ]+\\)$"))))
|
||||
|
||||
(defun diff-delete-if-empty ()
|
||||
;; An empty diff file means there's no more diffs to integrate, so we
|
||||
;; can just remove the file altogether. Very handy for .rej files if we
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(declare-function diff-setup-whitespace "diff-mode" ())
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defgroup diff nil
|
||||
@ -64,6 +66,7 @@ If optional args OLD-TEMP-FILE and/or NEW-TEMP-FILE are non-nil,
|
||||
delete the temporary files so named."
|
||||
(if old-temp-file (delete-file old-temp-file))
|
||||
(if new-temp-file (delete-file new-temp-file))
|
||||
(diff-setup-whitespace)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(let ((inhibit-read-only t))
|
||||
|
@ -655,6 +655,8 @@
|
||||
(require 'vc-dispatcher)
|
||||
(require 'ediff)
|
||||
|
||||
(declare-function diff-setup-whitespace "diff-mode" ())
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl)
|
||||
(require 'dired))
|
||||
@ -1524,17 +1526,18 @@ to override the value of `vc-diff-switches' and `diff-switches'."
|
||||
;; possibility of an empty output is for an async process.
|
||||
(when (buffer-live-p buffer)
|
||||
(let ((window (get-buffer-window buffer t))
|
||||
(emptyp (zerop (buffer-size buffer))))
|
||||
(emptyp (zerop (buffer-size buffer))))
|
||||
(with-current-buffer buffer
|
||||
(and messages emptyp
|
||||
(let ((inhibit-read-only t))
|
||||
(insert (cdr messages) ".\n")
|
||||
(message "%s" (cdr messages))))
|
||||
(goto-char (point-min))
|
||||
(when window
|
||||
(shrink-window-if-larger-than-buffer window)))
|
||||
(and messages emptyp
|
||||
(let ((inhibit-read-only t))
|
||||
(insert (cdr messages) ".\n")
|
||||
(message "%s" (cdr messages))))
|
||||
(diff-setup-whitespace)
|
||||
(goto-char (point-min))
|
||||
(when window
|
||||
(shrink-window-if-larger-than-buffer window)))
|
||||
(when (and messages (not emptyp))
|
||||
(message "%sdone" (car messages))))))
|
||||
(message "%sdone" (car messages))))))
|
||||
|
||||
(defvar vc-diff-added-files nil
|
||||
"If non-nil, diff added files by comparing them to /dev/null.")
|
||||
|
Loading…
Reference in New Issue
Block a user