unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* appt: allowing hh.mm for time
@ 2003-12-04 15:00 D Goel
  2003-12-05 20:44 ` Glenn Morris
  0 siblings, 1 reply; 7+ messages in thread
From: D Goel @ 2003-12-04 15:00 UTC (permalink / raw)


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)))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-04 15:00 appt: allowing hh.mm for time D Goel
@ 2003-12-05 20:44 ` Glenn Morris
  2003-12-05 21:18   ` D Goel
  0 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2003-12-05 20:44 UTC (permalink / raw)
  Cc: emacs-devel

D Goel wrote:

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

RMS asked me to look after calendar-related matters, so I should
probably comment on this. The idea (allowing times of the format
"11.00" as well as "11:00") is fine, but in practice it's more
complicated than your patch. For example, taking a quick look at
diary-lib.el, I see many places where a ":" separator is assumed (the
syntax table for the diary buffer, etc). So if you want to make this
change consistent for the calendar/diary you will have to deal with
all of those places. The ":" format may very well be assumed in other
files in lisp/calendar AFAIK. You may find making this change is more
trouble than it's worth to you. :(

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-05 20:44 ` Glenn Morris
@ 2003-12-05 21:18   ` D Goel
  2003-12-05 23:05     ` Andreas Schwab
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: D Goel @ 2003-12-05 21:18 UTC (permalink / raw)


Glenn Morris <gmorris+emacs@ast.cam.ac.uk> writes:

> D Goel wrote:
>

> change consistent for the calendar/diary you will have to deal with
> all of those places. The ":" format may very well be assumed in other
> files in lisp/calendar AFAIK. You may find making this change is more
> trouble than it's worth to you. :(



Glenn

Thanks for pointing this out.  I just looked at calendar.el and
diary.el, and indeed, there are some places there that time entries
are parsed, and changes should be made there too. I think there's onle
one or two places in each file that we need to replace : by
"\\(?::\\|\\.\\)", so I am still interested in making the change.

(I am no longer thinking of the customizable
"appt-time-separator". )... we could just replace . by \\|( . \\| :
\\) whenver time is parsed.


Please let me know what you think of it. If you think it is worth
making the change, I will do it, else not.


I do think it is worth it since I (others?) miss appointments (I did
try to get myself used to aa:bb, but still accidentally fill out time
as aa.bb) and I still find hand-editing diary the easiest way to do
it.

If you don't think it is worth it, I guess I will write a private
function that searches the diary for timestrings a.bb and prompts
replacing them, and add that function to my file-save-hook or such.




DG                                 http://gnufans.net/~deego/
--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-05 21:18   ` D Goel
@ 2003-12-05 23:05     ` Andreas Schwab
  2003-12-06  0:58     ` Thien-Thi Nguyen
  2003-12-06 21:54     ` Glenn Morris
  2 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2003-12-05 23:05 UTC (permalink / raw)
  Cc: emacs-devel

D Goel <deego@gnufans.org> writes:

> Thanks for pointing this out.  I just looked at calendar.el and
> diary.el, and indeed, there are some places there that time entries
> are parsed, and changes should be made there too. I think there's onle
> one or two places in each file that we need to replace : by
> "\\(?::\\|\\.\\)", so I am still interested in making the change.

"[:.]" is a much simpler regexp for this.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-05 21:18   ` D Goel
  2003-12-05 23:05     ` Andreas Schwab
@ 2003-12-06  0:58     ` Thien-Thi Nguyen
  2003-12-06 21:54     ` Glenn Morris
  2 siblings, 0 replies; 7+ messages in thread
From: Thien-Thi Nguyen @ 2003-12-06  0:58 UTC (permalink / raw)
  Cc: emacs-devel

D Goel <deego@gnufans.org> writes:

   If you don't think it is worth it

it is worth it.  hh:mm is not universal.  hh.mm is also widely used.

thi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-05 21:18   ` D Goel
  2003-12-05 23:05     ` Andreas Schwab
  2003-12-06  0:58     ` Thien-Thi Nguyen
@ 2003-12-06 21:54     ` Glenn Morris
  2003-12-08 15:35       ` D. Goel
  2 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2003-12-06 21:54 UTC (permalink / raw)
  Cc: emacs-devel

D Goel wrote:

> Please let me know what you think of it. If you think it is worth
> making the change, I will do it, else not.

Please by all means make this change. I should learn to be less
pessimistic! 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: appt: allowing hh.mm for time
  2003-12-06 21:54     ` Glenn Morris
