emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Apply patch for hour/minute repeater support
@ 2010-09-14 17:06 Andrew J. Korty
  2010-09-15 16:10 ` Martin Pohlack
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrew J. Korty @ 2010-09-14 17:06 UTC (permalink / raw)
  To: emacs-orgmode

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

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

end of thread, other threads:[~2010-10-24 16:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14 17:06 [PATCH] Apply patch for hour/minute repeater support Andrew J. Korty
2010-09-15 16:10 ` Martin Pohlack
2010-09-15 23:58   ` Andrew J. Korty
2010-09-21 12:46 ` Carsten Dominik
2010-09-22  4:47   ` Manish
2010-09-22  7:06     ` Nick Dokos
2010-10-24 16:39 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).