[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v |
Date: |
Fri, 19 Oct 2007 17:16:46 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 07/10/19 17:16:45
Index: diff-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- diff-mode.el 13 Oct 2007 00:07:23 -0000 1.118
+++ diff-mode.el 19 Oct 2007 17:16:43 -0000 1.119
@@ -1657,20 +1657,22 @@
:group 'diff-mode)
(defun diff-fine-highlight-preproc ()
- (while (re-search-forward "^." nil t)
- ;; Replace the hunk's leading prefix (+, -, !, <, or >) on each line
- ;; with something constant, otherwise it'll be flagged as changes
- ;; (since it's typically "-" on one side and "+" on the other).
- ;; Note that we keep the same number of chars: we treat the prefix
- ;; as part of the texts-to-diff, so that finding the right char
- ;; afterwards will be easier. This only makes sense because we make
- ;; diffs at char-granularity.
- (replace-match " ")))
+ (while (re-search-forward "^[+>]" nil t)
+ ;; Remove spurious changes due to the fact that one side of the hunk is
+ ;; marked with leading + or > and the other with leading - or <.
+ ;; We used to replace all the prefix chars with " " but this only worked
+ ;; when we did char-based refinement (or when using
+ ;; smerge-refine-weight-hack) since otherwise, the `forward' motion done
+ ;; in chopup do not necessarily do the same as the ones in highlight
+ ;; since the "_" is not treated the same as " ".
+ (replace-match (cdr (assq (char-before) '((?+ . "-") (?> . "<"))))))
+ )
(defun diff-fine-highlight ()
"Highlight changes of hunk at point at a finer granularity."
(interactive)
(require 'smerge-mode)
+ (save-excursion
(diff-beginning-of-hunk 'try-harder)
(let* ((style (diff-hunk-style)) ;Skips the hunk header as well.
(beg (point))
@@ -1682,7 +1684,8 @@
(goto-char beg)
(case style
(unified
- (while (re-search-forward "^\\(?:-.*\n\\)+\\(\\)\\(?:\\+.*\n\\)+" end t)
+ (while (re-search-forward "^\\(?:-.*\n\\)+\\(\\)\\(?:\\+.*\n\\)+"
+ end t)
(smerge-refine-subst (match-beginning 0) (match-end 1)
(match-end 1) (match-end 0)
props 'diff-fine-highlight-preproc)))
@@ -1704,7 +1707,7 @@
;; It's a combined add&remove, so there's something to do.
(smerge-refine-subst beg1 (match-beginning 0)
(match-end 0) end
- props 'diff-fine-highlight-preproc)))))))
+ props 'diff-fine-highlight-preproc))))))))
;; provide the package
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Stefan Monnier, 2007/10/09
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Stefan Monnier, 2007/10/09
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Miles Bader, 2007/10/09
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Stefan Monnier, 2007/10/12
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Dan Nicolaescu, 2007/10/12
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Stefan Monnier, 2007/10/19
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Dan Nicolaescu, 2007/10/20
- [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v, Dan Nicolaescu, 2007/10/21