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

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

[elpa] master 69eacfe 18/57: Fix and simplify final newline detection


From: Justin Burkett
Subject: [elpa] master 69eacfe 18/57: Fix and simplify final newline detection
Date: Tue, 3 Nov 2020 14:32:20 -0500 (EST)

branch: master
commit 69eacfee0eb675ce667d46cc82f1ab679cb9b76f
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>

    Fix and simplify final newline detection
    
    Issue warning if no newline is found.
---
 vdiff.el | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/vdiff.el b/vdiff.el
index d8cf976..85a3b58 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -529,25 +529,25 @@ POST-REFRESH-FUNCTION is called when the process 
finishes."
       (with-current-buffer (car buffers)
         (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))))
+        (unless (= (char-before (point-max)) ?\n)
+          (message "vdiff: Warning %s does not end in a newline."
+                   (if buffer-file-name buffer-file-name (buffer-name)))
+          (write-region "\n" nil tmp-a t 'quietly)))
       (with-current-buffer (cadr buffers)
         (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))))
+        (unless (= (char-before (point-max)) ?\n)
+          (message "vdiff: Warning %s does not end in a newline."
+                   (if buffer-file-name buffer-file-name (buffer-name)))
+          (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)
           ;; 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)))))
+          (unless (= (char-before (point-max)) ?\n)
+            (message "vdiff: Warning %s does not end in a newline."
+                     (if buffer-file-name buffer-file-name (buffer-name)))
+            (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]