emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Task time limit


From: Bastien Guerry
Subject: Re: [Orgmode] Task time limit
Date: Sun, 10 Feb 2008 18:57:11 +0000
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux)

"Sebastjan Trepca" <address@hidden> writes:

> I finally got time to try this code :)

This is just 84 days old :)

> Copied into my .emacs file, changed the time to 1 minute, clocked in a
> task, waited a minute and nothing happened :)

Are you activating appointments with (appt-activate) somewhere?  
What is the output of M-x appt-delete RET ?

Maybe you can try with a more realistic value of 20 minutes and check if
the appt appears somewhere (with-x appt-delete RET)

BTW, here is the last version I use, letting you to delete
"appointments" if you clock out (only in the org-mode buffer):

;; Make sure you have a sensible value for `appt-message-warning-time'
(defvar bzg-org-clock-in-appt-delay 100
  "Number of minutes for setting an appointment by clocking-in")

(defun bzg-org-clock-in-add-appt (&optional n)
  "Add an appointment for the Org entry at point in N minutes."
  (interactive)
  (save-excursion
    (org-back-to-heading t)
    (looking-at org-complex-heading-regexp)
    (let* ((msg (match-string-no-properties 4))
           (ct-time (decode-time))
           (appt-min (+ (cadr ct-time) 
                        (or n bzg-org-clock-in-appt-delay)))
           (appt-time ; define the time for the appointment
            (progn (setf (cadr ct-time) appt-min) ct-time)))
      (appt-add (format-time-string  
                 "%H:%M" (apply 'encode-time appt-time)) msg)
      (if (interactive-p) (message "New appointment for %s" msg)))))

(defadvice org-clock-in (after org-clock-in-add-appt activate)
  "Add an appointment when clocking a task in."
  (bzg-org-clock-in-add-appt))

(defun bzg-org-clock-out-delete-appt nil
  "When clocking out, delete any associated appointment."
  (interactive)
  (save-excursion
    (org-back-to-heading t)
    (looking-at org-complex-heading-regexp)
    (let* ((msg (match-string-no-properties 4)))
      (setq appt-time-msg-list
            (delete nil 
                    (mapcar 
                     (lambda (appt)
                       (if (not (string-match (regexp-quote msg) 
                                              (cadr appt))) appt))
                     appt-time-msg-list)))
      (appt-check))))

(defadvice org-clock-out (before org-clock-out-delete-appt activate)
  "Delete an appointment when clocking a task out."
  (bzg-org-clock-out-delete-appt))

-- 
Bastien




reply via email to

[Prev in Thread] Current Thread [Next in Thread]