@ 2003-12-08 15:35       ` D. Goel
  0 siblings, 0 replies; 7+ messages in thread
From: D. Goel @ 2003-12-08 15:35 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

Glenn Morris <gmorris+emacs@ast.cam.ac.uk> writes:

>
> Please by all means make this change. 

Glenn, 

 Andreas hinted it could be done with a much simper regexp: [:.].

Attached are all the changes and the ChangeLog. I went through all the
files in lisp/calendar/ and these are the only changes I think need to
be made. 



DG                                 http://gnufans.net/~deego/
--

[-- Attachment #2: patches.el-diff --]
[-- Type: application/octet-stream, Size: 1773 bytes --]

--- appt-original.el	Mon Dec  8 10:17:51 2003
+++ appt.el	Mon Dec  8 10:17:26 2003
@@ -437,7 +437,8 @@
 The time should be in either 24 hour format or am/pm format."
 
   (interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
-  (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time)
+  (if (string-match "[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?" 
+		    new-appt-time)
       nil
     (error "Unacceptable time-string"))
 
@@ -519,7 +520,7 @@
 			   (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\\)?\\).*"
+			  "\\([0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?\\).*"
 			  time-string)
 		    (let* ((beg (match-beginning 0))
 			   ;; Get just the time for this appointment.
@@ -527,7 +528,7 @@
 			   ;; 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\\)?"
+				 "^[ \t]*[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?"
 				 time-string
 				 (match-end 0)))
 			   ;; Get the whole string for this appointment.
@@ -586,17 +587,17 @@
 
 
 (defun appt-convert-time (time2conv)
-  "Convert hour:min[am/pm] format to minutes from midnight."
-
+  "Convert hour:min[am/pm] format to minutes from midnight.
+Also try to accpe the hour.min[am/pm] format."
   (let ((conv-time 0)
         (hr 0)
         (min 0))
 
-    (string-match ":\\([0-9][0-9]\\)" time2conv)
+    (string-match "[:.]\\([0-9][0-9]\\)" time2conv)
     (setq min (string-to-int
                (match-string 1 time2conv)))
 
-    (string-match "[0-9]?[0-9]:" time2conv)
+    (string-match "[0-9]?[0-9][:.]" time2conv)
     (setq hr (string-to-int
               (match-string 0 time2conv)))
 

[-- Attachment #3: diary-lib.el-diff --]
[-- Type: application/octet-stream, Size: 2669 bytes --]

--- diary-lib-original.el	Mon Dec  8 10:18:06 2003
+++ diary-lib.el	Mon Dec  8 10:17:01 2003
@@ -1099,12 +1099,15 @@
 (defun diary-entry-time (s)
   "Return time at the beginning of the string S as a military-style integer.
 For example, returns 1325 for 1:25pm.
-Returns `diary-unknown-time' (default value -9999) if no time is recognized.  The recognized forms are XXXX, X:XX, or
-XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm,
-or XX:XXPM."
+
+Returns `diary-unknown-time' (default value -9999) if no time is
+recognized.  The recognized forms are XXXX, X:XX, or
+XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam,
+XX:XXAM XX:XXpm, or XX:XXPM. We also try to accept time in the
+form XX[.XX][am/pm/AM/PM]]."
   (let ((case-fold-search nil))
     (cond ((string-match        ; Military time
-	    "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
+	    "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.]?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
 	   (+ (* 100 (string-to-int
 		      (substring s (match-beginning 1) (match-end 1))))
 	      (string-to-int (substring s (match-beginning 2) (match-end 2)))))
@@ -1116,7 +1119,7 @@
 	      (if (equal ?a (downcase (aref s (match-beginning 2))))
 		  0 1200)))
 	  ((string-match        ; Hour and minute  XX:XXam or XX:XXpm
-	    "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
+	    "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.][\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
 	   (+ (* 100 (% (string-to-int
 			   (substring s (match-beginning 1) (match-end 1)))
 			  12))
@@ -1764,7 +1767,7 @@
    '("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
    '("^Day.*omer.*$" . font-lock-builtin-face)
    '("^Parashat.*$" . font-lock-comment-face)
-   '("^[ \t]*[0-9]?[0-9]\\(:?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)?\\(-[0-9]?[0-9]\\(:?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)?\\)?"
+   '("^[ \t]*[0-9]?[0-9]\\([:.]?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)?\\(-[0-9]?[0-9]\\([:.]?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)?\\)?"
      . font-lock-variable-name-face))
   "Keywords to highlight in fancy diary display")
 
@@ -1855,7 +1858,7 @@
                  "?\\(" (regexp-quote islamic-diary-entry-symbol) "\\)")
          '(1 font-lock-reference-face))
         '(font-lock-diary-sexps . font-lock-keyword-face)
-        '("[0-9]?[0-9]\\(:?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)\\(-[0-9]?[0-9]\\(:?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)\\)?"
+        '("[0-9]?[0-9]\\([:.]?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)\\(-[0-9]?[0-9]\\([:.]?[0-9][0-9]\\)?\\(am\\|pm\\|AM\\|PM\\)\\)?"
           . font-lock-function-name-face)))
       "Forms to highlight in diary-mode")
 

[-- Attachment #4: changelog --]
[-- Type: application/octet-stream, Size: 295 bytes --]

2003-12-08  D Goel  <deego@gnufans.org>


	* diary-lib.el (diary-entry-time): Also accept time in the form
	XX[.XX][am/pm/AM/PM]. 
	(fancy-diary-font-lock-keywords): ditto.
	(diary-font-lock-keywords): ditto.
	* appt.el (appt-add): ditto.
	(appt-make-list): ditto.
	(appt-convert-time): ditto.


[-- Attachment #5: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-08 15:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-04 15:00 appt: allowing hh.mm for time D Goel
2003-12-05 20:44 ` Glenn Morris
2003-12-05 21:18   ` D Goel
2003-12-05 23:05     ` Andreas Schwab
2003-12-06  0:58     ` Thien-Thi Nguyen
2003-12-06 21:54     ` Glenn Morris
2003-12-08 15:35       ` D. Goel

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).