Commit 0cb7f2c0 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(appt-time-regexp): New var.

(appt-add, appt-make-list): Use it.
(appt-convert-time): Clean up.
parent 3307a4fa
2005-10-04 Stefan Monnier <monnier@iro.umontreal.ca>
* calendar/appt.el (appt-time-regexp): New var.
(appt-add, appt-make-list): Use it.
(appt-convert-time): Clean up.
* textmodes/tex-mode.el (tex-font-lock-syntactic-face-function):
Don't set any syntax-table property here.
(tex-font-lock-verb): New function. Do it here.
(tex-font-lock-syntactic-keywords): Use it.
2005-10-04 Richard M. Stallman <rms@gnu.org> 2005-10-04 Richard M. Stallman <rms@gnu.org>
   
* wid-edit.el (widget-file-complete): Get the widget start point * wid-edit.el (widget-file-complete): Get the widget start point
...@@ -12,7 +23,7 @@ ...@@ -12,7 +23,7 @@
Call ispell-maybe-find-aspell-dictionaries. Call ispell-maybe-find-aspell-dictionaries.
(ispell-accept-buffer-local-defs): (ispell-accept-buffer-local-defs):
Don't call ispell-maybe-find-aspell-dictionaries Don't call ispell-maybe-find-aspell-dictionaries
2005-10-04 Richard M. Stallman <rms@gnu.org> 2005-10-04 Richard M. Stallman <rms@gnu.org>
   
* iswitchb.el (iswitchb-buffer-ignore): Label it risky. * iswitchb.el (iswitchb-buffer-ignore): Label it risky.
...@@ -74,7 +85,6 @@ ...@@ -74,7 +85,6 @@
   
* ido.el (ido-mode): Use custom-initialize-set. * ido.el (ido-mode): Use custom-initialize-set.
   
>>>>>>> 1.8276
2005-10-02 Richard M. Stallman <rms@gnu.org> 2005-10-02 Richard M. Stallman <rms@gnu.org>
   
* progmodes/ebnf2ps.el (ebnf-eps-production-list): * progmodes/ebnf2ps.el (ebnf-eps-production-list):
......
...@@ -195,7 +195,7 @@ STRING is the description of the appointment. ...@@ -195,7 +195,7 @@ STRING is the description of the appointment.
FLAG, if non-nil, says that the element was made with `appt-add' FLAG, if non-nil, says that the element was made with `appt-add'
so calling `appt-make-list' again should preserve it.") so calling `appt-make-list' again should preserve it.")
(defconst appt-max-time 1439 (defconst appt-max-time (1- (* 24 60))
"11:59pm in minutes - number of minutes in a day minus 1.") "11:59pm in minutes - number of minutes in a day minus 1.")
(defvar appt-mode-string nil (defvar appt-mode-string nil
...@@ -484,13 +484,15 @@ Usually just deletes the appointment buffer." ...@@ -484,13 +484,15 @@ Usually just deletes the appointment buffer."
lowest-window w))))) lowest-window w)))))
(select-window lowest-window))) (select-window lowest-window)))
(defconst appt-time-regexp
"[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?")
;;;###autoload ;;;###autoload
(defun appt-add (new-appt-time new-appt-msg) (defun appt-add (new-appt-time new-appt-msg)
"Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG. "Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG.
The time should be in either 24 hour format or am/pm format." The time should be in either 24 hour format or am/pm format."
(interactive "sTime (hh:mm[am/pm]): \nsMessage: ") (interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
(unless (string-match "[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?" (unless (string-match appt-time-regexp new-appt-time)
new-appt-time)
(error "Unacceptable time-string")) (error "Unacceptable time-string"))
(let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) (let* ((appt-time-string (concat new-appt-time " " new-appt-msg))
(appt-time (list (appt-convert-time new-appt-time))) (appt-time (list (appt-convert-time new-appt-time)))
...@@ -577,16 +579,14 @@ appointment package (if it is not already active)." ...@@ -577,16 +579,14 @@ appointment package (if it is not already active)."
(calendar-date-equal (calendar-date-equal
(calendar-current-date) (car (car entry-list)))) (calendar-current-date) (car (car entry-list))))
(let ((time-string (cadr (car entry-list)))) (let ((time-string (cadr (car entry-list))))
(while (string-match (while (string-match appt-time-regexp time-string)
"\\([0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?\\).*"
time-string)
(let* ((beg (match-beginning 0)) (let* ((beg (match-beginning 0))
;; Get just the time for this appointment. ;; Get just the time for this appointment.
(only-time (match-string 1 time-string)) (only-time (match-string 0 time-string))
;; Find the end of this appointment ;; Find the end of this appointment
;; (the start of the next). ;; (the start of the next).
(end (string-match (end (string-match
"^[ \t]*[0-9]?[0-9][:.][0-9][0-9]\\(am\\|pm\\)?" (concat "\n[ \t]*" appt-time-regexp)
time-string time-string
(match-end 0))) (match-end 0)))
;; Get the whole string for this appointment. ;; Get the whole string for this appointment.
...@@ -633,31 +633,23 @@ APPT-LIST is a list of the same format as `appt-time-msg-list'." ...@@ -633,31 +633,23 @@ APPT-LIST is a list of the same format as `appt-time-msg-list'."
"Convert hour:min[am/pm] format to minutes from midnight. "Convert hour:min[am/pm] format to minutes from midnight.
A period (.) can be used instead of a colon (:) to separate the A period (.) can be used instead of a colon (:) to separate the
hour and minute parts." hour and minute parts."
(let ((conv-time 0) ;; Formats that should be accepted:
(hr 0) ;; 10:00 10.00 10h00 10h 10am 10:00am 10.00am
(min 0)) (let ((min (if (string-match "[h:.]\\([0-9][0-9]\\)" time2conv)
(string-to-number (match-string 1 time2conv))
(string-match "[:.]\\([0-9][0-9]\\)" time2conv) 0))
(setq min (string-to-number (hr (if (string-match "[0-9]*[0-9]" time2conv)
(match-string 1 time2conv))) (string-to-number (match-string 0 time2conv))
0)))
(string-match "[0-9]?[0-9][:.]" time2conv)
(setq hr (string-to-number
(match-string 0 time2conv)))
;; convert the time appointment time into 24 hour time ;; convert the time appointment time into 24 hour time
(cond ((and (string-match "pm" time2conv) (< hr 12)) (cond ((and (string-match "pm" time2conv) (< hr 12))
(setq hr (+ 12 hr))) (setq hr (+ 12 hr)))
((and (string-match "am" time2conv) (= hr 12)) ((and (string-match "am" time2conv) (= hr 12))
(setq hr 0))) (setq hr 0)))
;; convert the actual time ;; convert the actual time into minutes.
;; into minutes for comparison (+ (* hr 60) min)))
;; against the actual time.
(setq conv-time (+ (* hr 60) min))
conv-time))
(defun appt-update-list () (defun appt-update-list ()
...@@ -719,5 +711,5 @@ ARG is positive, otherwise off." ...@@ -719,5 +711,5 @@ ARG is positive, otherwise off."
(provide 'appt) (provide 'appt)
;;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347 ;; arch-tag: bf5791c4-8921-499e-a26f-772b1788d347
;;; appt.el ends here ;;; appt.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment