[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 351279ffae 3/3: org-diary-to-ical-string: Make sure
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 351279ffae 3/3: org-diary-to-ical-string: Make sure that temporary file/buffer is cleaned |
Date: |
Thu, 23 Feb 2023 04:58:25 -0500 (EST) |
branch: externals/org
commit 351279ffaead08398002fd29801eaad688ccf239
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-diary-to-ical-string: Make sure that temporary file/buffer is cleaned
* lisp/org.el (org-diary-to-ical-string): Clean temporary file buffer
on error.
Reported-by: Alexei Gilev <gerardomoro37@gmail.com>
Link:
https://orgmode.org/list/CAF4Fj9gUBj4Ap4noTLP3aSG4owXJ2nydxaqwT4cF5x9DcdhQmg@mail.gmail.com
---
lisp/org.el | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index cc2c09e3a9..b0a6d8ef3f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14567,19 +14567,20 @@ This uses the icalendar.el library."
(tmpfile (make-temp-name
(expand-file-name "orgics" tmpdir)))
buf rtn b e)
- (with-current-buffer frombuf
- (icalendar-export-region (point-min) (point-max) tmpfile)
- (setq buf (find-buffer-visiting tmpfile))
- (set-buffer buf)
- (goto-char (point-min))
- (when (re-search-forward "^BEGIN:VEVENT" nil t)
- (setq b (match-beginning 0)))
- (goto-char (point-max))
- (when (re-search-backward "^END:VEVENT" nil t)
- (setq e (match-end 0)))
- (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
- (kill-buffer buf)
- (delete-file tmpfile)
+ (unwind-protect
+ (with-current-buffer frombuf
+ (icalendar-export-region (point-min) (point-max) tmpfile)
+ (setq buf (find-buffer-visiting tmpfile))
+ (set-buffer buf)
+ (goto-char (point-min))
+ (when (re-search-forward "^BEGIN:VEVENT" nil t)
+ (setq b (match-beginning 0)))
+ (goto-char (point-max))
+ (when (re-search-backward "^END:VEVENT" nil t)
+ (setq e (match-end 0)))
+ (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
+ (when (and buf (buffer-live-p buf)) (kill-buffer buf))
+ (delete-file tmpfile))
rtn))
(defun org-closest-date (start current prefer)