emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Hotlist agenda view: how to simplify its expression?
@ 2013-08-09 14:56 Sebastien Vauban
  2013-08-09 15:54 ` Jonathan Leech-Pepin
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Vauban @ 2013-08-09 14:56 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

Suppose I want a convenient way to see my most important tasks, the ones
which:

- are due soon (in the next 7 days), or
- have a high priority (#A), or
- are FLAGGED.

If I don't mind having the entries mixed, this is quite simple and short:

#+begin_src emacs-lisp
  (add-to-list 'org-agenda-custom-commands
               '("H" "Hotlist"
                 tags-todo "DEADLINE<=\"<+1w>\"|PRIORITY=\"A\"|FLAGGED"
                 ((org-agenda-todo-ignore-scheduled 'future))) t)
#+end_src

Though, if I want 3 different blocks (in the above order) with *no repetition*
of entries, I need to write such a monster expression:

#+begin_src emacs-lisp
  (add-to-list 'org-agenda-custom-commands
               '("I" "Hotlist"
                 ((tags-todo "DEADLINE<=\"<+1w>\""
                             ((org-agenda-overriding-header "Due in next 7 days")))
                  (tags-todo "PRIORITY=\"A\"+DEADLINE=\"\"|PRIORITY=\"A\"+DEADLINE>\"<+1w>\""
                             ((org-agenda-overriding-header "High priority")))
                  (tags-todo "FLAGGED+PRIORITY=\"\"+DEADLINE=\"\"|FLAGGED+PRIORITY=\"\"+DEADLINE>\"<+1w>\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE=\"\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE>\"<+1w>\""
                             ((org-agenda-overriding-header "Starred"))))
                 ((org-agenda-todo-ignore-scheduled 'future))) t)
#+end_src

Do you see a way to optimize it (make it shorter)?  On the problems relies in
the fact that the inverse of

    DEADLINE<="<+1w>"

is

    DEADLINE=""|DEADLINE>"<+1w>"

that is 2 tests to be done.

The same applies for the priorities: the inverse of

    PRIORITY=\"A\"

is

    PRIORITY=""|PRIORITY<>"A"

Hence, an exponential number of checks every time you want to remove
duplicated entries (which would have been displayed in the previous block):
you double the number of subexpressions in the next block...

Any better idea?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Hotlist agenda view: how to simplify its expression?
  2013-08-09 14:56 Hotlist agenda view: how to simplify its expression? Sebastien Vauban
@ 2013-08-09 15:54 ` Jonathan Leech-Pepin
  2013-08-12 11:58   ` Sebastien Vauban
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Leech-Pepin @ 2013-08-09 15:54 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: Org Mode Mailing List

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

Hello,

On Aug 9, 2013 10:57 AM, "Sebastien Vauban" <sva-news@mygooglest.com> wrote:
>
> Hello,
>
> Suppose I want a convenient way to see my most important tasks, the ones
> which:
>
> - are due soon (in the next 7 days), or
> - have a high priority (#A), or
> - are FLAGGED.
>
> If I don't mind having the entries mixed, this is quite simple and short:
>
> #+begin_src emacs-lisp
>   (add-to-list 'org-agenda-custom-commands
>                '("H" "Hotlist"
>                  tags-todo "DEADLINE<=\"<+1w>\"|PRIORITY=\"A\"|FLAGGED"
>                  ((org-agenda-todo-ignore-scheduled 'future))) t)
> #+end_src
>
> Though, if I want 3 different blocks (in the above order) with *no
repetition*
> of entries, I need to write such a monster expression:
>
> #+begin_src emacs-lisp
>   (add-to-list 'org-agenda-custom-commands
>                '("I" "Hotlist"
>                  ((tags-todo "DEADLINE<=\"<+1w>\""
>                              ((org-agenda-overriding-header "Due in next
7 days")))
>                   (tags-todo
"PRIORITY=\"A\"+DEADLINE=\"\"|PRIORITY=\"A\"+DEADLINE>\"<+1w>\""
>                              ((org-agenda-overriding-header "High
priority")))
>                   (tags-todo
"FLAGGED+PRIORITY=\"\"+DEADLINE=\"\"|FLAGGED+PRIORITY=\"\"+DEADLINE>\"<+1w>\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE=\"\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE>\"<+1w>\""
>                              ((org-agenda-overriding-header "Starred"))))
>                  ((org-agenda-todo-ignore-scheduled 'future))) t)
> #+end_src
>
> Do you see a way to optimize it (make it shorter)?  On the problems
relies in
> the fact that the inverse of
>
>     DEADLINE<="<+1w>"
>
> is
>
>     DEADLINE=""|DEADLINE>"<+1w>"
>
> that is 2 tests to be done.
>
> The same applies for the priorities: the inverse of
>
>     PRIORITY=\"A\"
>
> is
>
>     PRIORITY=""|PRIORITY<>"A"
>
> Hence, an exponential number of checks every time you want to remove
> duplicated entries (which would have been displayed in the previous
block):
> you double the number of subexpressions in the next block...
>
Could you use (org-agenda-skip-regexp "...") combined with
(org-agenda-skip-function (org-agenda-skip-entry-when-regexp-matches))

Just change the ... in the above to the deadline/priority you want to
exclude in the block.

Sorry if this is at all unclear, sending from my phone so hard to write out
the code blocks.

Regards,
Jon

> Any better idea?
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>

[-- Attachment #2: Type: text/html, Size: 3751 bytes --]

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

* Re: Hotlist agenda view: how to simplify its expression?
  2013-08-09 15:54 ` Jonathan Leech-Pepin
