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

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

[elpa] externals/org-transclusion bdc034ce8e: intrnl: more robus with-in


From: ELPA Syncer
Subject: [elpa] externals/org-transclusion bdc034ce8e: intrnl: more robus with-inhibit-read-only
Date: Wed, 29 Dec 2021 10:02:01 -0500 (EST)

branch: externals/org-transclusion
commit bdc034ce8ea6351e8db1c30954f8b456ee85cb55
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    intrnl: more robus with-inhibit-read-only
    
    - Use of unwind-protect in the macro.
    - Also chagne set-buffer-modified to restore-buffer-p in kill-buffer
---
 org-transclusion.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/org-transclusion.el b/org-transclusion.el
index 76ac57325a..fbb932c04c 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -271,9 +271,14 @@ specific keybindings; namely:
 (defmacro org-transclusion-with-inhibit-read-only (&rest body)
   "Run BODY with `'inhibit-read-only` t."
   (declare (debug t) (indent 0))
-  `(let* ((inhibit-read-only t))
-     (progn
-           ,@body)))
+  (let ((modified (make-symbol "modified")))
+    `(let* ((,modified (buffer-modified-p))
+            (inhibit-read-only t))
+       (unwind-protect
+           (progn
+             ,@body)
+         (unless ,modified
+           (restore-buffer-modified-p nil))))))
 
 ;;;; Commands
 
@@ -747,7 +752,7 @@ turned off (removed)."
   ;; by the buffer. If a "temp" buffer, there is no file being visited.
   (when (and (org-transclusion-remove-all)
              (buffer-file-name))
-    (set-buffer-modified-p t)
+    (restore-buffer-modified-p t)
     (save-buffer)))
 
 ;;;;---------------------------------------------------------------------------



reply via email to

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