Hi Kiwon, On Wed, 12 Jan 2011 12:23:48 +0900 Kiwon Um <um.ki...@gmail.com> wrote:
> Dear org users, > > The recent function for showing current time in agenda view is quite > cool. I have a question about it. When the agenda view is being shown, > is there any way to refresh it automatically so that makes the current > time line always recent? > I have thought about that, I even worked up a small minor mode for that (attached). But it doesn't seem to work very well. It updates only the first time but fails subsequently. I am still a lisp newbie. If someone could guide me, I could give it another try. Right now it only updates if any of the agenda file buffers change but I would also like to put a timer. Then if no agenda files have been edited in a while (say 5 mins) the agenda buffer is refreshed anyway. But I don't know how to do that. Any suggestions would be welcome. > Thanks. > Thanks > -- > Kiwon Um -- Suvayu Open source is the future. It sets us free.
>From 82a240bd0af7ac4e7e59357777bf38892972f4c7 Mon Sep 17 00:00:00 2001 From: Suvayu Ali <fatkasuvayu+li...@gmail.com> Date: Tue, 11 Jan 2011 23:17:08 -0800 Subject: [PATCH] Implement org-agenda-refresh-mode minor mode * lisp/org-agenda.el: (org-agenda-refresh-mode) New minor mode to auto-refresh the agenda buffer (org-agenda-refresh-changed) The function used to refresh the Agenda buffer Issue: updates only the first time. --- lisp/org-agenda.el | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index bf36758..d5f11eb 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6780,6 +6780,31 @@ if it was hidden in the outline." (org-back-to-heading) (recenter n))) +(defvar org-agenda-refresh-mode) +(defvar org-agenda-refresh-changed-buffers nil) + +(define-minor-mode org-agenda-refresh-mode + "Turn on refresh for Agenda buffer." + nil nil nil + (unless (derived-mode-p 'org-agenda-mode) + (error "Not in an Org Agenda buffer")) + (frame-or-buffer-changed-p 'org-agenda-refresh-changed-buffers) + (add-hook 'post-command-hook 'org-agenda-refresh-changed)) + +(defun org-agenda-refresh-changed () + "Update Org Agenda buffer." + (interactive) + (when (frame-or-buffer-changed-p 'org-agenda-refresh-changed-buffers) + (let* ((agenda-buf (get-buffer "*Org Agenda*"))) + (dolist (buf (org-buffer-list 'agenda)) + (ignore-errors + (if (and (buffer-modified-p buf) + (with-current-buffer buf (eq 'org-mode major-mode))) + (with-current-buffer agenda-buf + (when (and org-agenda-refresh-mode + (derived-mode-p 'org-agenda-mode)) + (org-agenda-redo))))))))) + (defvar org-agenda-cycle-counter nil) (defun org-agenda-cycle-show (&optional n) "Show the current entry in another window, with default settings. -- 1.7.3.4
_______________________________________________ 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