emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] New variable to speed up custom agendas
@ 2010-03-09  4:39 Matt Lundin
  2010-03-10 16:15 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Lundin @ 2010-03-09  4:39 UTC (permalink / raw)
  To: Org Mode

Hi Carsten,

Below is a patch I've been using to speed up the construction of agenda
views limited to certain types of entries (e.g., timestamps and sexps).
Previously, I had constructed "calendar" views consisting only of
timestamps and sexps by using the variable org-agenda-skip-function to
exclude scheduled items and deadlines from the agenda. This, however,
proved somewhat slow (3-4 seconds for weekly calendars, 10-12 seconds
for monthly calendars). The patch below cuts the times to 1 and 3
seconds respectively. I believe it provides an efficient alternative to
the skip function by allowing the user to tweak the arguments passed to
org-agenda-get-day-entries.

Thanks for taking a look at this, and please do excuse any grotesque
errors perpetrated by an elisp novice.

- Matt

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 514634f..5ec0b32 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3089,6 +3089,21 @@ When EMPTY is non-nil, also include days without any entries."
 (defvar org-agenda-span nil) ; local variable in the agenda buffer
 (defvar org-include-all-loc nil) ; local variable
 
+(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
+  "This variable is a list of symbols that controls the types of
+items that appear in the daily/weekly agenda. By default, items
+with deadlines, scheduled timestamps, active timestamps, and
+diary sexps are included. For a full list of possible arguments,
+see the documentation for the `org-diary'
+
+Never set this variable globally using `setq', because then it
+will apply to all future agenda commands. Instead, bind it with
+`let' to scope it dynamically into the the agenda-constructing
+command. A good way to set it is through options in
+`org-agenda-custom-commands'. For a more flexible (though
+somewhat less efficient) way of determining what is included in
+the daily/weekly agenda, see `org-agenda-skip-function'.")
+
 ;;;###autoload
 (defun org-agenda-list (&optional include-all start-day ndays)
   "Produce a daily/weekly view from all files in variable `org-agenda-files'.
