[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/excorporate 44e056d 43/93: excorporate-org: Support mul
From: |
Stefan Monnier |
Subject: |
[elpa] externals/excorporate 44e056d 43/93: excorporate-org: Support multiple calendars |
Date: |
Sun, 29 Nov 2020 15:43:05 -0500 (EST) |
branch: externals/excorporate
commit 44e056df63ca0ef3a577b34db4a1ae48d5767070
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
excorporate-org: Support multiple calendars
* packages/excorporate/excorporate-org.el
(exco-org--temporary-buffers): New variable.
(exco-org-initialize-buffer): Clear exco-org--temporary-buffers.
Change 1 to point-min call.
(exco-org--identifier-buffer): New function.
(exco-org-insert-headline): Insert into a temporary buffer instead
of main results buffer.
(exco-org-insert-meetings): Likewise.
(exco-org-finalize-buffer): Insert results from temporary buffers
then kill them and clear exco-org--temporary-buffers.
---
excorporate-org.el | 53 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/excorporate-org.el b/excorporate-org.el
index a17d060..649573b 100644
--- a/excorporate-org.el
+++ b/excorporate-org.el
@@ -20,7 +20,7 @@
;;; Commentary:
-;; Use the Org Mode to display daily meetings.
+;; Use Org Mode to display daily meetings.
;;; Code:
@@ -30,8 +30,12 @@
(defvar excorporate-org-buffer-name "*Excorporate*"
"The buffer into which Org Mode output is inserted.")
+(defvar exco-org--temporary-buffers '()
+ "A list of per-connection result buffers.")
+
(defun exco-org-initialize-buffer ()
"Add initial text to the destination buffer."
+ (setq exco-org--temporary-buffers '())
(with-current-buffer (get-buffer-create excorporate-org-buffer-name)
(setq buffer-read-only t)
;; Some Org mode configurations need `buffer-file-name' to be
@@ -47,7 +51,7 @@
(display-buffer (current-buffer))
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
- (goto-char 1)
+ (goto-char (point-min))
(insert "# Updated...\n"))))
(defun exco-org-format-headline (identifier)
@@ -77,13 +81,21 @@ by `current-time'."
(dolist (invitee invitees)
(insert (format " + %s\n" invitee))))
+(defun exco-org--identifier-buffer (identifier)
+ "Return a hidden buffer with a name based on IDENTIFIER."
+ (get-buffer-create
+ (format " *exco-org-%S*" identifier)))
+
(defun exco-org-insert-headline (identifier month day year)
"Insert Org headline for IDENTIFIER on date MONTH DAY YEAR."
- (with-current-buffer (get-buffer-create excorporate-org-buffer-name)
- (let ((inhibit-read-only t))
- (insert (exco-org-format-headline identifier))
- (org-insert-time-stamp (encode-time 0 0 0 day month year)
- nil t " + Date " "\n"))))
+ (let ((temporary-buffer (exco-org--identifier-buffer identifier)))
+ (push temporary-buffer exco-org--temporary-buffers)
+ (with-current-buffer temporary-buffer
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point-max))
+ (insert (exco-org-format-headline identifier))
+ (org-insert-time-stamp (encode-time 0 0 0 day month year)
+ nil t " + Date " "\n")))))
(defun exco-org-insert-meeting (subject start end location
main-invitees optional-invitees)
@@ -107,17 +119,19 @@ are the requested participants."
(defun exco-org-insert-meetings (identifier response)
"Insert the connection IDENTIFIER's meetings from RESPONSE."
(with-current-buffer (get-buffer-create excorporate-org-buffer-name)
- (let ((inhibit-read-only t)
- (name-regexp (concat "\\" (exco-org-format-headline identifier))))
- (goto-char 1)
+ (let ((inhibit-read-only t))
+ (goto-char (point-min))
(end-of-line)
- (insert (format "%s..." identifier))
- (goto-char (point-max))
- (re-search-backward name-regexp nil)
- (forward-line 2)
+ (insert (format "%s..." identifier))))
+ (with-current-buffer (exco-org--identifier-buffer identifier)
+ (let ((inhibit-read-only t))
(org-insert-time-stamp (current-time) t t " + Last checked " "\n")
- (exco-calendar-item-iterate response #'exco-org-insert-meeting)
- (re-search-backward name-regexp nil)
+ (exco-calendar-item-iterate
+ response (lambda (&rest arguments)
+ (with-current-buffer (exco-org--identifier-buffer identifier)
+ (org-mode)
+ (apply #'exco-org-insert-meeting arguments))))
+ (goto-char (point-min))
(if (save-excursion (org-goto-first-child))
(org-sort-entries t ?s)
(forward-line 3)
@@ -130,8 +144,11 @@ are the requested participants."
(let ((inhibit-read-only t))
(goto-char (point-min))
(end-of-line)
- (insert "done.")
- (org-sort-entries t ?a))))
+ (insert "done.\n")
+ (dolist (result-buffer (nreverse exco-org--temporary-buffers))
+ (insert-buffer-substring result-buffer)
+ (kill-buffer result-buffer))
+ (setq exco-org--temporary-buffers '()))))
;;;###autoload
(defun exco-org-show-day (month day year)
- [elpa] externals/excorporate cd392a1 40/93: excorporate-diary: Escape literal percent signs, (continued)
- [elpa] externals/excorporate cd392a1 40/93: excorporate-diary: Escape literal percent signs, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate acbc123 22/93: excorporate.texi: Increase authentication success likelihood, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate a1ec101 26/93: excorporate.el: Require org for org-trim, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 836db8c 35/93: packages/excorporate: Bump version to 0.8.1, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 0d20739 41/93: excorporate-diary: Fix documentation string, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 6d8fa65 19/93: packages/excorporate: Acknowledge Fabio Leimgruber, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 3e13cee 24/93: excorporate-calfw.el: Rename from excorporate-calfw.el.txt, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 33ee501 31/93: packages/excorporate: Update documentation for Diary support, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 882f2e0 44/93: excorporate-diary: Suppress compilation warning, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate d0a8709 39/93: excorporate-diary: Always use diary-fancy-display, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 44e056d 43/93: excorporate-org: Support multiple calendars,
Stefan Monnier <=
- [elpa] externals/excorporate e343dc8 47/93: excorporate-diary: Fix read-only diary buffer, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 47fb189 73/93: Excorporate: Add some helper functions to Org backend, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 890266e 67/93: Excorporate: Support creating and cancelling meetings, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate c9df5e5 76/93: Excorporate: Fix some byte compiler warnings, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 5eeff27 89/93: Excorporate: Bump version to 0.9.0, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate a33cd79 91/93: Excorporate: Prompt for meeting reply messages, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 48d34df 12/93: packages/excorporate: Add NEWS file, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 618d12c 18/93: packages/excorporate: Bump version to 0.7.5, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 8279180 20/93: packages/excorporate: Bump url-http-ntlm required version to 2.0.3, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 90532e9 29/93: packages/excorporate: Support retrieving meeting details, Stefan Monnier, 2020/11/29