Dear all, 

Thanks for your kind reply! Sorry that I didn't have chance to check till now. 

OKay, I added the function:

(defun sx-org-revert-agenda-buffers ()
  (interactive)
  (mapcar
   (lambda (file)
     (let ((revert-without-query '(".*\.org$")))
       (find-file file)
       (revert-buffer)))
   (org-agenda-files t)))

It works ! Thanks a lot!

Xin



On Thu, Jul 26, 2012 at 11:32 PM, Carsten Dominik <carsten.dominik@gmail.com> wrote:
Carsten Dominik <carsten.dominik@gmail.com> wrote:

>
> On 25 jul 2012, at 17:39, Nick Dokos wrote:
>
>> ...
>> On the OP's question, I'd prefer a more targeted solution: something
>> like this should work (very lightly tested - check the doc for
>> revert-without-query if you want to modify the regexp):
>>
>> --8<---------------cut here---------------start------------->8---
>> (defun xin-shi-org-revert-agenda-buffers ()
>> (interactive)
>> (mapcar
>>  (lambda (file)
>>    (let ((revert-without-query '(".*\.org$")))
>>      (find-file file)
>>      (revert-buffer)))
>>  org-agenda-files))
>> --8<---------------cut here---------------end--------------->8---
>
>
> The variable org-agenda-files can also contain directories.  Therefore
> you should use the function call
>
>   (org-agenda-files t)
>
> to get a list of the files.  The t means, even if the agenda
> is currently restricted, get all files.
>

Thanks - I forgot all about that.

> Another improvement to this function would be to limit it
> to files currently visited - but I guess this is a minor issue
> as the next agenda command will visit all those files anyway.
>

Yes, I thought about that and decided it wasn't worth worrying about.
As Kernighan and Plauger say: first get it right, then make it fast; and
as we just saw, it wasn't right :-). But for typical setups - a few
files or a few dozen files - I don't think it's going to make much
difference. OTOH, if one has thousands of agenda files, then one
probably has much worse problems than this.



Uhhh, yes, indeed!

- Carsten

Nick