aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/diff-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r--lisp/diff-mode.el82
1 files changed, 41 insertions, 41 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index a3c4ca617ed..b37c0802033 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -1116,47 +1116,47 @@ else cover the whole buffer."
1116 (save-excursion 1116 (save-excursion
1117 (goto-char end) (diff-end-of-hunk nil 'donttrustheader) 1117 (goto-char end) (diff-end-of-hunk nil 'donttrustheader)
1118 (let ((plus 0) (minus 0) (space 0) (bang 0)) 1118 (let ((plus 0) (minus 0) (space 0) (bang 0))
1119 while (and (= (forward-line -1) 0) (<= start (point))) 1119 (while (and (= (forward-line -1) 0) (<= start (point)))
1120 (if (not (looking-at 1120 (if (not (looking-at
1121 (concat diff-hunk-header-re-unified 1121 (concat diff-hunk-header-re-unified
1122 "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$" 1122 "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$"
1123 "\\|--- .+\n\\+\\+\\+ "))) 1123 "\\|--- .+\n\\+\\+\\+ ")))
1124 (case (char-after) 1124 (case (char-after)
1125 (?\s (incf space)) 1125 (?\s (incf space))
1126 (?+ (incf plus)) 1126 (?+ (incf plus))
1127 (?- (incf minus)) 1127 (?- (incf minus))
1128 (?! (incf bang)) 1128 (?! (incf bang))
1129 ((?\\ ?#) nil) 1129 ((?\\ ?#) nil)
1130 (t (setq space 0 plus 0 minus 0 bang 0))) 1130 (t (setq space 0 plus 0 minus 0 bang 0)))
1131 (cond 1131 (cond
1132 ((looking-at diff-hunk-header-re-unified) 1132 ((looking-at diff-hunk-header-re-unified)
1133 (let* ((old1 (match-string 2)) 1133 (let* ((old1 (match-string 2))
1134 (old2 (match-string 4)) 1134 (old2 (match-string 4))
1135 (new1 (number-to-string (+ space minus))) 1135 (new1 (number-to-string (+ space minus)))
1136 (new2 (number-to-string (+ space plus)))) 1136 (new2 (number-to-string (+ space plus))))
1137 (if old2 1137 (if old2
1138 (unless (string= new2 old2) (replace-match new2 t t nil 4)) 1138 (unless (string= new2 old2) (replace-match new2 t t nil 4))
1139 (goto-char (match-end 3)) 1139 (goto-char (match-end 3))
1140 (insert "," new2)) 1140 (insert "," new2))
1141 (if old1 1141 (if old1
1142 (unless (string= new1 old1) (replace-match new1 t t nil 2)) 1142 (unless (string= new1 old1) (replace-match new1 t t nil 2))
1143 (goto-char (match-end 1)) 1143 (goto-char (match-end 1))
1144 (insert "," new1)))) 1144 (insert "," new1))))
1145 ((looking-at diff-context-mid-hunk-header-re) 1145 ((looking-at diff-context-mid-hunk-header-re)
1146 (when (> (+ space bang plus) 0) 1146 (when (> (+ space bang plus) 0)
1147 (let* ((old1 (match-string 1)) 1147 (let* ((old1 (match-string 1))
1148 (old2 (match-string 2)) 1148 (old2 (match-string 2))
1149 (new (number-to-string 1149 (new (number-to-string
1150 (+ space bang plus -1 (string-to-number old1))))) 1150 (+ space bang plus -1 (string-to-number old1)))))
1151 (unless (string= new old2) (replace-match new t t nil 2))))) 1151 (unless (string= new old2) (replace-match new t t nil 2)))))
1152 ((looking-at "\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]*\\) \\*\\*\\*\\*$") 1152 ((looking-at "\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]*\\) \\*\\*\\*\\*$")
1153 (when (> (+ space bang minus) 0) 1153 (when (> (+ space bang minus) 0)
1154 (let* ((old (match-string 1)) 1154 (let* ((old (match-string 1))
1155 (new (format 1155 (new (format
1156 (concat "%0" (number-to-string (length old)) "d") 1156 (concat "%0" (number-to-string (length old)) "d")
1157 (+ space bang minus -1 (string-to-number old))))) 1157 (+ space bang minus -1 (string-to-number old)))))
1158 (unless (string= new old) (replace-match new t t nil 2)))))) 1158 (unless (string= new old) (replace-match new t t nil 2))))))
1159 (setq space 0 plus 0 minus 0 bang 0))))))) 1159 (setq space 0 plus 0 minus 0 bang 0)))))))
1160 1160
1161;;;; 1161;;;;
1162;;;; Hooks 1162;;;; Hooks