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

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

[elpa] externals/excorporate 30cc0bd 63/93: Excorporate: Add appointment


From: Stefan Monnier
Subject: [elpa] externals/excorporate 30cc0bd 63/93: Excorporate: Add appointment deletion in Org buffer
Date: Sun, 29 Nov 2020 15:43:10 -0500 (EST)

branch: externals/excorporate
commit 30cc0bdccc1eb2ad8af09d23d9215540e1f54d19
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>

    Excorporate: Add appointment deletion in Org buffer
    
    * packages/excorporate/excorporate-org.el
    (exco-org--connection-identifier-at-point): New function.
    (exco-org-delete-appointment): Likewise.
---
 excorporate-org.el | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/excorporate-org.el b/excorporate-org.el
index 8f9cec4..4fab6b3 100644
--- a/excorporate-org.el
+++ b/excorporate-org.el
@@ -33,6 +33,45 @@
 (defvar exco-org--temporary-buffers '()
   "A list of per-connection result buffers.")
 
+(defun exco-org--connection-identifier-at-point ()
+  "Return the connection identifier associated with point."
+  (let* ((calendar-headline
+         (save-excursion (org-up-heading-safe) (org-element-at-point)))
+        (headline (org-element-property :raw-value calendar-headline)))
+    (string-match "Calendar (\\(.*\\))$" headline)
+    (car (read-from-string (match-string 1 headline)))))
+
+(defun exco-org-delete-appointment ()
+  "Delete the appointment at point."
+  (interactive)
+  (let ((identifier (exco-org--connection-identifier-at-point))
+       (item-identifier
+        (org-entry-get (car (org-get-property-block)) "Identifier")))
+    (when item-identifier
+      (exco-calendar-item-appointment-delete
+       identifier
+       (car (read-from-string item-identifier))
+       (lambda (identifier response)
+        (let ((response-code
+               (exco-extract-value '(ResponseMessages
+                                     DeleteItemResponseMessage
+                                     ResponseCode)
+                                   response)))
+          (if (equal response-code "NoError")
+              (with-current-buffer (get-buffer-create
+                                    excorporate-org-buffer-name)
+                (save-excursion
+                  (org-back-to-heading)
+                  (let* ((inhibit-read-only t)
+                         (element (org-element-at-point))
+                         (begin (org-element-property :begin element))
+                         (end (org-element-property :end element)))
+                    (kill-region begin end)
+                    (message
+                     "excorporate-org: Successfully deleted appointment"))))
+            (message "excorporate-org: Failed to delete appointment: %S"
+                     response-code))))))))
+
 (defun exco-org-initialize-buffer ()
   "Add initial text to the destination buffer."
   (setq exco-org--temporary-buffers '())



reply via email to

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