dm_g · 2022-07-19 19:04
hi everybody,
I use a file as my main "dashboard" and I would like to insert an agenda view into it. The idea is to "refresh" this buffer, remove the currently displayed agenda, compute the agenda for the day, and insert it into this buffer.
I can do lisp, but I wonder if there is something similar to what I am trying to do that might have been already implemented.
I guess ultimately I can look at the source code of org-agenda and reuse its code, but I am wondering if I would be "rediscovering the wheel"
thank you.
7890yuiop · 2022-07-19 21:15
"problematically"?
nicholas_hubbard · 2022-07-19 21:27
OP wants to know the worst possible way to do this :)
gravygrowinggreen · 2022-07-19 21:34
Probably generating a screenshot via some sort of terminal/shell call to an external program, then inserting the screenshot into the target document.
gravygrowinggreen · 2022-07-19 21:38
OP, you might be served best by modifying your desired outcome. Instead of having only one file as your dashboard, why not have your emacs start up and immediately open two buffers? One is your current dashboard, and the other is the traditional agenda buffer.
I'm not aware of any setups that directly insert the contents of the agenda into another buffer programmatically, but I think that should be feasible with elisp.
dm_g · 2022-07-19 21:40
Probably typing character by character.
sorry for the typo. Impossible to edit title now :(
but it made me laugh
dpoggio · 2022-07-19 21:54
`org-agenda-write` does the trick as `C-x C-w` ish behavior in agenda buffers. It can also write different formats, relying on the given filename extension. You could refresh your dashboard using a source agenda file filled with this function… I would rather just go to my agenda though, but it’s your dashboard.
dpoggio · 2022-07-19 21:57
`org-agenda-write` does this, just it kills the buffer after writing.
gravygrowinggreen · 2022-07-19 22:09
He could probably take a look at the code for that function, copy most of it into a custom function, change the names, and remove the call to kill the buffer.
dpoggio · 2022-07-19 23:15
Or just call it and then insert the contents of the file into the dashboard. Less coding.
bram85 · 2022-07-20 05:49
Maybe dynamic org-ql blocks do what you're trying to achieve.
https://github.com/alphapapa/org-ql/#dynamic-block
dm_g · 2022-07-20 20:20
Thanks! this was what I was looking for. I was able to quickly write a function that scans my agenda files and extract the NEXT item. It might be useful to others:
(defun dmg-insert-next-agenda-actions ()
(interactive)
(insert
(apply 'concat
(mapcar (lambda (entry) (concat "- " entry "\n") )
(org-ql-select (org-agenda-files)
'(todo "NEXT")
:action (lambda () (concat "[[file:" buffer-file-name "][" (org-get-heading) "]]")))
))))