[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r108031: Fix whitespace highlighting
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r108031: Fix whitespace highlighting of context diffs. |
Date: |
Wed, 25 Apr 2012 23:06:51 +0800 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 108031
fixes bug(s): http://debbugs.gnu.org/8612
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Wed 2012-04-25 23:06:51 +0800
message:
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.
modified:
lisp/ChangeLog
lisp/vc/diff-mode.el
lisp/vc/diff.el
lisp/vc/vc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-04-25 14:47:33 +0000
+++ b/lisp/ChangeLog 2012-04-25 15:06:51 +0000
@@ -1,3 +1,12 @@
+2012-04-25 Chong Yidong <address@hidden>
+
+ * 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 <address@hidden>
* files.el (auto-mode-alist): Use javascript-mode instead.
=== modified file 'lisp/vc/diff-mode.el'
--- a/lisp/vc/diff-mode.el 2012-04-14 06:28:57 +0000
+++ b/lisp/vc/diff-mode.el 2012-04-25 15:06:51 +0000
@@ -1283,11 +1283,7 @@
(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 @@
;;; 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
=== modified file 'lisp/vc/diff.el'
--- a/lisp/vc/diff.el 2012-01-19 07:21:25 +0000
+++ b/lisp/vc/diff.el 2012-04-25 15:06:51 +0000
@@ -30,6 +30,8 @@
;;; Code:
+(declare-function diff-setup-whitespace "diff-mode" ())
+
(eval-when-compile (require 'cl))
(defgroup diff nil
@@ -64,6 +66,7 @@
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))
=== modified file 'lisp/vc/vc.el'
--- a/lisp/vc/vc.el 2012-04-22 13:58:00 +0000
+++ b/lisp/vc/vc.el 2012-04-25 15:06:51 +0000
@@ -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 @@
;; 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.")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r108031: Fix whitespace highlighting of context diffs.,
Chong Yidong <=