From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suvayu Ali Subject: Re: org-agenda-show-current-time-in-grid and automatic refresh Date: Tue, 11 Jan 2011 23:19:09 -0800 Message-ID: <20110111231909.2338897e@bhishma.homelinux.net> References: <87fwsyyfcr.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/eM.CsfmlzJRju/.PDV+kWBI" Return-path: Received: from [140.186.70.92] (port=53512 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcuzF-0006tA-Lz for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 02:19:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcuzE-0002Hd-HY for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 02:19:17 -0500 Received: from mail-gy0-f169.google.com ([209.85.160.169]:54745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcuzE-0002HX-Ei for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 02:19:16 -0500 Received: by gyd10 with SMTP id 10so121714gyd.0 for ; Tue, 11 Jan 2011 23:19:15 -0800 (PST) In-Reply-To: <87fwsyyfcr.fsf@gmail.com> 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: Kiwon Um Cc: emacs-orgmode@gnu.org --MP_/eM.CsfmlzJRju/.PDV+kWBI Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Kiwon, On Wed, 12 Jan 2011 12:23:48 +0900 Kiwon Um 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. --MP_/eM.CsfmlzJRju/.PDV+kWBI Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-org-agenda-refresh-mode-minor-mode.patch >From 82a240bd0af7ac4e7e59357777bf38892972f4c7 Mon Sep 17 00:00:00 2001 From: Suvayu Ali 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 --MP_/eM.CsfmlzJRju/.PDV+kWBI Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --MP_/eM.CsfmlzJRju/.PDV+kWBI--