Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate a task in org-mode upon clocking out?

Tags:

emacs

org-mode

I use the Emacs org-mode for clocking in and out of work and I would like to automate some specific tasks every time I clock out. For example, I have a shell script to push repositories to a version control system and I would like to do this automatically when I'm finished working (i.e. when I clock out). This could be extended to every time you clock in as well (e.x. whenever I clock in I want to open my e-mail client automatically).

Any ideas on how to write Emacs lisp in my .emacs file to accomplish this?

like image 306
Stefan Avey Avatar asked May 14 '14 13:05

Stefan Avey


People also ask

How do I track time in tasks in org-mode?

So, you want to track time in tasks in Org-mode? First, you need a task, any headline can be clocked in to. In order to clock in to a task, hit C-c C-x C-i, and hit C-c C-x C-o to clock back out. When you clock in to a headline a drawer appears, a drawer looks like this: You can expand and collapse the drawer with TAB.

How do I clock in/out of a task?

In order to clock in to a task, hit C-c C-x C-i, and hit C-c C-x C-o to clock back out. When you clock in to a headline a drawer appears, a drawer looks like this:

How do I manually change the clock in org-mode?

These are taken straight from the org-mode clock-table documentation . You can use the S-<left>/<right> keys on the :block line to shift the time interval. Sometimes you need to manually make changes to a clock, because it's wrong, or you forgot to clock in, or your cat jumped on to your keyboard and clocked in to an embarrassing task.

How does Org show the current clocking time?

While the clock is running, Org shows the current clocking time in the mode line, along with the title of the task. The clock time shown is all time ever clocked for this task and its children. If the task has an effort estimate (see Effort Estimates ), the mode line displays the current clocking time against it 74.


1 Answers

You could write a function that does what you need to have done, and add it to org-clock-out-hook. Perhaps something like this (untested):

(defun my-on-org-clock-out ()
  (shell-command "commit-everything.sh"))

(add-hook 'org-clock-out-hook 'my-on-org-clock-out)

Likewise, there is a hook called org-clock-in-hook.

like image 179
legoscia Avatar answered Oct 19 '22 20:10

legoscia