mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
ox-icalendar: release buffers less aggressively
* lisp/ox-icalendar.el (org-icalendar--combine-files): Release only newly created buffers. Reported-by: Michaël Cadilhac <michael@cadilhac.name> <http://lists.gnu.org/archive/html/emacs-orgmode/2017-08/msg00691.html>
This commit is contained in:
parent
23eba90e26
commit
ab6f43fcac
|
@ -928,43 +928,46 @@ This function assumes major mode for current buffer is
|
|||
(defun org-icalendar--combine-files (&rest files)
|
||||
"Combine entries from multiple files into an iCalendar file.
|
||||
FILES is a list of files to build the calendar from."
|
||||
(org-agenda-prepare-buffers files)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(with-temp-file org-icalendar-combined-agenda-file
|
||||
(insert
|
||||
(org-icalendar--vcalendar
|
||||
;; Name.
|
||||
org-icalendar-combined-name
|
||||
;; Owner.
|
||||
user-full-name
|
||||
;; Timezone.
|
||||
(or (org-string-nw-p org-icalendar-timezone)
|
||||
(cadr (current-time-zone)))
|
||||
;; Description.
|
||||
org-icalendar-combined-description
|
||||
;; Contents.
|
||||
(concat
|
||||
;; Agenda contents.
|
||||
(mapconcat
|
||||
(lambda (file)
|
||||
(catch 'nextfile
|
||||
(org-check-agenda-file file)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
;; Create ID if necessary.
|
||||
(when org-icalendar-store-UID
|
||||
(org-icalendar-create-uid file t))
|
||||
(org-export-as
|
||||
'icalendar nil nil t
|
||||
'(:ascii-charset utf-8 :ascii-links-to-notes nil)))))
|
||||
files "")
|
||||
;; BBDB anniversaries.
|
||||
(when (and org-icalendar-include-bbdb-anniversaries
|
||||
(require 'org-bbdb nil t))
|
||||
(with-output-to-string (org-bbdb-anniv-export-ical)))))))
|
||||
(run-hook-with-args 'org-icalendar-after-save-hook
|
||||
org-icalendar-combined-agenda-file))
|
||||
(org-release-buffers org-agenda-new-buffers)))
|
||||
;; At the end of the process, all buffers related to FILES are going
|
||||
;; to be killed. Make sure to only kill the ones opened in the
|
||||
;; process.
|
||||
(let ((org-agenda-new-buffers nil))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(with-temp-file org-icalendar-combined-agenda-file
|
||||
(insert
|
||||
(org-icalendar--vcalendar
|
||||
;; Name.
|
||||
org-icalendar-combined-name
|
||||
;; Owner.
|
||||
user-full-name
|
||||
;; Timezone.
|
||||
(or (org-string-nw-p org-icalendar-timezone)
|
||||
(cadr (current-time-zone)))
|
||||
;; Description.
|
||||
org-icalendar-combined-description
|
||||
;; Contents.
|
||||
(concat
|
||||
;; Agenda contents.
|
||||
(mapconcat
|
||||
(lambda (file)
|
||||
(catch 'nextfile
|
||||
(org-check-agenda-file file)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
;; Create ID if necessary.
|
||||
(when org-icalendar-store-UID
|
||||
(org-icalendar-create-uid file t))
|
||||
(org-export-as
|
||||
'icalendar nil nil t
|
||||
'(:ascii-charset utf-8 :ascii-links-to-notes nil)))))
|
||||
files "")
|
||||
;; BBDB anniversaries.
|
||||
(when (and org-icalendar-include-bbdb-anniversaries
|
||||
(require 'org-bbdb nil t))
|
||||
(with-output-to-string (org-bbdb-anniv-export-ical)))))))
|
||||
(run-hook-with-args 'org-icalendar-after-save-hook
|
||||
org-icalendar-combined-agenda-file))
|
||||
(org-release-buffers org-agenda-new-buffers))))
|
||||
|
||||
|
||||
(provide 'ox-icalendar)
|
||||
|
|
Loading…
Reference in a new issue