emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 5667bc6 16/57: Ensure input files to diff end in newline


From: Justin Burkett
Subject: [elpa] master 5667bc6 16/57: Ensure input files to diff end in newline
Date: Tue, 3 Nov 2020 14:32:19 -0500 (EST)

branch: master
commit 5667bc6204086f129292122e6b1b08e9a93906a1
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>

    Ensure input files to diff end in newline
---
 vdiff.el | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/vdiff.el b/vdiff.el
index 69bde38..0e71a38 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -522,12 +522,27 @@ POST-REFRESH-FUNCTION is called when the process 
finishes."
            (proc (get-buffer-process proc-buf)))
       (setq vdiff--last-command cmd)
       (with-current-buffer (car buffers)
-        (write-region nil nil tmp-a nil 'quietly))
+        (write-region nil nil tmp-a nil 'quietly)
+        ;; ensure tmp file ends in newline
+        (save-excursion
+          (goto-char (point-max))
+          (unless (looking-at-p "\n")
+            (write-region "\n" nil tmp-a t 'quietly))))
       (with-current-buffer (cadr buffers)
-        (write-region nil nil tmp-b nil 'quietly))
+        (write-region nil nil tmp-b nil 'quietly)
+        ;; ensure tmp file ends in newline
+        (save-excursion
+          (goto-char (point-max))
+          (unless (looking-at-p "\n")
+            (write-region "\n" nil tmp-b t 'quietly))))
       (when vdiff-3way-mode
         (with-current-buffer (nth 2 buffers)
-          (write-region nil nil tmp-c nil 'quietly)))
+          (write-region nil nil tmp-c nil 'quietly)
+          ;; ensure tmp file ends in newline
+          (save-excursion
+            (goto-char (point-max))
+            (unless (looking-at-p "\n")
+              (write-region "\n" nil tmp-c t 'quietly)))))
       (when proc
         (kill-process proc))
       (with-current-buffer (get-buffer-create proc-buf)



reply via email to

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