emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org agenda -- checking for invisible tasks after filtering...
@ 2019-12-15 12:52 Christian Schwarzgruber
  2020-02-03 19:29 ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Schwarzgruber @ 2019-12-15 12:52 UTC (permalink / raw)
  To: emacs-orgmode

Hey!

I'm a contributor of `org-super-agenda`
https://github.com/alphapapa/org-super-agenda, `org-super-agenda` lets you group
tasks into blocks. However, `org-super-agenda` doesn't consider filtering, which
might leave you with empty groups.

To solve that, I created a PR (https://github.com/alphapapa/org-super-agenda/pull/77)
which advices `org-agenda-filter-apply` and `org-agenda-finalize`
(https://github.com/alphapapa/org-super-agenda/pull/77/files#diff-465f82cd8ad2c42f0cebb190be6f58abR305).

Both are calling the same function `org-super-agenda--hide-or-show-groups`
(https://github.com/alphapapa/org-super-agenda/pull/77/files#diff-465f82cd8ad2c42f0cebb190be6f58abR1114).

In that function I check for the property `'invisible`. If all tasks in a group are
invisible the group gets hidden too.

The question is now, is it possible to further reduce the advised functions to
just one advised function.


best,

Christian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2019-12-15 12:52 Org agenda -- checking for invisible tasks after filtering Christian Schwarzgruber
@ 2020-02-03 19:29 ` Bastien
  2020-02-16 10:13   ` Christian Schwarzgruber
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2020-02-03 19:29 UTC (permalink / raw)
  To: Christian Schwarzgruber; +Cc: emacs-orgmode

Hi Christian,

Christian Schwarzgruber <c.schwarzgruber.cs@gmail.com> writes:

> The question is now, is it possible to further reduce the advised
> functions to just one advised function.

I am sorry, I don't understand what change does it imply on Org's
side.  Can you explain us a bit more?

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-03 19:29 ` Bastien
@ 2020-02-16 10:13   ` Christian Schwarzgruber
  2020-02-16 23:47     ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Schwarzgruber @ 2020-02-16 10:13 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

Bastien <bzg@gnu.org> writes:

> Christian Schwarzgruber <c.schwarzgruber.cs@gmail.com> writes:
>
>> The question is now, is it possible to further reduce the advised
>> functions to just one advised function.
>
> I am sorry, I don't understand what change does it imply on Org's
> side.  Can you explain us a bit more?

Nothing need to be changed on Org's side (I guess). I'm just wondering if there
is a single spot where I can hook in (advice) to achieve the same as with the
currently two advice I use.

The project org-super-agenda advices `org-agenda-finalize-entries` and groups
the entries. However, when one uses the org filter functionality some groups
might be empty, which looks ugly. My implementation to handle that case is to
advice the following functions `org-agenda-filter-apply` and
`org-agenda-finalize`. Both will call the same function
`org-super-agenda--hide-or-show-groups`. If all tasks inside a group have the
invisible property set the group gets hidden as well, and vica versa.

The author of `org-super-agenda` doesn't like my implementation which uses
two advice. But I couldn't find a single spot where I can hook in, and check if
all tasks are hidden...


Thanks!

Christian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-16 10:13   ` Christian Schwarzgruber
@ 2020-02-16 23:47     ` Bastien
  2020-02-17 15:49       ` Christian Schwarzgruber
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2020-02-16 23:47 UTC (permalink / raw)
  To: Christian Schwarzgruber; +Cc: emacs-orgmode

Hi Christian,

you might want to have a look at org-agenda-finalize-hook, though I'm
not sure it can help, I'm not familiar with org-super-agenda enough.

HTH,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-16 23:47     ` Bastien
@ 2020-02-17 15:49       ` Christian Schwarzgruber
  2020-02-17 17:44         ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Schwarzgruber @ 2020-02-17 15:49 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

thank you! That would reduce it to one advice.

However, I would still need to advice the function org-agenda-filter-apply since
it doesn't call `org-agenda-finalize`. Would it make sense to call the hook
org-agenda-finalize-hook at the and of org-agenda-filter-apply or perhaps add a
new hook `org-agenda-filter(-(apply|after))?-hook`? Calling org-agenda-finalize
at the end of org-agenda-filter-apply wont work, because org-agenda-finalize
calls org-agenda-filter-apply, and hence, would result in an infinite
recursion.

org-agenda-filter-remove-all and org-agenda-remove-filter do call
org-agenda-finalize, so this way works.

Thanks Bastien

Bastien <bzg@gnu.org> writes:

> Hi Christian,
>
> you might want to have a look at org-agenda-finalize-hook, though I'm
> not sure it can help, I'm not familiar with org-super-agenda enough.
>
> HTH,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-17 15:49       ` Christian Schwarzgruber
@ 2020-02-17 17:44         ` Bastien
  2020-02-17 20:55           ` Christian Schwarzgruber
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2020-02-17 17:44 UTC (permalink / raw)
  To: Christian Schwarzgruber; +Cc: emacs-orgmode

Hi Christian,

Christian Schwarzgruber <c.schwarzgruber.cs@gmail.com> writes:

> or perhaps add a new hook `org-agenda-filter(-(apply|after))?-hook`?

Yes, this one makes sense, I've added `org-agenda-filter-hook' for
functions that you need to run right after `org-agenda-filter' has
been called.

Thanks for the suggestion!

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-17 17:44         ` Bastien
@ 2020-02-17 20:55           ` Christian Schwarzgruber
  2020-02-17 23:13             ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Schwarzgruber @ 2020-02-17 20:55 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bestian,

Bastien <bzg@gnu.org> writes:

> Yes, this one makes sense, I've added `org-agenda-filter-hook' for
> functions that you need to run right after `org-agenda-filter' has
> been called.

thanks for that change. But unfortunate this one doesn't work for the
org-agenda-filter-by-* functions. However, it would work for all
org-agenda-filter* functions, if the hook would be called at the end of
`org-agenda-filter-apply`. But I can see what than would happen, the hook
would be called several times when more filter types are set. A other option
would be the call the hook at the end of all the org-agenda-filter* functions,
perhaps.

-Christian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Org agenda -- checking for invisible tasks after filtering...
  2020-02-17 20:55           ` Christian Schwarzgruber
@ 2020-02-17 23:13             ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2020-02-17 23:13 UTC (permalink / raw)
  To: Christian Schwarzgruber; +Cc: emacs-orgmode

Hi Christian,

thanks for testing.

Christian Schwarzgruber <c.schwarzgruber.cs@gmail.com> writes:

> thanks for that change. But unfortunate this one doesn't work for the
> org-agenda-filter-by-* functions. However, it would work for all
> org-agenda-filter* functions, if the hook would be called at the end of
> `org-agenda-filter-apply`. But I can see what than would happen, the hook
> would be called several times when more filter types are set.

The added hook is not intrusive and useful, outside the needs related
to your patch to org-super-agenda.

Adding a hook to a function that is called many times is calling for
problems, I don't want to go that way.

> A other option would be the call the hook at the end of all the
> org-agenda-filter* functions, perhaps.

Not sure what you mean (patch welcome just to understand).  But again
I think we don't need more hooks.

Maybe you can explore using post-command-hook in org-super-agenda-mode
in a way that checks whether the last command was a filter command and
then act from there?  Just an idea, not sure it is correct.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-17 23:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-15 12:52 Org agenda -- checking for invisible tasks after filtering Christian Schwarzgruber
2020-02-03 19:29 ` Bastien
2020-02-16 10:13   ` Christian Schwarzgruber
2020-02-16 23:47     ` Bastien
2020-02-17 15:49       ` Christian Schwarzgruber
2020-02-17 17:44         ` Bastien
2020-02-17 20:55           ` Christian Schwarzgruber
2020-02-17 23:13             ` Bastien

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).