aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc/diff-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/vc/diff-mode.el')
-rw-r--r--lisp/vc/diff-mode.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index e609ca9f943..7ffa115bde4 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -437,6 +437,9 @@ See http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html")
437(defconst diff-hunk-header-re 437(defconst diff-hunk-header-re
438 (concat "^\\(?:" diff-hunk-header-re-unified ".*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$")) 438 (concat "^\\(?:" diff-hunk-header-re-unified ".*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$"))
439(defconst diff-file-header-re (concat "^\\(--- .+\n\\+\\+\\+ \\|\\*\\*\\* .+\n--- \\|[^-+!<>0-9@* \n]\\).+\n" (substring diff-hunk-header-re 1))) 439(defconst diff-file-header-re (concat "^\\(--- .+\n\\+\\+\\+ \\|\\*\\*\\* .+\n--- \\|[^-+!<>0-9@* \n]\\).+\n" (substring diff-hunk-header-re 1)))
440
441(defconst diff-separator-re "^--+ ?$")
442
440(defvar diff-narrowed-to nil) 443(defvar diff-narrowed-to nil)
441 444
442(defun diff-hunk-style (&optional style) 445(defun diff-hunk-style (&optional style)
@@ -1537,15 +1540,20 @@ Only works for unified diffs."
1537 (pcase (char-after) 1540 (pcase (char-after)
1538 (?\s (cl-decf before) (cl-decf after) t) 1541 (?\s (cl-decf before) (cl-decf after) t)
1539 (?- 1542 (?-
1540 (if (and (looking-at diff-file-header-re) 1543 (cond
1541 (zerop before) (zerop after)) 1544 ((and (looking-at diff-separator-re)
1542 ;; No need to query: this is a case where two patches 1545 (zerop before) (zerop after))
1543 ;; are concatenated and only counting the lines will 1546 nil)
1544 ;; give the right result. Let's just add an empty 1547 ((and (looking-at diff-file-header-re)
1545 ;; line so that our code which doesn't count lines 1548 (zerop before) (zerop after))
1546 ;; will not get confused. 1549 ;; No need to query: this is a case where two patches
1547 (progn (save-excursion (insert "\n")) nil) 1550 ;; are concatenated and only counting the lines will
1548 (cl-decf before) t)) 1551 ;; give the right result. Let's just add an empty
1552 ;; line so that our code which doesn't count lines
1553 ;; will not get confused.
1554 (save-excursion (insert "\n")) nil)
1555 (t
1556 (cl-decf before) t)))
1549 (?+ (cl-decf after) t) 1557 (?+ (cl-decf after) t)
1550 (_ 1558 (_
1551 (cond 1559 (cond