emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v [EMACS_22_BASE]


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/diff-mode.el,v [EMACS_22_BASE]
Date: Fri, 25 Apr 2008 02:08:46 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Branch:         EMACS_22_BASE
Changes by:     Stefan Monnier <monnier>        08/04/25 02:08:44

Index: diff-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.99.2.14
retrieving revision 1.99.2.15
diff -u -b -r1.99.2.14 -r1.99.2.15
--- diff-mode.el        18 Mar 2008 20:49:52 -0000      1.99.2.14
+++ diff-mode.el        25 Apr 2008 02:08:43 -0000      1.99.2.15
@@ -342,7 +342,7 @@
            (replace-match "" t t)))))))
 
 (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
   `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$")
@@ -402,8 +402,8 @@
         (setq style (cdr (assq (char-after) '((?@ . unified) (?* . 
context))))))
       (goto-char (match-end 0))
       (when (and (not donttrustheader) (match-end 2))
-        (let* ((nold (string-to-number (match-string 2)))
-               (nnew (string-to-number (match-string 4)))
+        (let* ((nold (string-to-number (or (match-string 2) "1")))
+               (nnew (string-to-number (or (match-string 4) "1")))
                (endold
         (save-excursion
           (re-search-forward (if diff-valid-unified-empty-line
@@ -768,9 +768,9 @@
                (replace-match "***" t t nil 2))
            ;; we matched a hunk header
            (let ((line1 (match-string 4))
-                 (lines1 (match-string 5))
+                 (lines1 (or (match-string 5) "1"))
                  (line2 (match-string 6))
-                 (lines2 (match-string 7)))
+                 (lines2 (or (match-string 7) "1")))
              (replace-match
               (concat "***************\n*** " line1 ","
                       (number-to-string (+ (string-to-number line1)
@@ -1005,8 +1005,12 @@
                     (old2 (match-string 4))
                     (new1 (number-to-string (+ space minus)))
                     (new2 (number-to-string (+ space plus))))
+                (if old2
                (unless (string= new2 old2) (replace-match new2 t t nil 4))
-               (unless (string= new1 old1) (replace-match new1 t t nil 2))))
+                  (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]*\\) ----$")
              (when (> (+ space bang plus) 0)
                (let* ((old1 (match-string 1))
@@ -1241,8 +1245,8 @@
        ((eq (char-after) ?@)
         (if (not (looking-at diff-hunk-header-re-unified))
             (error "Unrecognized unified diff hunk header format")
-          (let ((before (string-to-number (match-string 2)))
-                (after (string-to-number (match-string 4))))
+          (let ((before (string-to-number (or (match-string 2) "1")))
+                (after (string-to-number (or (match-string 4) "1"))))
             (forward-line)
             (while
                 (case (char-after)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]