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

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

[elpa] externals/rec-mode d505c30 61/98: rec-mode: visiting an empty fil


From: Stefan Monnier
Subject: [elpa] externals/rec-mode d505c30 61/98: rec-mode: visiting an empty file works again.
Date: Thu, 12 Nov 2020 13:18:41 -0500 (EST)

branch: externals/rec-mode
commit d505c30efedb5e7265367bc84812314d89842ba2
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>

    rec-mode: visiting an empty file works again.
---
 etc/rec-mode.el | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 08003bc..1104a31 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -598,11 +598,22 @@ The current record is the record where the pointer is"
 ;; These functions perform the management of the collection of records
 ;; in the buffer.
 
+(defun rec-buffer-valid-p ()
+  "Determine whether the current buffer contains valid rec data."
+  (equal (call-process-region (point-min) (point-max)
+                              rec-recinf
+                              nil ; delete
+                              nil ; discard output
+                              nil ; display
+                              ) 0))
+
 (defun rec-update-buffer-descriptors-and-check (&optional dont-go-fundamental)
   "Update buffer descriptors and switch to fundamental mode if
 there is a parse error."
-  (if (rec-update-buffer-descriptors)
-      t
+  (if (rec-buffer-valid-p)
+      (progn
+        (rec-update-buffer-descriptors)
+        t)
     (unless dont-go-fundamental
       (fundamental-mode))
     (let* ((cur-buf (current-buffer))



reply via email to

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