emacs-devel
[Top][All Lists]
Advanced

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

appt: allowing hh.mm for time


From: D Goel
Subject: appt: allowing hh.mm for time
Date: Thu, 04 Dec 2003 10:00:08 -0500
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)

hi

Thoguh diary does have interactive functions for adding appointments,
I like to hand-edit my diary file. 

I often add entries like 

2/3/2003: 11.00 dentist.

however, i often miss those appointments because appt.el doesn't
remind me because the correct format should have been 

2/3/2003: 11:00 dentist.


The patch below generalizes the time-format to allow 11.00 as well,
(and even makes it customizable.)

I would like to apply it to appt.el, may I?



DG                                 http://gnufans.net/
--

--- appt-original.el    Thu Dec  4 09:54:45 2003
+++ appt.el     Thu Dec  4 09:54:08 2003
@@ -165,6 +165,17 @@
   :type 'integer
   :group 'appt)
 
+
+(defcustom appt-time-separator "\\(?::\\|\\.\\)"
+  " Time is of the form hh(appt-time-separator)mm. 
+
+A regex which is either a character, like : or .  or or-ed characters. 
+The orring should begin with \\(?: so as not to consume match-string
+  expressions.  The default is : or .  "
+  :type 'string)
+
+   
+
 (defvar appt-buffer-name " *appt-buf*"
   "Name of the appointments buffer.")
 
@@ -519,7 +530,9 @@
                           (calendar-current-date) (car (car entry-list))))
                (let ((time-string (cadr (car entry-list))))
                  (while (string-match
-                         "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
+                         (concat "\\([0-9]?[0-9]"
+                                 appt-time-separator
+                                 "[0-9][0-9]\\(am\\|pm\\)?\\).*")
                          time-string)
                    (let* ((beg (match-beginning 0))
                           ;; Get just the time for this appointment.
@@ -527,7 +540,10 @@
                           ;; Find the end of this appointment
                           ;; (the start of the next).
                           (end (string-match
-                                "^[ \t]*[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?"
+                                (concat 
+                                 "^[ \t]*[0-9]?[0-9]" 
+                                 appt-time-separator
+                                 "[0-9][0-9]\\(am\\|pm\\)?")
                                 time-string
                                 (match-end 0)))
                           ;; Get the whole string for this appointment.
@@ -592,11 +608,13 @@
         (hr 0)
         (min 0))
 
-    (string-match ":\\([0-9][0-9]\\)" time2conv)
+    (string-match 
+     (concat appt-time-separator "\\([0-9][0-9]\\)")
+     time2conv)
     (setq min (string-to-int
                (match-string 1 time2conv)))
 
-    (string-match "[0-9]?[0-9]:" time2conv)
+    (string-match (concat "[0-9]?[0-9]" appt-time-separator) time2conv)
     (setq hr (string-to-int
               (match-string 0 time2conv)))
 





reply via email to

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