From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.devel Subject: Re: [appt] allow specifying warning time in diary Date: Wed, 08 Sep 2010 15:55:03 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283957717 23293 80.91.229.12 (8 Sep 2010 14:55:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Sep 2010 14:55:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 08 16:55:16 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OtM3Q-0006rH-96 for ged-emacs-devel@m.gmane.org; Wed, 08 Sep 2010 16:55:16 +0200 Original-Received: from localhost ([127.0.0.1]:46796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OtM3P-0002Yr-Oz for ged-emacs-devel@m.gmane.org; Wed, 08 Sep 2010 10:55:15 -0400 Original-Received: from [140.186.70.92] (port=33313 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OtM3H-0002Xd-Sv for emacs-devel@gnu.org; Wed, 08 Sep 2010 10:55:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OtM3G-00059D-Fu for emacs-devel@gnu.org; Wed, 08 Sep 2010 10:55:07 -0400 Original-Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]:36514) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OtM3G-00058v-7M for emacs-devel@gnu.org; Wed, 08 Sep 2010 10:55:06 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Original-Received: from cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:53234 helo=Victoria.local) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1OtM3E-0002bu-iH (Exim 4.72) (return-path ); Wed, 08 Sep 2010 15:55:04 +0100 In-Reply-To: (Stefan Monnier's message of "Wed, 08 Sep 2010 16:34:52 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (Mac OS X 10.6.4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:129786 Archived-At: On 2010-09-08 15:34 +0100, Stefan Monnier wrote: > Looks good, thank you; can someone install it? > > > Stefan Thanks for the interest. The previous patch doesn't take into account of non-zero time-beg. This one fixes it and is simpler. Modified lisp/calendar/appt.el diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index fd15093..af60d78 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,9 +585,19 @@ 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 (= 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 @@ -590,9 +606,10 @@ appointment package (if it is not already active)." (match-end 0))) ;; 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)) Leo