aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-05-15 10:09:43 -0400
committerChong Yidong2011-05-15 10:09:43 -0400
commit5e9e35cd1dd6e4fb47c6720991581508b89f87f7 (patch)
treee8e614ca30721ed75c7f49f98230fa3a48230ee4
parentc8e837514fa2e5c161106a6d14ef174561496f1b (diff)
downloademacs-5e9e35cd1dd6e4fb47c6720991581508b89f87f7.tar.gz
emacs-5e9e35cd1dd6e4fb47c6720991581508b89f87f7.zip
Fix minor bug of diff-fixup-modifs on small diffs (Bug#8672).
* vc/diff-mode.el (diff-fixup-modifs): Locate correct position for hunk-end tags.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/vc/diff-mode.el80
2 files changed, 44 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 631a1bec3d0..2e0e7f99e56 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12011-05-15 Chong Yidong <cyd@stupidchicken.com> 12011-05-15 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * vc/diff-mode.el (diff-fixup-modifs): Locate correct position for
4 hunk-end tags (Bug#8672).
5
3 * vc/vc-annotate.el (vc-annotate-mode-map): Bind = to 6 * vc/vc-annotate.el (vc-annotate-mode-map): Bind = to
4 vc-annotate-show-diff-revision-at-line (Bug#8671). 7 vc-annotate-show-diff-revision-at-line (Bug#8671).
5 8
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 22dac00e7e4..318163f39ca 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1118,45 +1118,47 @@ else cover the whole buffer."
1118 (save-excursion 1118 (save-excursion
1119 (goto-char end) (diff-end-of-hunk nil 'donttrustheader) 1119 (goto-char end) (diff-end-of-hunk nil 'donttrustheader)
1120 (let ((plus 0) (minus 0) (space 0) (bang 0)) 1120 (let ((plus 0) (minus 0) (space 0) (bang 0))
1121 (while (and (= (forward-line -1) 0) (<= start (point))) 1121 while (and (= (forward-line -1) 0) (<= start (point)))
1122 (if (not (looking-at 1122 (if (not (looking-at
1123 (concat diff-hunk-header-re-unified 1123 (concat diff-hunk-header-re-unified
1124 "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$" 1124 "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$"
1125 "\\|--- .+\n\\+\\+\\+ "))) 1125 "\\|--- .+\n\\+\\+\\+ ")))
1126 (case (char-after) 1126 (case (char-after)
1127 (?\s (incf space)) 1127 (?\s (incf space))
1128 (?+ (incf plus)) 1128 (?+ (incf plus))
1129 (?- (incf minus)) 1129 (?- (incf minus))
1130 (?! (incf bang)) 1130 (?! (incf bang))
1131 ((?\\ ?#) nil) 1131 ((?\\ ?#) nil)
1132 (t (setq space 0 plus 0 minus 0 bang 0))) 1132 (t (setq space 0 plus 0 minus 0 bang 0)))
1133 (cond 1133 (cond
1134 ((looking-at diff-hunk-header-re-unified) 1134 ((looking-at diff-hunk-header-re-unified)
1135 (let* ((old1 (match-string 2)) 1135 (let* ((old1 (match-string 2))
1136 (old2 (match-string 4)) 1136 (old2 (match-string 4))
1137 (new1 (number-to-string (+ space minus))) 1137 (new1 (number-to-string (+ space minus)))
1138 (new2 (number-to-string (+ space plus)))) 1138 (new2 (number-to-string (+ space plus))))
1139 (if old2 1139 (if old2
1140 (unless (string= new2 old2) (replace-match new2 t t nil 4)) 1140 (unless (string= new2 old2) (replace-match new2 t t nil 4))
1141 (goto-char (match-end 4)) (insert "," new2)) 1141 (goto-char (match-end 3))
1142 (if old1 1142 (insert "," new2))
1143 (unless (string= new1 old1) (replace-match new1 t t nil 2)) 1143 (if old1
1144 (goto-char (match-end 2)) (insert "," new1)))) 1144 (unless (string= new1 old1) (replace-match new1 t t nil 2))
1145 ((looking-at diff-context-mid-hunk-header-re) 1145 (goto-char (match-end 1))
1146 (when (> (+ space bang plus) 0) 1146 (insert "," new1))))
1147 (let* ((old1 (match-string 1)) 1147 ((looking-at diff-context-mid-hunk-header-re)
1148 (old2 (match-string 2)) 1148 (when (> (+ space bang plus) 0)
1149 (new (number-to-string 1149 (let* ((old1 (match-string 1))
1150 (+ space bang plus -1 (string-to-number old1))))) 1150 (old2 (match-string 2))
1151 (unless (string= new old2) (replace-match new t t nil 2))))) 1151 (new (number-to-string
1152 ((looking-at "\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]*\\) \\*\\*\\*\\*$") 1152 (+ space bang plus -1 (string-to-number old1)))))
1153 (when (> (+ space bang minus) 0) 1153 (unless (string= new old2) (replace-match new t t nil 2)))))
1154 (let* ((old (match-string 1)) 1154 ((looking-at "\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]*\\) \\*\\*\\*\\*$")
1155 (new (format 1155 (when (> (+ space bang minus) 0)
1156 (concat "%0" (number-to-string (length old)) "d") 1156 (let* ((old (match-string 1))
1157 (+ space bang minus -1 (string-to-number old))))) 1157 (new (format
1158 (unless (string= new old) (replace-match new t t nil 2)))))) 1158 (concat "%0" (number-to-string (length old)) "d")
1159 (setq space 0 plus 0 minus 0 bang 0))))))) 1159 (+ space bang minus -1 (string-to-number old)))))
1160 (unless (string= new old) (replace-match new t t nil 2))))))
1161 (setq space 0 plus 0 minus 0 bang 0)))))))
1160 1162
1161;;;; 1163;;;;
1162;;;; Hooks 1164;;;; Hooks