Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is it possible to fetch events from remote calendar and put them inside a specific heading in the destination file? #229

Open
gusgustavsohn opened this issue Mar 2, 2023 · 1 comment

Comments

@gusgustavsohn
Copy link

Let me begin by saying that Org-gcal is working fine for me, it is indeed a great tool. Thanks to everyone involved in its development and maintenance!

Now to the point of my question. I've noticed that the file that is the destination of the org-gcal-fetch-command could quickly get messy as all entries in my google calendar are fetched and appended to that file as level 1 headings.

My question is: could it be possible to tell org-gcal to put all entries from a given calendar inside a specific heading on the destination file set by org-gcal-fetch-file-alist? If it is indeed possible, I would very much appreciate your help in telling me how to achieve this. I've read the README but I couldn't find any info on this.

Thanks in advance for all your help.

@telotortium
Copy link
Collaborator

Hi @gusgustavsohn currently that is not supported directly, although I could consider it as a feature request. Instead, you could write a hook in org-gcal-after-update-entry-functions that moves the entry if it has just been fetched. I don't have time right now to provide a complete example, but here's an example of how org-gcal-after-update-entry-functions is used - the update-mode argument is set to 'newly-fetched for newly-fetched entries. Then you could use org-refile to move the tree, although you'll have to look up how to construct the rfloc argument to org-refile - shouldn't be too hard.

  (defun my-org-gcal-default-todo-meeting (_calendar-id event _update-mode)
    "Set all events with no TODO heading to be MEETING by default.
Applies only for files in ‘org-gcal-fetch-file-alist’."
    (when-let* ((title (plist-get event :summary))
                ((member (abbreviate-file-name buffer-file-name)
                         (mapcar #'cdr org-gcal-fetch-file-alist)))
                ((string= "" (org-get-todo-state)))
                ((not (string= "transparent"
                               (org-entry-get (point) "TRANSPARENCY")))))
      (let ((org-inhibit-logging t))
        (org-todo "MEETING"))))
  (add-hook 'org-gcal-after-update-entry-functions
            #'my-org-gcal-default-todo-meeting)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants