emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <PAXPR08MB66404DADBB7B180FDA034C5AA38E9@PAXPR08MB6640.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <87sfwag6oy.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 2447 bytes --]


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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2021-11-05 14:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04  4:16 [QUESTION] How to generate org-agenda view for clocked tasks and logs etc which are sorted by timestamps? stardiviner
2021-11-04 15:03 ` Russell Adams
2021-11-05 11:20   ` Christopher M. Miles
2021-11-05 11:53     ` Ihor Radchenko
2021-11-05 14:36       ` Christopher M. Miles [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAXPR08MB66404DADBB7B180FDA034C5AA38E9@PAXPR08MB6640.eurprd08.prod.outlook.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).