From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [PATCH] New variable to speed up custom agendas Date: Mon, 08 Mar 2010 23:39:57 -0500 Message-ID: <87eiju152a.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NorEC-0004Ir-Hv for emacs-orgmode@gnu.org; Mon, 08 Mar 2010 23:39:32 -0500 Received: from [140.186.70.92] (port=59024 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NorEB-0004Ia-Jd for emacs-orgmode@gnu.org; Mon, 08 Mar 2010 23:39:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NorEA-0004zl-B7 for emacs-orgmode@gnu.org; Mon, 08 Mar 2010 23:39:31 -0500 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:34807) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NorEA-0004zg-6y for emacs-orgmode@gnu.org; Mon, 08 Mar 2010 23:39:30 -0500 Received: from archdesk (adsl-99-19-42-244.dsl.klmzmi.sbcglobal.net [99.19.42.244]) by mail.messagingengine.com (Postfix) with ESMTPSA id DAF854CD567 for ; Mon, 8 Mar 2010 23:39:28 -0500 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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---