5

The org-agenda-daily-view is fancily helpful as a review,
Additionally, I want to append a real-time now line as time elapsed.

enter image description here

This could be achieved by a work around solution, repeatedly kill and open the daily agenda buffer .

Is it possible to make it update automatically say every five minutes?

4

You can use timers for this. run-with-timer allows you to run a command every N seconds. run-with-idle-timer is similar but the command runs only after Emacs has been idle for a number of seconds. An argument to both functions will cause the timer to repeat instead of just firing once. I prefer idle timers so they don't interrupt my typing.

To regenerate the default agenda view (with command "a") every 5 minutes (300 seconds):

(run-with-idle-timer 300 t (lambda () (org-agenda nil "a")) )
4
  • thank you. org-agenda nil means invoke org-agenda but not call a?
    – AbstProcDo
    Jan 19 '19 at 3:12
  • If you don't give a second argument it will open the agenda menu to prompt you.
    – erikstokes
    Jan 19 '19 at 16:20
  • Excellent!. Is there a way to do this without focusing the agenda buffer, though?
    – loki
    Aug 14 '19 at 10:17
  • @loki Try wrapping the org-agenda call with save-window-excursion
    – erikstokes
    Aug 14 '19 at 21:40
0

erikstokes's answer will only run the command one time with 300s delay every time the user becomes idle:

Emacs becomes idle when it starts waiting for user input, and it remains idle until the user provides some input. If a timer is set for five seconds of idleness, it runs approximately five seconds after Emacs first becomes idle. Even if repeat is non-nil, this timer will not run again as long as Emacs remains idle, because the duration of idleness will continue to increase and will not go down to five seconds again. (source)

To make it automatically update every five minutes (even during idle), we can do something like this (reference: the code in https://www.gnu.org/software/emacs/manual/html_node/elisp/Idle-Timers.html):

(defvar refresh-agenda-time-seconds 300)

(defvar refresh-agenda-timer nil
  "Timer for `refresh-agenda-timer-function' to reschedule itself, or nil.")

(defun refresh-agenda-timer-function ()
  ;; If the user types a command while refresh-agenda-timer
  ;; is active, the next time this function is called from
  ;; its main idle timer, deactivate refresh-agenda-timer.
  (when refresh-agenda-timer
    (cancel-timer refresh-agenda-timer))

  (org-agenda nil "a")

  (setq refresh-agenda-timer
    (run-with-idle-timer
      ;; Compute an idle time break-length
      ;; more than the current value.
      (time-add (current-idle-time) refresh-agenda-time-seconds)
      nil
      'refresh-agenda-timer-function)))

(run-with-idle-timer refresh-agenda-time-seconds t 'refresh-agenda-timer-function)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.