diff options
| author | Stefan Monnier | 2008-04-25 02:08:43 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-04-25 02:08:43 +0000 |
| commit | 43392d1263d34c33a86eadf99783259bcf0e28f6 (patch) | |
| tree | df62aaa0ddad757b4b4385e0acea1d0368602f21 /lisp/diff-mode.el | |
| parent | 928ad6435e49441415684b375d4fa63aea280b0a (diff) | |
| download | emacs-43392d1263d34c33a86eadf99783259bcf0e28f6.tar.gz emacs-43392d1263d34c33a86eadf99783259bcf0e28f6.zip | |
(diff-hunk-header-re-unified): Allow elided line counts.
(diff-end-of-hunk, diff-unified->context, diff-fixup-modifs)
(diff-sanity-check-hunk): Adjust code accordingly.
Diffstat (limited to 'lisp/diff-mode.el')
| -rw-r--r-- | lisp/diff-mode.el | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index 798f5f2e4ec..ecd8abae0bf 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el | |||
| @@ -342,7 +342,7 @@ when editing big diffs)." | |||
| 342 | (replace-match "" t t))))))) | 342 | (replace-match "" t t))))))) |
| 343 | 343 | ||
| 344 | (defconst diff-hunk-header-re-unified | 344 | (defconst diff-hunk-header-re-unified |
| 345 | "^@@ -\\([0-9]+\\),\\([0-9]+\\) \\+\\([0-9]+\\),\\([0-9]+\\) @@") | 345 | "^@@ -\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\+\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? @@") |
| 346 | 346 | ||
| 347 | (defvar diff-font-lock-keywords | 347 | (defvar diff-font-lock-keywords |
| 348 | `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$") | 348 | `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$") |
| @@ -402,8 +402,8 @@ See http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html") | |||
| 402 | (setq style (cdr (assq (char-after) '((?@ . unified) (?* . context)))))) | 402 | (setq style (cdr (assq (char-after) '((?@ . unified) (?* . context)))))) |
| 403 | (goto-char (match-end 0)) | 403 | (goto-char (match-end 0)) |
| 404 | (when (and (not donttrustheader) (match-end 2)) | 404 | (when (and (not donttrustheader) (match-end 2)) |
| 405 | (let* ((nold (string-to-number (match-string 2))) | 405 | (let* ((nold (string-to-number (or (match-string 2) "1"))) |
| 406 | (nnew (string-to-number (match-string 4))) | 406 | (nnew (string-to-number (or (match-string 4) "1"))) |
| 407 | (endold | 407 | (endold |
| 408 | (save-excursion | 408 | (save-excursion |
| 409 | (re-search-forward (if diff-valid-unified-empty-line | 409 | (re-search-forward (if diff-valid-unified-empty-line |
| @@ -768,9 +768,9 @@ else cover the whole buffer." | |||
| 768 | (replace-match "***" t t nil 2)) | 768 | (replace-match "***" t t nil 2)) |
| 769 | ;; we matched a hunk header | 769 | ;; we matched a hunk header |
| 770 | (let ((line1 (match-string 4)) | 770 | (let ((line1 (match-string 4)) |
| 771 | (lines1 (match-string 5)) | 771 | (lines1 (or (match-string 5) "1")) |
| 772 | (line2 (match-string 6)) | 772 | (line2 (match-string 6)) |
| 773 | (lines2 (match-string 7))) | 773 | (lines2 (or (match-string 7) "1"))) |
| 774 | (replace-match | 774 | (replace-match |
| 775 | (concat "***************\n*** " line1 "," | 775 | (concat "***************\n*** " line1 "," |
| 776 | (number-to-string (+ (string-to-number line1) | 776 | (number-to-string (+ (string-to-number line1) |
| @@ -1005,8 +1005,12 @@ else cover the whole buffer." | |||
| 1005 | (old2 (match-string 4)) | 1005 | (old2 (match-string 4)) |
| 1006 | (new1 (number-to-string (+ space minus))) | 1006 | (new1 (number-to-string (+ space minus))) |
| 1007 | (new2 (number-to-string (+ space plus)))) | 1007 | (new2 (number-to-string (+ space plus)))) |
| 1008 | (unless (string= new2 old2) (replace-match new2 t t nil 4)) | 1008 | (if old2 |
| 1009 | (unless (string= new1 old1) (replace-match new1 t t nil 2)))) | 1009 | (unless (string= new2 old2) (replace-match new2 t t nil 4)) |
| 1010 | (goto-char (match-end 4)) (insert "," new2)) | ||
| 1011 | (if old1 | ||
| 1012 | (unless (string= new1 old1) (replace-match new1 t t nil 2)) | ||
| 1013 | (goto-char (match-end 2)) (insert "," new1)))) | ||
| 1010 | ((looking-at "--- \\([0-9]+\\),\\([0-9]*\\) ----$") | 1014 | ((looking-at "--- \\([0-9]+\\),\\([0-9]*\\) ----$") |
| 1011 | (when (> (+ space bang plus) 0) | 1015 | (when (> (+ space bang plus) 0) |
| 1012 | (let* ((old1 (match-string 1)) | 1016 | (let* ((old1 (match-string 1)) |
| @@ -1241,8 +1245,8 @@ Only works for unified diffs." | |||
| 1241 | ((eq (char-after) ?@) | 1245 | ((eq (char-after) ?@) |
| 1242 | (if (not (looking-at diff-hunk-header-re-unified)) | 1246 | (if (not (looking-at diff-hunk-header-re-unified)) |
| 1243 | (error "Unrecognized unified diff hunk header format") | 1247 | (error "Unrecognized unified diff hunk header format") |
| 1244 | (let ((before (string-to-number (match-string 2))) | 1248 | (let ((before (string-to-number (or (match-string 2) "1"))) |
| 1245 | (after (string-to-number (match-string 4)))) | 1249 | (after (string-to-number (or (match-string 4) "1")))) |
| 1246 | (forward-line) | 1250 | (forward-line) |
| 1247 | (while | 1251 | (while |
| 1248 | (case (char-after) | 1252 | (case (char-after) |