[Top][All Lists]

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

Re: programatically generate an agenda

From: Alan Schmitt
Subject: Re: programatically generate an agenda
Date: Mon, 15 Feb 2021 18:45:49 +0100

On 2021-02-14 12:12, John Kitchin <jkitchin@andrew.cmu.edu> writes:

> If it is possible to set up what you want in an entry in
> org-agenda-custom-commands, then you can call it in a program like
> #+BEGIN_SRC emacs-lisp
> (org-agenda nil "w" nil)

This is what I ended up doing.

- set up an agenda view with only the current day and the events:

#+begin_src emacs-lisp
  ("d" "Daily schedule"
   ((agenda ""
            ((org-agenda-span 'day)
             (org-agenda-use-time-grid nil)
             (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled))

- use it with org-agenda write, massaging the results a little

#+begin_src emacs-lisp
(defun as/get-daily-agenda ()
  "Return the agenda for the day as a string."
  (let ((file (make-temp-file "daily-agenda" nil ".txt")))
    (org-agenda nil "d" nil)
    (org-agenda-write file nil nil "*Org Agenda(d)*")
      (insert-file-contents file)
      (goto-char (point-min))
      (kill-line 2)
      (while (re-search-forward "^  " nil t)
        (replace-match "- " nil nil))

Thanks again for your suggestion.



Attachment: signature.asc
Description: PGP signature

reply via email to

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