emacs-orgmode
[Top][All Lists]
Advanced

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

[SOLVED] Re: [QUESTION] How to generate org-agenda view for clocked task


From: Christopher M. Miles
Subject: [SOLVED] Re: [QUESTION] How to generate org-agenda view for clocked tasks and logs etc which are sorted by timestamps?
Date: Fri, 05 Nov 2021 22:36:33 +0800
User-agent: mu4e 1.7.0; emacs 28.0.60

Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> In the source code comment "FIXME" org-agenda always in frontend and popup 
>> buffer. I can't generate
>> org-agenda in background then get the buffer content.
>>
>> Does anybody knows some tricky method for my code?
>
> Maybe wrap agenda call into save-window-excursion?

Thanks for your helpful hint. I finally got a solution:

#+begin_src emacs-lisp
(add-to-list
 'org-agenda-custom-commands
 '("c" "Tody [c]locked tasks."
   ((agenda ""
            ((org-agenda-ndays 1)
             (org-agenda-span-1)
             (org-agenda-use-time-grid t)
             (org-agenda-include-diary nil)
             (org-agenda-show-log (quote clockcheck))
             (org-agenda-clockreport t))))))

(let* ((org-agenda-sticky t)
       ;; Run it in background instead of switch to agenda buffer with 
`save-window-excursion'.
       (_ (save-window-excursion (org-agenda nil "c")))
       (origin-buffer (current-buffer))
       (origin-buffer-point (point))
       (agenda-buffer (with-current-buffer "*Org Agenda(c)*"
                        (buffer-substring (point-min) (point-max)))))
  (print agenda-buffer))
#+end_src

#+RESULTS[(2021-11-05 21:27:30) 96280334f709aece114a7bf308c1ff4762eff1bf]:
#+begin_example
Day-agenda (W44):
Friday      5 November 2021
                  8:00am......  ----------------
                 10:00am......  ----------------
                 12:00pm......  ----------------
   Feature        1:00pm- 1:04pm  Clocked:   (0:04) FEATURE [#A] create an 
org-agenda like view mode for clocking,note logs sorted by timestamps
   Feature        1:06pm- 1:38pm  Clocked:   (0:32) FEATURE [#A] create an 
org-agenda like view mode for clocking,note logs sorted by timestamps
                  2:00pm......  ----------------
                  4:00pm......  ----------------
                  6:00pm......  ----------------
                  6:28pm......  now - - - - - - - - - - - - - - - - - - - - - - 
- - -
                  8:00pm......  ----------------
#+end_example

So that I can record those into into Diary.


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature


reply via email to

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