[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)
> #+END_SRC
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))
))))
#+end_src
- 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."
(interactive)
(let ((file (make-temp-file "daily-agenda" nil ".txt")))
(org-agenda nil "d" nil)
(org-agenda-write file nil nil "*Org Agenda(d)*")
(kill-buffer)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(kill-line 2)
(while (re-search-forward "^ " nil t)
(replace-match "- " nil nil))
(buffer-string))))
#+end_src
Thanks again for your suggestion.
Best,
Alan
signature.asc
Description: PGP signature