I am trying to rebuild my Org Agenda buffer with a timer. I am trying to do it like this:
(defun renewOrgBuffer ()
(interactive)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (derived-mode-p 'org-agenda-mode)
(org-agenda-redo t))))
)
(run-with-idle-timer 60 1000 #'renewOrgBuffer)
I basically swiped this from another answer but they wanted to do somehting when the org file saved. I want to update it with a timer and am running into errors.
When I just run the function in ielm
I get the error: *** Eval error *** ‘recenter’ing a window that does not display current-buffer.
I am running Emacs 25.1.50.2 client connected to a daemon with org verion 8.2.10 on Ubuntu 15.10.
The purpose for this for me is that I like to have my org file with my todos and appointments up in one buffer and the Org Agenda buffer up next to it. So the the main purpose for me to update the Org Agenda buffer is just so that the line that says now - - - - -
updates. It is a small think but I just want to figure it out.
Any help or pointers is appreciated.
Edit March 7
I have found that if you enable the sticky agenda view from the dispatcher (* option) then I can call my previously defined renewOrgBuffer
function interactively with M-x and instead of getting an error, I get a message in the mini buffer that says "org-agenda-list: ‘recenter’ing a window that does not display current-buffer.", which is great, but I don't want to call it interactively every time.
When I try to run that function from the scratch buffer or on a timer like
(run-with-idle-timer 3 1000 #'renewOrgBuffer)
I get the error:
Rebuilding agenda buffer...done
Error running timer ‘renewOrgBuffer’: (error "‘recenter’ing a window that does not display current-buffer.")
Although it says "Rebuilding agenda buffer...done" it does not actually rebuild it.
Any help with this added information would be helpful, Thank you.
recenter
in org-mode -- grep them and comment them out, and re-byte-compile if necessary. Or, find the offending function that has the word(recenter
and redefine it or use advice. You want to be able to operate on buffers that are not visible, andrecenter
is preventing you from further developing your new system. Later on, you can write-in some exceptions for when a window is visible, then recenter . . . I took care of that in my own setup a long time ago./usr/local/share/emacs/25.1.50/lisp/org
. Are you suggesting editing the source and recompiling it? Thanksrecenter
. You can either edit the source and re-byte-compile, or you can just create new functions with the same names for those that need modification. For example, if the function namedfoo
contains arecenter
command` andfoo
is located in the library namedorg-foo.el
, then your.emacs
can have something like:(require 'org-foo) (defun foo (however many arguments) [the modified guts less the recenter garbage]))
and then restart Emacs or evaluate your.emacs
file.org-agenda-maybe-redo
, which callsorg-agenda-redo
but does some other things making it usable to me. Thanks for your input though!