@@ -3217,13 +3232,13 @@ given in `org-agenda-start-on-weekday'."
            (setq rtn (org-agenda-get-day-entries
                       file date :closed)))
           (org-agenda-show-log
-           (setq rtn (org-agenda-get-day-entries
+           (setq rtn (apply 'org-agenda-get-day-entries
                       file date
-                      :deadline :scheduled :timestamp :sexp :closed)))
+                      (append '(:closed) org-agenda-entry-types))))
           (t
-           (setq rtn (org-agenda-get-day-entries
-                      file date
-                      :deadline :scheduled :sexp :timestamp))))
+           (setq rtn (apply 'org-agenda-get-day-entries
+                            file date
+                            org-agenda-entry-types))))
          (setq rtnall (append rtnall rtn))))
       (if org-agenda-include-diary
          (let ((org-agenda-search-headline-for-time t))
--8<---------------cut here---------------end--------------->8---

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

* Re: [PATCH] New variable to speed up custom agendas
  2010-03-09  4:39 [PATCH] New variable to speed up custom agendas Matt Lundin
@ 2010-03-10 16:15 ` Carsten Dominik
  2010-03-11  4:12   ` Matthew Lundin
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-03-10 16:15 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Org Mode

Hi Matt,

wow, you have proven me wrong.  There is a way to get
a significant speedup in agenda construction, for special
cases like you mentioned in an earlier message.  This is
brilliant.

I have taken the patch, with a few small modifications:

1. I changed the constant `org-agenda-custom-commands-local-options'
    so that it will become a lot easier to bind this variable as an
    an option when configuring `org-agenda-custom-commands' using
    the customize interface.

2. I modified the docstring of the new variable so that the first line
    is a stand-alone sentence, as required in Emacs.

3. I moved the description of the symbols into your new variable,
    and made org-diary point to it.  I think the new location is
    a better place for this.

Excellent, thank you very much.  Will you add an example to
your org-agenda-custom-commands tutorial?

- Carsten

On Mar 9, 2010, at 5:39 AM, Matt Lundin wrote:

> Hi Carsten,
>
> Below is a patch I've been using to speed up the construction of  
> agenda
> views limited to certain types of entries (e.g., timestamps and  
> sexps).
> Previously, I had constructed "calendar" views consisting only of
> timestamps and sexps by using the variable org-agenda-skip-function to
> exclude scheduled items and deadlines from the agenda. This, however,
> proved somewhat slow (3-4 seconds for weekly calendars, 10-12 seconds
> for monthly calendars). The patch below cuts the times to 1 and 3
> seconds respectively. I believe it provides an efficient alternative  
> to
> the skip function by allowing the user to tweak the arguments passed  
> to
> org-agenda-get-day-entries.
>
> Thanks for taking a look at this, and please do excuse any grotesque
> errors perpetrated by an elisp novice.
>
> - Matt
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 514634f..5ec0b32 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -3089,6 +3089,21 @@ When EMPTY is non-nil, also include days  
> without any entries."
> (defvar org-agenda-span nil) ; local variable in the agenda buffer
> (defvar org-include-all-loc nil) ; local variable
>
> +(defvar org-agenda-entry-types  
> '(:deadline :scheduled :timestamp :sexp)
> +  "This variable is a list of symbols that controls the types of
> +items that appear in the daily/weekly agenda. By default, items
> +with deadlines, scheduled timestamps, active timestamps, and
> +diary sexps are included. For a full list of possible arguments,
> +see the documentation for the `org-diary'
> +
> +Never set this variable globally using `setq', because then it
> +will apply to all future agenda commands. Instead, bind it with
> +`let' to scope it dynamically into the the agenda-constructing
> +command. A good way to set it is through options in
> +`org-agenda-custom-commands'. For a more flexible (though
> +somewhat less efficient) way of determining what is included in
> +the daily/weekly agenda, see `org-agenda-skip-function'.")
> +
> ;;;###autoload
> (defun org-agenda-list (&optional include-all start-day ndays)
>   "Produce a daily/weekly view from all files in variable `org- 
> agenda-files'.
> @@ -3217,13 +3232,13 @@ given in `org-agenda-start-on-weekday'."
>            (setq rtn (org-agenda-get-day-entries
>                       file date :closed)))
>           (org-agenda-show-log
> -           (setq rtn (org-agenda-get-day-entries
> +           (setq rtn (apply 'org-agenda-get-day-entries
>                       file date
> -                      :deadline 
>  :scheduled :timestamp :sexp :closed)))
> +                      (append '(:closed) org-agenda-entry-types))))
>           (t
> -           (setq rtn (org-agenda-get-day-entries
> -                      file date
> -                      :deadline :scheduled :sexp :timestamp))))
> +           (setq rtn (apply 'org-agenda-get-day-entries
> +                            file date
> +                            org-agenda-entry-types))))
>          (setq rtnall (append rtnall rtn))))
>       (if org-agenda-include-diary
>          (let ((org-agenda-search-headline-for-time t))
> --8<---------------cut here---------------end--------------->8---
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: [PATCH] New variable to speed up custom agendas
  2010-03-10 16:15 ` Carsten Dominik
@ 2010-03-11  4:12   ` Matthew Lundin
  2010-03-11 10:33     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Lundin @ 2010-03-11  4:12 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org Mode

Hi Carsten,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> wow, you have proven me wrong.  There is a way to get
> a significant speedup in agenda construction, for special
> cases like you mentioned in an earlier message.  This is
> brilliant.
>
> I have taken the patch, with a few small modifications:
>
> 1. I changed the constant `org-agenda-custom-commands-local-options'
>    so that it will become a lot easier to bind this variable as an
>    an option when configuring `org-agenda-custom-commands' using
>    the customize interface.
>
> 2. I modified the docstring of the new variable so that the first line
>    is a stand-alone sentence, as required in Emacs.
>
> 3. I moved the description of the symbols into your new variable,
>    and made org-diary point to it.  I think the new location is
>    a better place for this.

Thanks for applying the patch and for making these additional
modifications! 

> Excellent, thank you very much.  Will you add an example to
> your org-agenda-custom-commands tutorial?

I would be glad to. I'll put it on my todo list. :)

- Matt

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

* Re: [PATCH] New variable to speed up custom agendas
  2010-03-11  4:12   ` Matthew Lundin
@ 2010-03-11 10:33     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2010-03-11 10:33 UTC (permalink / raw)
  To: Matthew Lundin; +Cc: Org Mode

Hi Matt,

sorry, it looks like I forgot to push yesterday evening.  Done now...

- Carsten

On Mar 11, 2010, at 5:12 AM, Matthew Lundin wrote:

> Hi Carsten,
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> wow, you have proven me wrong.  There is a way to get
>> a significant speedup in agenda construction, for special
>> cases like you mentioned in an earlier message.  This is
>> brilliant.
>>
>> I have taken the patch, with a few small modifications:
>>
>> 1. I changed the constant `org-agenda-custom-commands-local-options'
>>   so that it will become a lot easier to bind this variable as an
>>   an option when configuring `org-agenda-custom-commands' using
>>   the customize interface.
>>
>> 2. I modified the docstring of the new variable so that the first  
>> line
>>   is a stand-alone sentence, as required in Emacs.
>>
>> 3. I moved the description of the symbols into your new variable,
>>   and made org-diary point to it.  I think the new location is
>>   a better place for this.
>
> Thanks for applying the patch and for making these additional
> modifications!
>
>> Excellent, thank you very much.  Will you add an example to
>> your org-agenda-custom-commands tutorial?
>
> I would be glad to. I'll put it on my todo list. :)
>
> - Matt
>

- Carsten

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

end of thread, other threads:[~2010-03-11 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-09  4:39 [PATCH] New variable to speed up custom agendas Matt Lundin
2010-03-10 16:15 ` Carsten Dominik
2010-03-11  4:12   ` Matthew Lundin
2010-03-11 10:33     ` Carsten Dominik

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