* programatically generate an agenda
@ 2021-02-13 18:05 Alan Schmitt
2021-02-14 17:12 ` John Kitchin
0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2021-02-13 18:05 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
Hello,
In my quest/endeavor/struggle to generate an org file for what I want to
do during the day, I’m trying to leverage the power of org-agenda (that
does a lot of what I want to do) to create an org file. I learned of
org-agenda-write, which I could use to write to file what I want then
include it in my org file, but for that I need to create the correct
org-agenda buffer. What is the elisp way of doing it?
I tried using org-agenda-list, but it only seems to restore the current
agenda view. For instance, (org-agenda-list nil nil 1) generates an
agenda for the week (which is my default), even though I pass a SPAN
argument of 1. I also don’t know how to set the org-agenda-skip steps
before calling that function…
Thanks a lot for any suggestion on how to do this.
Best,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: programatically generate an agenda
2021-02-13 18:05 programatically generate an agenda Alan Schmitt
@ 2021-02-14 17:12 ` John Kitchin
2021-02-15 13:26 ` Alan Schmitt
2021-02-15 17:45 ` Alan Schmitt
0 siblings, 2 replies; 4+ messages in thread
From: John Kitchin @ 2021-02-14 17:12 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
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
In that snippet, I have the key in an org-agenda-custom-commands set to
"w".
that generates an agenda buffer for me, which I assume you can then use
the org-agenda-write command on.
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> In my quest/endeavor/struggle to generate an org file for what I want to
> do during the day, I’m trying to leverage the power of org-agenda (that
> does a lot of what I want to do) to create an org file. I learned of
> org-agenda-write, which I could use to write to file what I want then
> include it in my org file, but for that I need to create the correct
> org-agenda buffer. What is the elisp way of doing it?
>
> I tried using org-agenda-list, but it only seems to restore the current
> agenda view. For instance, (org-agenda-list nil nil 1) generates an
> agenda for the week (which is my default), even though I pass a SPAN
> argument of 1. I also don’t know how to set the org-agenda-skip steps
> before calling that function…
>
> Thanks a lot for any suggestion on how to do this.
>
> Best,
>
> Alan
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: programatically generate an agenda
2021-02-14 17:12 ` John Kitchin
@ 2021-02-15 13:26 ` Alan Schmitt
2021-02-15 17:45 ` Alan Schmitt
1 sibling, 0 replies; 4+ messages in thread
From: Alan Schmitt @ 2021-02-15 13:26 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 522 bytes --]
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
>
> In that snippet, I have the key in an org-agenda-custom-commands set to
> "w".
>
> that generates an agenda buffer for me, which I assume you can then use
> the org-agenda-write command on.
Thank you for the suggestion, this is most useful.
Best,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: programatically generate an agenda
2021-02-14 17:12 ` John Kitchin
2021-02-15 13:26 ` Alan Schmitt
@ 2021-02-15 17:45 ` Alan Schmitt
1 sibling, 0 replies; 4+ messages in thread
From: Alan Schmitt @ 2021-02-15 17:45 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1225 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-15 17:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-13 18:05 programatically generate an agenda Alan Schmitt
2021-02-14 17:12 ` John Kitchin
2021-02-15 13:26 ` Alan Schmitt
2021-02-15 17:45 ` Alan Schmitt
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).