GNU Emacs

31.12 Summing Time Intervals

The timeclock package adds up time intervals, so you can (for instance) keep track of how much time you spend working on particular projects. (A more advanced alternative is to use the Org Mode’s facilities for clocking time, see Clocking Work Time in The Org Manual).

Use the M-x timeclock-in command when you start working on a project, and M-x timeclock-out command when you’re done. Each time you do this, it adds one time interval to the record of the project. You can change to working on a different project with M-x timeclock-change.

Once you’ve collected data from a number of time intervals, you can use M-x timeclock-workday-remaining to see how much time is left to work today (assuming a typical average of 8 hours a day), and M-x timeclock-when-to-leave which will calculate when you’re done.

If you want Emacs to display the amount of time left of your workday in the mode line, either customize the timeclock-mode-line-display variable and set its value to t, or invoke the M-x timeclock-mode-line-display command.

Terminating the current Emacs session might or might not mean that you have stopped working on the project and, by default, Emacs asks you. You can, however, customize the value of the variable timeclock-ask-before-exiting to nil to avoid the question; then, only an explicit M-x timeclock-out or M-x timeclock-change will tell Emacs that the current interval is over.

The timeclock functions work by accumulating the data in a file called ~/.emacs.d/timelog. You can specify a different name for this file by customizing the variable timeclock-file. If you edit the timeclock file manually, or if you change the value of any of timeclock’s customizable variables, you should run the command M-x timeclock-reread-log to update the data in Emacs from the file.