alphapapa / org-sidebar

A helpful sidebar for Org mode
GNU General Public License v3.0
527 stars 16 forks source link

How to get the agenda from all the agenda files? #4

Closed vikasrawal closed 5 years ago

vikasrawal commented 5 years ago

Can I use this to see agenda from all my agenda files in the sidebar? Or does it only work with the current buffer?

alphapapa commented 5 years ago

The two built-in sidebars use the current buffer, but you can write a sidebar function to display whatever items you want. The API for this is still awkward and I hope to improve it. In the meantime, try this:

(org-sidebar-def-item-buffer-fn all-agenda-files
  "all agenda-file items"
  (cl-flet ((date-header (item)
                         (propertize (org-timestamp-format (or (org-element-property :scheduled item)
                                                               (org-element-property :deadline item))
                                                           org-sidebar-date-format)
                                     'face '(:inherit variable-pitch :weight bold))))
    (let ((items (org-ql (org-agenda-files)
                   (and (not (done))
                        (or (todo "TODAY" "IMPORTANT")
                            (deadline <=)
                            (date = today)
                            (and (scheduled <=)
                                 (tags "personal"))
                            (and (todo)
                                 (tags "now"))))
                   :sort (date todo priority))))
      (if group
          (-group-by #'date-header items)
        items))))

(org-sidebar :buffer-fns '(org-sidebar--all-agenda-files-buffer)
             :super-groups t)

You can adjust the query in the org-ql block as desired. That one is similar to a standard Org Agenda with some customizations.

vikasrawal commented 5 years ago

This does not seem to work. I turned out the debugger and it gave an error as follows:

Debugger entered--Lisp error: (error "Unknown date-element type: active-range") signal(error ("Unknown date-element type: active-range")) error("Unknown date-element type: %s" active-range) org-ql--date-type-p(:scheduled <= nil) scheduled(<=)

f(compiled-function () #<bytecode 0x1c2e87d>)()

.... .....

alphapapa commented 5 years ago

What version of Emacs and Org are you using?

vikasrawal commented 5 years ago

GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.8) of 2019-04-12 Org mode version 9.2.4 (9.2.4-10-g3b006f-elpaplus @ /home/vikas/.emacs.d/elpa/org-plus-contrib-20190715/)

On Wed, 17 Jul 2019 at 22:08, alphapapa notifications@github.com wrote:

What version of Emacs and Org are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alphapapa/org-sidebar/issues/4?email_source=notifications&email_token=AADVDTBAOFR74P577PCF5PDP75DI7A5CNFSM4IEK2TRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2E7WRY#issuecomment-512359239, or mute the thread https://github.com/notifications/unsubscribe-auth/AADVDTHSWQ3BB4JZ3RD4H4LP75DI7ANCNFSM4IEK2TRA .

alphapapa commented 5 years ago

That would seem to indicate that you have an entry in that Org file with a SCHEDULED: planning line that has a timestamp range rather than a single timestamp, e.g.:

* Heading
SCHEDULED: <2019-07-17 Thu 12:00>--<2019-07-18 Fri 12:00>

Can you confirm that?

If so, I don't think that is valid in Org. According to the Org manual, SCHEDULED is supposed to be used for a date on which you plan to start working on an entry.

alphapapa commented 5 years ago

If it helps, I just pushed a new commit to org-ql that gives a more detailed error message. You could upgrade org-ql and perform the same action and it will show you where the bad date range is.

vikasrawal commented 5 years ago

That would seem to indicate that you have an entry in that Org file with a

SCHEDULED: planning line that has a timestamp range rather than a single timestamp, e.g.:

  • Heading SCHEDULED: <2019-07-17 Thu 12:00>--<2019-07-18 Fri 12:00>

Can you confirm that?

Oh, yes. I am guilty of shaving made that mistake. Just check es the documentation and it is indeed as you say.

alphapapa commented 5 years ago

Okay, well, I'm not sure if that's actually a mistake. It doesn't seem to fit with what the manual says the intended use of the SCHEDULED line is, but many, many Org users don't know about that and don't use it that way. So we probably need to handle ranges there anyway.

And, in fact, org-ql was supposed to handle that, but I made a mistake and didn't implement it properly. So I'll fix that now, in org-ql, and you shouldn't have that problem anymore.

Thanks for reporting these issues. As you can tell, org-sidebar is still somewhat experimental and needs a lot of polishing. After org-ql gets published on MELPA, I'll work on that and hope to publish org-sidebar on MELPA too.

alphapapa commented 5 years ago

The fix is pushed to org-ql now. Thanks.