emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Mikhanosha <max@openchat.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] speedup redisplay of agenda item after change
Date: Fri, 28 Sep 2012 13:01:45 -0400	[thread overview]
Message-ID: <87mx0at72e.wl%max@openchat.com> (raw)

I had noticed that with large agendas (several hundred items), any
command that changes and re-displays the current item is slow. For
example something like changing priority with Shift-Up/Down key, can
take a second or two.

Most of that time is spent in (org-agenda-finalize) call, which is
responsible for putting finishes touches, such as fortifying [#A] as
bold when you change priority from [#B].

It seems that even if only single line had changed, the
(org-agenda-finalize) still processes entire agenda buffer, which is
the cause of the slowness.

Following patch changes (org-agenda-change-all-lines) to call
(org-agenda-finalize) for each line changed, with agenda buffer
narrowed to just that line, and it speeds up redisplay of current item
a lot, the Shift-Up changing of priority can almost keep up with
keyboard repeat rate on large agendas.

I was running with this patch for a month, and did not noticed any
problems so far.

From 432293f3c55308f3f76b0c5284ca696fb11f10ea Mon Sep 17 00:00:00 2001
From: Max Mikhanosha <max@openchat.com>
Date: Fri, 28 Sep 2012 09:02:07 -0400
Subject: [PATCH] speedup redisplay of agenda item after change

* lisp/org-agenda.el (org-agenda-change-all-lines): speedup
 refresh of a single line of agenda by narrowing the agenda
 buffer just that line before calling org-agenda-finalize-

---
 lisp/org-agenda.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ea607eb..30dd5bf 100755
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8079,9 +8079,11 @@ (defun org-agenda-change-all-lines (newhead hdmarker
 			 undone-face done-face))))
 	    (org-agenda-highlight-todo 'line)
 	    (beginning-of-line 1))
-	   (t (error "Line update did not work"))))
-	(beginning-of-line 0)))
-    (org-agenda-finalize)))
+	   (t (error "Line update did not work")))
+	  (save-restriction
+	    (narrow-to-region (point-at-bol) (point-at-eol))
+	    (org-agenda-finalize)))
+	(beginning-of-line 0)))))
 
 (defun org-agenda-align-tags (&optional line)
   "Align all tags in agenda items to `org-agenda-tags-column'."
-- 
1.7.11.rc0.100.g5498c5f

             reply	other threads:[~2012-09-28 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28 17:01 Max Mikhanosha [this message]
2012-09-29  6:21 ` [PATCH] speedup redisplay of agenda item after change Bastien
2012-09-30 20:29   ` Max Mikhanosha
2012-09-30 21:20     ` Bastien
2012-09-29  9:20 ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mx0at72e.wl%max@openchat.com \
    --to=max@openchat.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).