@ 2013-08-12 11:58   ` Sebastien Vauban
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastien Vauban @ 2013-08-12 11:58 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello Jonathan,

Jonathan Leech-Pepin wrote:
> On Aug 9, 2013 10:57 AM, "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org> wrote:
>> Suppose I want a convenient way to see my most important tasks, the ones
>> which:
>>
>> - are due soon (in the next 7 days), or
>> - have a high priority (#A), or
>> - are FLAGGED.
>>
>> If I want 3 different blocks (in the above order) with *no repetition* of
>> entries, I need to write such a monster expression:
>>
>> #+begin_src emacs-lisp
>>   (add-to-list 'org-agenda-custom-commands
>>                '("I" "Hotlist"
>>                  ((tags-todo "DEADLINE<=\"<+1w>\""
>>                              ((org-agenda-overriding-header "Due in next 7 days")))
>>                   (tags-todo "PRIORITY=\"A\"+DEADLINE=\"\"|PRIORITY=\"A\"+DEADLINE>\"<+1w>\""
>>                              ((org-agenda-overriding-header "High priority")))
>>                   (tags-todo "FLAGGED+PRIORITY=\"\"+DEADLINE=\"\"|FLAGGED+PRIORITY=\"\"+DEADLINE>\"<+1w>\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE=\"\"|FLAGGED+PRIORITY<>\"A\"+DEADLINE>\"<+1w>\""
>>                              ((org-agenda-overriding-header "Starred"))))
>>                  ((org-agenda-todo-ignore-scheduled 'future))) t)
>> #+end_src
>>
>> Do you see a way to optimize it (make it shorter)?
>
> Could you use (org-agenda-skip-regexp "...") combined with
> (org-agenda-skip-function (org-agenda-skip-entry-when-regexp-matches))
>
> Just change the ... in the above to the deadline/priority you want to
> exclude in the block.

I can do it for checking for the PRIORITY cookie (#A), but I can't transform
(the inverse of) DEADLINE<="<+1w>" into a regexp...

Though, here is already a nicer version of the above command:

--8<---------------cut here---------------start------------->8---
  (add-to-list 'org-agenda-custom-commands
               '("dh" "Hotlist"
                 ;; tags-todo "DEADLINE<=\"<+1w>\"|PRIORITY=\"A\"|FLAGGED"
                 ((tags-todo "DEADLINE<=\"<+1w>\""
                             ((org-agenda-overriding-header "Due in next 7 days")))
                  (tags-todo "PRIORITY=\"A\"+DEADLINE=\"\"|PRIORITY=\"A\"+DEADLINE>\"<+1w>\""
                             ((org-agenda-overriding-header "High priority")))
                  (tags-todo "FLAGGED+DEADLINE=\"\"|FLAGGED+DEADLINE>\"<+1w>\""
                             ((org-agenda-overriding-header "Starred")
                              (org-agenda-skip-regexp "\\[#A\\]")
                              (org-agenda-skip-function
                               '(org-agenda-skip-entry-when-regexp-matches)))))
                 ((org-agenda-todo-ignore-scheduled 'future))) t)
--8<---------------cut here---------------end--------------->8---

Thanks!

Best regards,
  Seb

-- 
Sebastien Vauban

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

end of thread, other threads:[~2013-08-12 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 14:56 Hotlist agenda view: how to simplify its expression? Sebastien Vauban
2013-08-09 15:54 ` Jonathan Leech-Pepin
2013-08-12 11:58   ` Sebastien Vauban

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