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
This commit is contained in:
parent
2e883b21a7
commit
351279ffae
27
lisp/org.el
27
lisp/org.el
|
@ -14567,19 +14567,20 @@ This uses the icalendar.el library."
|
||||||
(tmpfile (make-temp-name
|
(tmpfile (make-temp-name
|
||||||
(expand-file-name "orgics" tmpdir)))
|
(expand-file-name "orgics" tmpdir)))
|
||||||
buf rtn b e)
|
buf rtn b e)
|
||||||
(with-current-buffer frombuf
|
(unwind-protect
|
||||||
(icalendar-export-region (point-min) (point-max) tmpfile)
|
(with-current-buffer frombuf
|
||||||
(setq buf (find-buffer-visiting tmpfile))
|
(icalendar-export-region (point-min) (point-max) tmpfile)
|
||||||
(set-buffer buf)
|
(setq buf (find-buffer-visiting tmpfile))
|
||||||
(goto-char (point-min))
|
(set-buffer buf)
|
||||||
(when (re-search-forward "^BEGIN:VEVENT" nil t)
|
(goto-char (point-min))
|
||||||
(setq b (match-beginning 0)))
|
(when (re-search-forward "^BEGIN:VEVENT" nil t)
|
||||||
(goto-char (point-max))
|
(setq b (match-beginning 0)))
|
||||||
(when (re-search-backward "^END:VEVENT" nil t)
|
(goto-char (point-max))
|
||||||
(setq e (match-end 0)))
|
(when (re-search-backward "^END:VEVENT" nil t)
|
||||||
(setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
|
(setq e (match-end 0)))
|
||||||
(kill-buffer buf)
|
(setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
|
||||||
(delete-file tmpfile)
|
(when (and buf (buffer-live-p buf)) (kill-buffer buf))
|
||||||
|
(delete-file tmpfile))
|
||||||
rtn))
|
rtn))
|
||||||
|
|
||||||
(defun org-closest-date (start current prefer)
|
(defun org-closest-date (start current prefer)
|
||||||
|
|
Loading…
Reference in New Issue