From mboxrd@z Thu Jan 1 00:00:00 1970 From: Malcolm Purvis Subject: Regex Speedup for org-refresh-category-properties. Date: Tue, 29 Jul 2014 13:41:14 +1000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XByI1-0006ru-PH for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 23:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XByHv-0003rG-TQ for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 23:41:25 -0400 Received: from mail108.syd.optusnet.com.au ([211.29.132.59]:35496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XByHv-0003qy-Hm for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 23:41:19 -0400 Received: from purvis.id.au (c110-20-44-66.rivrw8.nsw.optusnet.com.au [110.20.44.66]) by mail108.syd.optusnet.com.au (Postfix) with ESMTP id B92831A2BE9 for ; Tue, 29 Jul 2014 13:41:15 +1000 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I use the master version of org, and some months ago the time required to generate my custom agenda view sky rocketed. I've found that 90% of the time was being spent in the call to re-search-forward in org-refresh-category-properties. The patch below speeds up the regular expression search and makes the generation of my agenda as fast as before. Malcolm diff --git a/lisp/org.el b/lisp/org.el index 7e30061..2fc6854 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9474,7 +9474,7 @@ The refresh happens only for the current tree (not subtree)." (goto-char (point-min)) (put-text-property (point) (point-max) 'org-category def-cat) (while (re-search-forward - "^[ \t]*\\(#\\+CATEGORY:\\|[ \t]*:CATEGORY:\\)\\(.*\\)" nil t) + "^[ \t]*\\(#\\+CATEGORY:\\|*:CATEGORY:\\)\\(.*\\)" nil t) (setq pos (match-end 0) optionp (equal (char-after (match-beginning 0)) ?#) cat (org-trim (match-string 2))) -- Malcolm Purvis