From: Leo <sdl.web@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: [appt] allow specifying warning time in diary
Date: Wed, 08 Sep 2010 21:38:58 +0100 [thread overview]
Message-ID: <m1vd6g9di5.fsf@cam.ac.uk> (raw)
In-Reply-To: m1y6bcz3nc.fsf@cam.ac.uk
On 2010-09-08 15:55 +0100, Leo wrote:
> Thanks for the interest. The previous patch doesn't take into account of
> non-zero time-beg. This one fixes it and is simpler.
Sorry, found two bugs (one is typo).
So I made a test diary file as follows:
8 Sep 2010 23:00 test1 (no)
8 Sep 2010 23:00 #20 test2 (yes)
8 Sep 2010
23:00 # xyz1 (no)
23:00#20 xyz2 (yes)
23:00 #1.2 xyz3 (no)
23:59 #-1 xyz4 (yes)
no = warntime is not set
yes = warntime is set
The renewed patch works with the test file.
Modified lisp/calendar/appt.el
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index fd15093..b590290 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -273,6 +273,12 @@ for a warning to be issued. The format of the time can be either
Thursday
11:45am Lunch meeting.
+Optionally you can specify a warning time (in minutes) for an
+entry following the time, for example:
+
+ Thursday
+ 11:45am #20 Lunch meeting.
+
Appointments are checked every `appt-display-interval' minutes.
The following variables control appointment notification:
@@ -579,20 +585,30 @@ appointment package (if it is not already active)."
(calendar-current-date) (caar entry-list)))
(setq time-string (cadr (car entry-list)))
(while (string-match appt-time-regexp time-string)
- (let* ((beg (match-beginning 0))
+ (let* ((time-beg (match-beginning 0))
+ (time-end (match-end 0))
;; Get just the time for this appointment.
(only-time (match-string 0 time-string))
+ (warntime
+ (when (eq time-end
+ (string-match
+ "[ \t]*#\\([-+]?[0-9]+\\)[ \t]+"
+ time-string time-end))
+ (prog1 (string-to-number
+ (match-string 1 time-string))
+ (setq time-string (replace-match
+ " " nil nil time-string)))))
;; Find the end of this appointment
;; (the start of the next).
(end (string-match
(concat "\n[ \t]*" appt-time-regexp)
- time-string
- (match-end 0)))
+ time-string time-end))
;; Get the whole string for this appointment.
(appt-time-string
- (substring time-string beg end))
+ (substring time-string time-beg end))
(appt-time (list (appt-convert-time only-time)))
- (time-msg (list appt-time appt-time-string)))
+ (time-msg (list appt-time appt-time-string
+ nil warntime)))
;; Add this appointment to appt-time-msg-list.
(setq appt-time-msg-list
(nconc appt-time-msg-list (list time-msg))
next prev parent reply other threads:[~2010-09-08 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-08 8:54 [appt] allow specifying warning time in diary Leo
2010-09-08 9:29 ` Andreas Schwab
2010-09-08 9:48 ` Leo
2010-09-08 14:34 ` Stefan Monnier
2010-09-08 14:55 ` Leo
2010-09-08 20:38 ` Leo [this message]
2010-09-09 8:54 ` Daniel Pittman
2010-09-10 11:11 ` Leo
2010-09-14 0:22 ` Glenn Morris
2010-09-25 13:21 ` Leo
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1vd6g9di5.fsf@cam.ac.uk \
--to=sdl.web@gmail.com \
--cc=emacs-devel@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.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).