alphapapa / org-super-agenda

Supercharge your Org daily/weekly agenda by grouping items

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to revert agenda files

djelenc opened this issue · comments

I'd like to generate an agenda by loading contents from an org file whose contents may have changed since the last time the file was opened in emacs, that is, the last time I generated the agenda. The file might have been changed by an external program.

If I don't manually reopen the file and refresh the buffer this way, the agenda gets generated with the old (cached) contents. One solution would be to globally set the variable global-auto-revert-mode, but it feels a bit nuclear, since I'd like to revert only a single buffer. Additionally, it explicitly asks the user for permission to update the buffer with new contents.

I have tracked down the problem to reverting the buffer and also found a solution, but for the classic agenda here:

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

However, I do not know how to use this with the org-super-agenda. I would appreciate any advice regarding this.

And thanks for this beautiful piece of software.

A working hack is to put the following contents in the file whose contents may get changed externally.

# Local Variables:
# eval: (auto-revert-mode t)
# End:

I would still prefer a solution that can be expressed in code, since this one depends on the file contents.

Hi David,

I use global-auto-revert-mode, and I never have to worry about whether a buffer's file has been modified outside of Emacs. AFAIK it only prompts if the buffer has also been modified in Emacs; if that happens, it usually means I did something wrong.

However, I do not know how to use this with the org-super-agenda. I would appreciate any advice regarding this.

org-super-agenda doesn't have anything to do with this. Please see this FAQ entry: https://github.com/alphapapa/org-super-agenda#why-are-some-items-not-displayed-even-though-i-used-group-selectors-for-them

I would still prefer a solution that can be expressed in code, since this one depends on the file contents.

If you don't want to use global-auto-revert-mode, you could add auto-revert-mode to org-mode-hook. But there's nothing wrong with using a file-local variable to do it.

And thanks for this beautiful piece of software.

Thanks for the kind words.

I use global-auto-revert-mode, and I never have to worry about whether a buffer's file has been modified outside of Emacs. AFAIK it only prompts if the buffer has also been modified in Emacs; if that happens, it usually means I did something wrong.

So I have tested this and it basically works as one would want it to work. It complains only if you manually create a conflict inside the buffer. global-auto-revert-mode is what I need. Thanks.