From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: org-mode and appointments Date: Mon, 25 Feb 2008 18:09:20 -0500 Message-ID: <87ejb063bz.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JTmRv-0000nm-Sp for emacs-orgmode@gnu.org; Mon, 25 Feb 2008 18:09:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JTmRv-0000nL-23 for emacs-orgmode@gnu.org; Mon, 25 Feb 2008 18:09:31 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JTmRu-0000nH-Np for emacs-orgmode@gnu.org; Mon, 25 Feb 2008 18:09:30 -0500 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JTmRu-0007Wg-4n for emacs-orgmode@gnu.org; Mon, 25 Feb 2008 18:09:30 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JTmRr-0002S3-Gb for emacs-orgmode@gnu.org; Mon, 25 Feb 2008 23:09:27 +0000 Received: from cpe000102d0fe75-cm0012256ecbde.cpe.net.cable.rogers.com ([99.239.148.180]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Feb 2008 23:09:27 +0000 Received: from bernt by cpe000102d0fe75-cm0012256ecbde.cpe.net.cable.rogers.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Feb 2008 23:09:27 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Bastien, I'm using your function for creating appointments: ,----[ my-org-agenda-to-appt in .emacs ] | ;; Make appt aware of appointments from the agenda | (defun my-org-agenda-to-appt (&optional filter) | "Activate appointments found in `org-agenda-files'. | When prefixed, prompt for a regular expression and use it as a | filter: only add entries if they match this regular expression. | | FILTER can be a string. In this case, use this string as a | regular expression to filter results. | | FILTER can also be an alist, with the car of each cell being | either 'headline or 'category. For example: | | '((headline \"IMPORTANT\") | (category \"Work\")) | | will only add headlines containing IMPORTANT or headlines | belonging to the category \"Work\"." | (interactive "P") | (require 'org) | (require 'calendar) | (if (equal filter '(4)) | (setq filter (read-from-minibuffer "Regexp filter: "))) | (let* ((cnt 0) ; count added events | (today (org-date-to-gregorian | (time-to-days (current-time)))) | (files org-agenda-files) entries file) | ;; Get all entries which may contain an appt | (while (setq file (pop files)) | (setq entries | (append entries | (org-agenda-get-day-entries | file today | :timestamp :scheduled :deadline)))) | (setq entries (delq nil entries)) | ;; Map thru entries and find if they pass thru the filter | (mapc | (lambda(x) | (let* ((evt (org-trim (get-text-property 1 'txt x))) | (cat (get-text-property 1 'org-category x)) | (tod (get-text-property 1 'time-of-day x)) | (ok (or (null filter) | (and (stringp filter) (string-match filter evt)) | (and (listp filter) | (or (string-match | (cadr (assoc 'category filter)) cat) | (string-match | (cadr (assoc 'headline filter)) evt)))))) | ;; FIXME Shall we remove text-properties for the appt text? | ;; (setq evt (set-text-properties 0 (length evt) nil evt)) | (when (and ok tod) | (setq tod (number-to-string tod) | tod (when (string-match | "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod) | (concat (match-string 1 tod) ":" | (match-string 2 tod)))) | (appt-add tod evt) | (setq cnt (1+ cnt))))) entries) | (message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))) `---- and this has been working pretty well for me. I really appreciate you posting this on the list (a long time ago :) ) I have a function key binding to rerun this function when I add new appointments for today. ,----[ Activate the appointments in .emacs ] | (global-set-key (kbd " a") 'my-org-agenda-to-appt) | ;; Get appointments for today | (my-org-agenda-to-appt) | (appt-activate t) `---- I have the following wishlist items for this function but don't currently have the lisp skills to fix it. - [ ] Clear the appointment list when rerunning the my-org-agenda-to-appt If I move an appointment to anther day and use f9-a the old appointment reminder is still there and bugs me when the time rolls around. I only use org appointment entries so clearing the list should be trivial. I don't use diary entries anymore. - [ ] Future deadlines are reported for today. I have an installation deadline at 8PM on Thursday. Since it's a deadline it shows up in my agenda today with a 3 day warning... and my-org-agenda-to-appt picks this up and makes an appointment for today -- which is incorrect. I don't need an appointment for this until Thursday. - [ ] If I leave Emacs running overnight is there a good way to reset the appointment list at midnight? What do I need to do to this function to fix these issues? Any input is greatly appreciated :) Regards, Bernt