Gmane
Picon Favicon
From: Andrew J. Korty <ajk <at> iu.edu>
Subject: [PATCH] Apply patch for hour/minute repeater support
Newsgroups: gmane.emacs.orgmode
Date: 2010-09-14 17:06:39 GMT (1 year, 35 weeks, 5 days, 13 hours and 20 minutes ago)
This patch adds hour and minute granularity to repeaters.  Let me know 
if there's interest in incorporating it, and I'll start the FSF 
paperwork process.

Andrew Korty

---
 doc/org.texi       |    4 ++--
 lisp/org-agenda.el |    2 +-
 lisp/org.el        |   27 +++++++++++++++------------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index d6ea141..e9ede5a 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5006,8 +5006,8 @@ plain timestamp will be shown exactly on that date.
 @cindex timestamp, with repeater interval
 A timestamp may contain a @emph{repeater interval}, indicating that it
 applies not only on the given date, but again and again after a certain
-interval of N days (d), weeks (w), months (m), or years (y).  The
-following will show up in the agenda every Wednesday:
+interval of N minutes(M), hours(H), days (d), weeks (w), months (m), or
+years (y).  The following will show up in the agenda every Wednesday:

 @example
 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9f94fa6..176c8f0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4385,7 +4385,7 @@ the documentation of `org-diary'."
 	      (apply 'encode-time  ; DATE bound by calendar
 		     (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
 	     1 11))
-	   "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
+	   "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[MHdwmy]>\\)"
 	   "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
 	 marker hdmarker deadlinep scheduledp clockp closedp inactivep
 	 donep tmp priority category ee txt timestr tags b0 b3 e3 head
diff --git a/lisp/org.el b/lisp/org.el
index 70dd482..ace8291 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -621,7 +621,7 @@ An entry can be toggled between QUOTE and normal with
   :type 'string)

 (defconst org-repeat-re
-  "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*?\\([.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)"
+  "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*?\\([.+]?\\+[0-9]+[MHdwmy]\\(/[0-9]+[dwmy]\\)?\\)"
   "Regular expression for specifying repeated events.
 After a match, group 1 contains the repeat expression.")

@@ -11392,7 +11392,8 @@ This function is run automatically after each state change to a DONE state."
 	 (aa (assoc last-state org-todo-kwd-alist))
 	 (interpret (nth 1 aa))
 	 (head (nth 2 aa))
-	 (whata '(("d" . day) ("m" . month) ("y" . year)))
+	 (whata '(("M" . minute) ("H" . hour) ("d" . day) ("m" . month)
+                  ("y" . year)))
 	 (msg "Entry repeats: ")
 	 (org-log-done nil)
 	 (org-todo-log-states nil)
@@ -11429,7 +11430,7 @@ This function is run automatically after each state change to a DONE state."
 	(setq type (if (match-end 1) org-scheduled-string
 		     (if (match-end 3) org-deadline-string "Plain:"))
 	      ts (match-string (if (match-end 2) 2 (if (match-end 4) 4 0))))
-	(when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)
+	(when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([MHdwmy]\\)" ts)
 	  (setq	n (string-to-number (match-string 2 ts))
 		what (match-string 3 ts))
 	  (if (equal what "w") (setq n (* n 7) what "d"))
@@ -11438,13 +11439,15 @@ This function is run automatically after each state change to a DONE state."
 	    (setq time (save-match-data (org-time-string-to-time ts)))
 	    (cond
 	     ((equal (match-string 1 ts) ".")
-	      ;; Shift starting date to today
+	      ;; Shift starting date to now
 	      (org-timestamp-change
-	       (- (time-to-days (current-time)) (time-to-days time))
-	       'day))
+               (truncate (/ (- (time-to-seconds (current-time))
+                               (time-to-seconds time)) 60))
+	       'minute))
 	     ((equal (match-string 1 ts) "+")
 	      (while (or (= nshift 0)
-			 (<= (time-to-days time) (time-to-days (current-time))))
+			 (<= (time-to-seconds time)
+                             (time-to-seconds (current-time))))
 		(when (= (incf nshift) nshiftmax)
 		  (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today.  Continue? " nshift))
 		      (error "Abort")))
@@ -11456,7 +11459,7 @@ This function is run automatically after each state change to a DONE state."
 	      ;; rematch, so that we have everything in place for the real shift
 	      (org-at-timestamp-p t)
 	      (setq ts (match-string 1))
-	      (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts))))
+	      (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([MHdwmy]\\)" ts))))
 	  (org-timestamp-change n (cdr (assoc what whata)))
 	  (setq msg (concat msg type " " org-last-changed-timestamp " "))))
       (setq org-log-post-message msg)
@@ -14687,7 +14690,7 @@ The command returns the inserted time stamp."
 	 t1 w1 with-hm tf time str w2 (off 0))
     (save-match-data
       (setq t1 (org-parse-time-string ts t))
-      (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)?\\'" ts)
+      (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\(
[.+]?\\+[0-9]+[MHdwmy]\\(/[0-9]+[dwmy]\\)?\\)?\\'" ts)
 	  (setq off (- (match-end 0) (match-beginning 0)))))
     (setq end (- end off))
     (setq w1 (- end beg)
@@ -15177,8 +15180,8 @@ With prefix ARG, change that many days."
 (defun org-timestamp-change (n &optional what updown)
   "Change the date in the time stamp at point.
 The date will be changed by N times WHAT.  WHAT can be `day', `month',
-`year', `minute', `second'.  If WHAT is not given, the cursor position
-in the timestamp determines what will be changed."
+`year', `hour', `minute', `second'.  If WHAT is not given, the cursor
+position in the timestamp determines what will be changed."
   (let ((pos (point))
 	with-hm inactive
 	(dm (max (nth 1 org-time-stamp-rounding-minutes) 1))
@@ -15199,7 +15202,7 @@ in the timestamp determines what will be changed."
 	    ts (match-string 0))
       (replace-match "")
       (if (string-match
-	   "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)*\\)[]>]"
+	   "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[HMdwmy]\\(/[0-9]+[dwmy]\\)?\\)*\\)[]>]"
 	   ts)
 	  (setq extra (match-string 1 ts)))
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
-- 
1.7.2.3

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode <at> gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode