As a programmer who sits before a computer more than 8 hours a day, standing up and exercising a bit regularly is said to be a good way to extend my lifespan. In this era, I believe even living a little longer could make a tremendous difference (see 《永生的阶梯》 by Cixin Liu, or Technological singularity on Wikipedia).

Given that I keep the emacs process live as long as my computer is on, I decide to set some alarms in emacs so it reminds to stand up and do some stretches every hour.

I posted this question on both Google+ and #emacs and got some feedback. Many people recommend org-pomodoro, which is an emacs implementation of the Pomodoro Technique.

I read its document and it looks promising, but I want something simpler. So I keep searching and trying different solutions until appt solves the problem imperfectly.

First step, install appt in emacs: M-x el-get-install appt (or through any other emacs plugins installation approach)

However, it turns out that appt requires some functions that are not available in emacs 24.4. Therefore, I have to do some small modifications to appt.

Remove the elc in case it affects anything: M-x delete-file ~/.emacs.d/el-get/appt/appt.elc

Then open the appt.el, C-x C-f ~/.emacs.d/el-get/appt/appt.el , search for update-calendar-mode-line and delete every line that contains it. C-x C-s , save the file. Now appt is usable.

Evaluate the following s-expressions and put them in your init.el:

;; Diary entries notification ( require ' appt ) ( setq appt-message-warning-time 0 ) ; 0 minute time before warning ( setq diary-file "~/diary" ) ; diary file

Since I just want to stand up and do some stretches regularly, I set appt-message-warning-time to 0, otherwise warnings would pop up a few minutes in advance.

Then specify a diary file: ~/diary (you can set it to any file you like)

Create this diary file C-x C-f ~/diary and write the following content to it (there might be more concise ways to express what I wrote, I didn’t read through the document):

Monday 9:00am stand up 10:00am stand up 11:00am stand up 12:00pm lunch time 2:00pm stand up 3:00pm stand up 4:00pm stand up 5:00pm leave office Tuesday 9:00am stand up 10:00am stand up 11:00am stand up 12:00pm lunch time 2:00pm stand up 3:00pm stand up 4:00pm stand up 5:00pm leave office Wednesday 9:00am stand up 10:00am stand up 11:00am stand up 12:00pm lunch time 2:00pm stand up 3:00pm stand up 4:00pm stand up 5:00pm leave office Thursday 9:00am stand up 10:00am stand up 11:00am stand up 12:00pm lunch time 2:00pm stand up 3:00pm stand up 4:00pm stand up 5:00pm leave office Friday 9:00am stand up 10:00am stand up 11:00am stand up 12:00pm lunch time 2:00pm stand up 3:00pm stand up 4:00pm stand up 5:00pm leave office

Save this file and press M-x appt-activate , done, emacs will pop up a new buffer for each entry in the diary on time.

Reference: http://www.gnu.org/software/emacs/manual/html_node/emacs/Appointments.html

Share this:

Print

