(defun my-timeclock-check ()
(interactive)
(setq current-action (or (nth 0 timeclock-last-event) "o")
current-project (or (nth 2 timeclock-last-event) "o")
directory-match nil)
(dolist (directory my-projects)
(let ((current-key (car directory))
(current-value (cdr directory)))
(if (string-match current-value default-directory)
(progn
(setq directory-match t)
(if (string-match current-action "i")
(if (not (string-match current-key current-project))
(progn
(timeclock-change nil current-key)
(message "Changed to the %s project." current-key))
(if (y-or-n-p (concat "Already clocked in to the "
current-key " project, clock out? "))
(progn
(timeclock-out)
(timeclock-reread-log))))
(progn
(timeclock-in current-key current-key)
(message "Clocked in to the %s project." current-key)))))))
(if (not directory-match)
(if (string-match current-action "i")
(progn
(timeclock-out)
(timeclock-reread-log)
(message "Clocked out of the %s project." current-project))
(message "No action needed."))))
(provide 'my-timeclock)
:-- my-timeclock.el All (1,0) (Emacs-Lisp/lah)