bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#37395: [PATCH] diff-mode.el: take into account patch separators


From: Konstantin Kharlamov
Subject: bug#37395: [PATCH] diff-mode.el: take into account patch separators
Date: Fri, 13 Sep 2019 00:34:45 +0300

* lisp/vc/diff-mode.el (diff-goto-line-before-patch-separator): an
inline function to check if prev. line was git-format-patch separator,
in which case go there.
(diff-end-of-hunk): make use of (diff-goto-line-before-patch-separator)
---
 lisp/vc/diff-mode.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 19f9c802d4..a3e4923fb4 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -511,6 +511,14 @@ diff-hunk-style
     (goto-char (match-end 0)))
   style)
 
+(defsubst diff-goto-line-before-patch-separator ()
+  "Go to prev. line, then if it has patch separator as produced
+by git-format-patch, stay there. Otherwise go back."
+  (previous-line)
+  (when (not (looking-at "-- "))
+      (next-line))
+  (point))
+
 (defun diff-end-of-hunk (&optional style donttrustheader)
   "Advance to the end of the current hunk, and return its position."
   (let (end)
@@ -561,7 +569,8 @@ diff-end-of-hunk
         (goto-char (or end (point-max)))
         (while (eq ?\n (char-before (1- (point))))
           (forward-char -1)
-          (setq end (point)))))
+          (setq end (point))))
+      (setq end (diff-goto-line-before-patch-separator)))
     ;; The return value is used by easy-mmode-define-navigation.
     (goto-char (or end (point-max)))))
 
-- 
2.23.0






reply via email to

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