mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-13 01:20:28 -08:00
(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.
This commit is contained in:
parent
928ad6435e
commit
43392d1263
2 changed files with 19 additions and 9 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2008-04-25 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||||
|
|
||||||
|
* diff-mode.el (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.
|
||||||
|
|
||||||
2008-04-23 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
|
2008-04-23 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
|
||||||
|
|
||||||
* term/mac-win.el (mac-ts-active-input-buf): Move defvar to macterm.c.
|
* term/mac-win.el (mac-ts-active-input-buf): Move defvar to macterm.c.
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ when editing big diffs)."
|
||||||
(replace-match "" t t)))))))
|
(replace-match "" t t)))))))
|
||||||
|
|
||||||
(defconst diff-hunk-header-re-unified
|
(defconst diff-hunk-header-re-unified
|
||||||
"^@@ -\\([0-9]+\\),\\([0-9]+\\) \\+\\([0-9]+\\),\\([0-9]+\\) @@")
|
"^@@ -\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\+\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? @@")
|
||||||
|
|
||||||
(defvar diff-font-lock-keywords
|
(defvar diff-font-lock-keywords
|
||||||
`((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$")
|
`((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$")
|
||||||
|
|
@ -402,8 +402,8 @@ See http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html")
|
||||||
(setq style (cdr (assq (char-after) '((?@ . unified) (?* . context))))))
|
(setq style (cdr (assq (char-after) '((?@ . unified) (?* . context))))))
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(when (and (not donttrustheader) (match-end 2))
|
(when (and (not donttrustheader) (match-end 2))
|
||||||
(let* ((nold (string-to-number (match-string 2)))
|
(let* ((nold (string-to-number (or (match-string 2) "1")))
|
||||||
(nnew (string-to-number (match-string 4)))
|
(nnew (string-to-number (or (match-string 4) "1")))
|
||||||
(endold
|
(endold
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(re-search-forward (if diff-valid-unified-empty-line
|
(re-search-forward (if diff-valid-unified-empty-line
|
||||||
|
|
@ -768,9 +768,9 @@ else cover the whole buffer."
|
||||||
(replace-match "***" t t nil 2))
|
(replace-match "***" t t nil 2))
|
||||||
;; we matched a hunk header
|
;; we matched a hunk header
|
||||||
(let ((line1 (match-string 4))
|
(let ((line1 (match-string 4))
|
||||||
(lines1 (match-string 5))
|
(lines1 (or (match-string 5) "1"))
|
||||||
(line2 (match-string 6))
|
(line2 (match-string 6))
|
||||||
(lines2 (match-string 7)))
|
(lines2 (or (match-string 7) "1")))
|
||||||
(replace-match
|
(replace-match
|
||||||
(concat "***************\n*** " line1 ","
|
(concat "***************\n*** " line1 ","
|
||||||
(number-to-string (+ (string-to-number line1)
|
(number-to-string (+ (string-to-number line1)
|
||||||
|
|
@ -1005,8 +1005,12 @@ else cover the whole buffer."
|
||||||
(old2 (match-string 4))
|
(old2 (match-string 4))
|
||||||
(new1 (number-to-string (+ space minus)))
|
(new1 (number-to-string (+ space minus)))
|
||||||
(new2 (number-to-string (+ space plus))))
|
(new2 (number-to-string (+ space plus))))
|
||||||
(unless (string= new2 old2) (replace-match new2 t t nil 4))
|
(if old2
|
||||||
(unless (string= new1 old1) (replace-match new1 t t nil 2))))
|
(unless (string= new2 old2) (replace-match new2 t t nil 4))
|
||||||
|
(goto-char (match-end 4)) (insert "," new2))
|
||||||
|
(if old1
|
||||||
|
(unless (string= new1 old1) (replace-match new1 t t nil 2))
|
||||||
|
(goto-char (match-end 2)) (insert "," new1))))
|
||||||
((looking-at "--- \\([0-9]+\\),\\([0-9]*\\) ----$")
|
((looking-at "--- \\([0-9]+\\),\\([0-9]*\\) ----$")
|
||||||
(when (> (+ space bang plus) 0)
|
(when (> (+ space bang plus) 0)
|
||||||
(let* ((old1 (match-string 1))
|
(let* ((old1 (match-string 1))
|
||||||
|
|
@ -1241,8 +1245,8 @@ Only works for unified diffs."
|
||||||
((eq (char-after) ?@)
|
((eq (char-after) ?@)
|
||||||
(if (not (looking-at diff-hunk-header-re-unified))
|
(if (not (looking-at diff-hunk-header-re-unified))
|
||||||
(error "Unrecognized unified diff hunk header format")
|
(error "Unrecognized unified diff hunk header format")
|
||||||
(let ((before (string-to-number (match-string 2)))
|
(let ((before (string-to-number (or (match-string 2) "1")))
|
||||||
(after (string-to-number (match-string 4))))
|
(after (string-to-number (or (match-string 4) "1"))))
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(while
|
(while
|
||||||
(case (char-after)
|
(case (char-after)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue