From: Carsten Dominik <dominik@science.uva.nl>
To: Bernt Hansen <bernt@norang.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-mode and appointments
Date: Tue, 26 Feb 2008 17:06:21 +0100 [thread overview]
Message-ID: <AE0668E5-D22D-4936-A1C2-1F308DEFB64F@science.uva.nl> (raw)
In-Reply-To: <87ejb063bz.fsf@gollum.intra.norang.ca>
Hi Bernt,
Bastien is quite busy, so let me replay
On Feb 26, 2008, at 12:09 AM, Bernt Hansen wrote:
> 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 "<f9> 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.
In this case, setting `appt-time-msg-list' to nil before calling my-
org-agenda-to-appt
should be fine. BTW, org.el contains `org-agenda-to-appt' which is a
very slightly improved
version of this function, so no need to keep it in .emacs.
> - [ ] 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.
Do
(let ((org-deadline-warning-days 0))
around the call. Actually, yes, this should be part f org-agenda-to-
appt,
I will put it in. But for now you can do it in your update function.
There is a bug in the documentation of org-deadline-warning-days saying
that only negative numbers will be enforced. In fact, 0 will also
be enforced.
> - [ ] If I leave Emacs running overnight is there a good way to reset
> the appointment list at midnight?
Take a look at the function `run-at-time'. This could be set up
in .emacs, better to not
execute this each time you update your appointment list.
So to summarize, this is really all you need in .emacs:
;; Get appointments for today
(global-set-key (kbd "<f9> a") 'my-org-agenda-to-appt)
(defun my-org-agenda-to-appt ()
(interactive)
(let ((org-deadline-warning-days 0)) ;; will be automatic in org
5.23
(org-agenda-to-appt)))
(my-org-agenda-to-appt)
(appt-activate t)
(run-at-time "24:01" nil 'my-org-agenda-to-appt)
next prev parent reply other threads:[~2008-02-26 16:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 23:09 org-mode and appointments Bernt Hansen
2008-02-26 16:06 ` Carsten Dominik [this message]
2008-02-26 16:09 ` Carsten Dominik
2008-02-26 16:14 ` Bernt Hansen
2008-02-27 1:01 ` Russell Adams
2008-02-28 0:55 ` Russell Adams
2008-02-28 1:04 ` Bernt Hansen
2008-02-28 1:06 ` Bernt Hansen
2008-02-28 22:38 ` Russell Adams
2008-02-28 23:17 ` Nick Dokos
2008-03-02 10:13 ` Russell Adams
2008-03-02 17:51 ` Richard G Riley
2008-03-02 19:33 ` Russell Adams
2008-03-03 1:31 ` Bastien
2008-02-26 16:19 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AE0668E5-D22D-4936-A1C2-1F308DEFB64F@science.uva.nl \
--to=dominik@science.uva.nl \
--cc=bernt@norang.ca \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).