emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Support hour in repeated task cookie
@ 2012-03-27 21:22 Takafumi Arakaki
  2012-03-31 20:54 ` Takafumi Arakaki
  2012-04-20 14:57 ` Bastien
  0 siblings, 2 replies; 7+ messages in thread
From: Takafumi Arakaki @ 2012-03-27 21:22 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

Basically, this patch changes all occurrence of "[dwmy]" with
"[hdwmy]" and adds "("h" . hour)" to whata of org-auto-repeat-maybe.

I think it is better to have some constant to indicate "dwmy".  So,
this pull request is rather a proof-of-concept and a feature request.
I didn't try to do it by myself because I thought org developers might
have some preference to how to add this constant.  If somebody who can
commit the change can add a constant and introduce "h" for repeated
cookie, please do it.  If you think I should create another patch to
add the constant, please give me a name of the constant.   How should
we call "dwmy"?  "Time unit chars" or something like that?  If the
current patch is acceptable, it is fine for me.  Maybe you want to introduce
some constants afterward.

Best,
Takafumi

[-- Attachment #2: 0001-Support-hour-in-repeated-task-cookie.patch --]
[-- Type: text/x-patch, Size: 9463 bytes --]

From bd1a22fe245c5e2e33979b4b351bfb4564e83825 Mon Sep 17 00:00:00 2001
From: Takafumi Arakaki <aka.tkf@gmail.com>
Date: Tue, 27 Mar 2012 22:55:39 +0200
Subject: [PATCH 1/2] Support hour in repeated task cookie

Basically, this patch changes all occurrence of "[dwmy]" with
"[hdwmy]" and adds "("h" . hour)" to whata of org-auto-repeat-maybe.
---
 lisp/org.el |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 04c5c62..2981b0f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -683,7 +683,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)"
   "Regular expression for specifying repeated events.
 After a match, group 1 contains the repeat expression.")
 
@@ -7919,7 +7919,7 @@ and still retain the repeater to cover future instances of the task."
     (if (not (and (integerp n) (> n 0)))
 	(error "Invalid number of replications %s" n))
     (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift)))
-	     (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
+	     (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([hdwmy]\\)[ \t]*\\'"
 				shift)))
 	(error "Invalid shift specification %s" shift))
     (when doshift
@@ -7937,7 +7937,7 @@ and still retain the repeater to cover future instances of the task."
     (setq end (point))
     (setq template (buffer-substring beg end))
     (when (and doshift
-	       (string-match "<[^<>\n]+ [.+]?\\+[0-9]+[dwmy][^<>\n]*>" template))
+	       (string-match "<[^<>\n]+ [.+]?\\+[0-9]+[hdwmy][^<>\n]*>" template))
       (delete-region beg end)
       (setq end beg)
       (setq nmin 0 nmax (1+ nmax) n-no-remove nmax))
@@ -7968,7 +7968,7 @@ and still retain the repeater to cover future instances of the task."
 		(while (re-search-forward org-ts-regexp nil t)
 		  (save-excursion
 		    (goto-char (match-beginning 0))
-		    (if (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[dwmy]\\)")
+		    (if (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[hdwmy]\\)")
 			(delete-region (match-beginning 1) (match-end 1)))))))
 	    (setq task (buffer-string)))
 	  (insert task))
@@ -11870,7 +11870,7 @@ 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 '(("h" . hour) ("d" . day) ("m" . month) ("y" . year)))
 	 (msg "Entry repeats: ")
 	 (org-log-done nil)
 	 (org-todo-log-states nil)
@@ -11906,7 +11906,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]+\\)\\([hdwmy]\\)" 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"))
@@ -11935,7 +11935,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]+\\)\\([hdwmy]\\)" ts))))
 	  (org-timestamp-change n (cdr (assoc what whata)))
 	  (setq msg (concat msg type " " org-last-changed-timestamp " "))))
       (setq org-log-post-message msg)
@@ -11982,7 +11982,7 @@ can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
     (let* ((old-date (org-entry-get nil "DEADLINE"))
 	   (repeater (and old-date
 			  (string-match
-			   "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			   "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			   old-date)
 			  (match-string 1 old-date))))
       (if remove
@@ -12030,7 +12030,7 @@ either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
     (let* ((old-date (org-entry-get nil "SCHEDULED"))
 	   (repeater (and old-date
 			  (string-match
-			   "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			   "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			   old-date)
 			  (match-string 1 old-date))))
       (if remove
@@ -13161,7 +13161,7 @@ epoch to the beginning of today (00:00)."
      ((string= s "<today>") (org-time-today))
      ((string= s "<tomorrow>")   (+ 86400.0 (org-time-today)))
      ((string= s "<yesterday>")  (- (org-time-today) 86400.0))
-     ((string-match "^<\\([-+][0-9]+\\)\\([dwmy]\\)>$" s)
+     ((string-match "^<\\([-+][0-9]+\\)\\([hdwmy]\\)>$" s)
       (+ (org-time-today)
 	 (* (string-to-number (match-string 1 s))
 	    (cdr (assoc (match-string 2 s)
@@ -14793,7 +14793,7 @@ at the cursor, it will be modified."
 	 	     (save-match-data
 	 	       (beginning-of-line)
 	 	       (when (re-search-forward
-			      "\\([.+-]+[0-9]+[dwmy] ?\\)+" ;;\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			      "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ;;\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			      (save-excursion (progn (end-of-line) (point))) t)
 			 (match-string 0)))))
 	 org-time-was-given org-end-time-was-given time)
@@ -14894,7 +14894,7 @@ mean next year.  For details, see the manual.  A few examples:
   etc.
 
 Furthermore you can specify a relative date by giving, as the *first* thing
-in the input:  a plus/minus sign, a number and a letter [dwmy] to indicate
+in the input:  a plus/minus sign, a number and a letter [hdwmy] to indicate
 change in days weeks, months, years.
 With a single plus or minus, the date is relative to today.  With a double
 plus or minus, it is relative to the date in DEFAULT-TIME.  E.g.
@@ -15312,7 +15312,7 @@ DEF-FLAG   is t when a double ++ or -- indicates shift relative to
 	  (concat
 	   "\\`[ \t]*\\([-+]\\{0,2\\}\\)"
 	   "\\([0-9]+\\)?"
-	   "\\([dwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
+	   "\\([hdwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
 	   "\\([ \t]\\|$\\)") s)
 	 (or (> (match-end 1) (match-beginning 1)) (match-end 4)))
     (let* ((dir (if (> (match-end 1) (match-beginning 1))
@@ -15429,7 +15429,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)?\\'" ts)
 	  (setq off (- (match-end 0) (match-beginning 0)))))
     (setq end (- end off))
     (setq w1 (- end beg)
@@ -15500,7 +15500,7 @@ Don't touch the rest."
    ((<= org-deadline-warning-days 0)
     ;; 0 or negative, enforce this value no matter what
     (- org-deadline-warning-days))
-   ((string-match "-\\([0-9]+\\)\\([dwmy]\\)\\(\\'\\|>\\| \\)" ts)
+   ((string-match "-\\([0-9]+\\)\\([hdwmy]\\)\\(\\'\\|>\\| \\)" ts)
     ;; lead time is specified.
     (floor (* (string-to-number (match-string 1 ts))
 	      (cdr (assoc (match-string 2 ts)
@@ -15691,7 +15691,7 @@ The variable date is bound by the calendar when this is called."
     (if (org-diary-sexp-entry (match-string 1 s) "" date)
 	daynr
       (+ daynr 1000)))
-   ((and daynr (string-match "\\+[0-9]+[dwmy]" s))
+   ((and daynr (string-match "\\+[0-9]+[hdwmy]" s))
     (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
 			  (time-to-days (current-time))) (match-string 0 s)
 			  prefer show-all))
@@ -15802,7 +15802,7 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
 
       (if (<= cday sday) (throw 'exit sday))
 
-      (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change)
+      (if (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change)
 	  (setq dn (string-to-number (match-string 1 change))
 		dw (cdr (assoc (match-string 2 change) a1)))
 	(error "Invalid change specifier: %s" change))
@@ -15986,7 +15986,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)*\\)[]>]"
 	   ts)
 	  (setq extra (match-string 1 ts)))
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
@@ -16059,7 +16059,7 @@ in the timestamp determines what will be changed."
   "Change the different parts of the lead-time and repeat fields in timestamp."
   (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
 	ng h m new rem)
-    (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([dmwy]\\)\\)?\\( +-\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
+    (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([hdwmy]\\)\\)?\\( +-\\([0-9]+\\)\\([hdwmy]\\)\\)?" s)
       (cond
        ((or (org-pos-in-match-range pos 2)
 	    (org-pos-in-match-range pos 3))
-- 
1.7.1


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

* Re: [PATCH] Support hour in repeated task cookie
  2012-03-27 21:22 [PATCH] Support hour in repeated task cookie Takafumi Arakaki
@ 2012-03-31 20:54 ` Takafumi Arakaki
  2012-04-01  8:25   ` Bastien
  2012-04-23 13:10   ` Bastien
  2012-04-20 14:57 ` Bastien
  1 sibling, 2 replies; 7+ messages in thread
From: Takafumi Arakaki @ 2012-03-31 20:54 UTC (permalink / raw)
  To: emacs-orgmode

No comments? No one wants to have "+3h" in SCHEDULED?

--
Takafumi

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

* Re: [PATCH] Support hour in repeated task cookie
  2012-03-31 20:54 ` Takafumi Arakaki
@ 2012-04-01  8:25   ` Bastien
  2012-04-23 13:10   ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Bastien @ 2012-04-01  8:25 UTC (permalink / raw)
  To: Takafumi Arakaki; +Cc: emacs-orgmode

Hi Takafumi,

Takafumi Arakaki <aka.tkf@gmail.com> writes:

> No comments? No one wants to have "+3h" in SCHEDULED?

please be patient.  Developers are working on their free time.

Also, please refine the ChangeLog of your patch by adding an Emacs
changelog entry with `C-x 4 a'.  Because the patch is not trivial.
This is documented in 

  http://orgmode.org/worg/org-contribute.html

Thanks,

-- 
 Bastien

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

* Re: [PATCH] Support hour in repeated task cookie
  2012-03-27 21:22 [PATCH] Support hour in repeated task cookie Takafumi Arakaki
  2012-03-31 20:54 ` Takafumi Arakaki
@ 2012-04-20 14:57 ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Bastien @ 2012-04-20 14:57 UTC (permalink / raw)
  To: Takafumi Arakaki; +Cc: emacs-orgmode

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

Hi Takafumi,

Takafumi Arakaki <aka.tkf@gmail.com> writes:

> Basically, this patch changes all occurrence of "[dwmy]" with
> "[hdwmy]" and adds "("h" . hour)" to whata of org-auto-repeat-maybe.

I like this idea and I worked on a more complete patch.

I didn't replace "dwmy" by a constant though, this is not expected
to change anymore. 

Please all test the patch and report if it breaks things or if it
is useless.

Thanks Takafumi for this idea!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-hourly-repeat-cookies.patch --]
[-- Type: text/x-patch, Size: 12304 bytes --]

From 570c927d4bc5d24567378d7643bcc1540813c705 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Fri, 20 Apr 2012 16:55:48 +0200
Subject: [PATCH] Support hourly repeat cookies.

* org.el (org-repeat-re)
(org-clone-subtree-with-time-shift, org-auto-repeat-maybe)
(org-deadline, org-schedule, org-matcher-time)
(org-time-stamp, org-read-date, org-read-date-get-relative)
(org-display-custom-time, org-get-wdays)
(org-time-string-to-absolute, org-closest-date)
(org-timestamp-change): Allow to set hourly repeat cookie.
Send an error when an hourly repeat cookie is set and no hour
is specified in the timestamp.

* org.texi (Repeated tasks): Document repeat cookies for
years, months, weeks, days and hours.

* org-agenda.el (org-agenda-get-timestamps): Match hourly
repeat cookies.

* org-icalendar.el (org-print-icalendar-entries): Handle
hourly repeat cookies.

Thanks a lot to Takafumi Arakaki for this idea and for a preliminary
version of this patch.
---
 doc/org.texi          |    7 ++++---
 lisp/org-agenda.el    |    2 +-
 lisp/org-icalendar.el |    4 ++--
 lisp/org.el           |   38 ++++++++++++++++++++------------------
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index fd28352..09a8c4c 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5848,9 +5848,10 @@ or plain timestamp.  In the following example
 @noindent
 the @code{+1m} is a repeater; the intended interpretation is that the task
 has a deadline on <2005-10-01> and repeats itself every (one) month starting
-from that time.  If you need both a repeater and a special warning period in
-a deadline entry, the repeater should come first and the warning period last:
-@code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
+from that time.  You can use yearly, monthly, weekly, daily and hourly repeat
+cookies by using the @code{y/w/m/d/h} letters.  If you need both a repeater
+and a special warning period in a deadline entry, the repeater should come
+first and the warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
 
 @vindex org-todo-repeat-to-state
 Deadlines and scheduled items produce entries in the agenda when they are
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ffc27cc..7713c57 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4962,7 +4962,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 	      (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]+[hdwmy]>\\)"
 	   "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
 	 marker hdmarker deadlinep scheduledp clockp closedp inactivep
 	 donep tmp priority category org-category-pos ee txt timestr tags
diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
index ac6a661..d322786 100644
--- a/lisp/org-icalendar.el
+++ b/lisp/org-icalendar.el
@@ -403,12 +403,12 @@ When COMBINE is non nil, add the category to each line."
 	  (if (or (string-match org-tr-regexp hd)
 		  (string-match org-ts-regexp hd))
 	      (setq hd (replace-match "" t t hd)))
-	  (if (string-match "\\+\\([0-9]+\\)\\([dwmy]\\)>" ts)
+	  (if (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)>" ts)
 	      (setq rrule
 		    (concat "\nRRULE:FREQ="
 			    (cdr (assoc
 				  (match-string 2 ts)
-				  '(("d" . "DAILY")("w" . "WEEKLY")
+				  '(("h" . "HOURLY")("d" . "DAILY")("w" . "WEEKLY")
 				    ("m" . "MONTHLY")("y" . "YEARLY"))))
 			    ";INTERVAL=" (match-string 1 ts)))
 	    (setq rrule ""))
diff --git a/lisp/org.el b/lisp/org.el
index b2b140c..95145c0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -694,7 +694,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)"
   "Regular expression for specifying repeated events.
 After a match, group 1 contains the repeat expression.")
 
@@ -7967,7 +7967,7 @@ and still retain the repeater to cover future instances of the task."
     (if (not (and (integerp n) (> n 0)))
 	(error "Invalid number of replications %s" n))
     (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift)))
-	     (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
+	     (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([hdwmy]\\)[ \t]*\\'"
 				shift)))
 	(error "Invalid shift specification %s" shift))
     (when doshift
@@ -7985,7 +7985,7 @@ and still retain the repeater to cover future instances of the task."
     (setq end (point))
     (setq template (buffer-substring beg end))
     (when (and doshift
-	       (string-match "<[^<>\n]+ [.+]?\\+[0-9]+[dwmy][^<>\n]*>" template))
+	       (string-match "<[^<>\n]+ [.+]?\\+[0-9]+[hdwmy][^<>\n]*>" template))
       (delete-region beg end)
       (setq end beg)
       (setq nmin 0 nmax (1+ nmax) n-no-remove nmax))
@@ -8016,7 +8016,7 @@ and still retain the repeater to cover future instances of the task."
 		(while (re-search-forward org-ts-regexp nil t)
 		  (save-excursion
 		    (goto-char (match-beginning 0))
-		    (if (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[dwmy]\\)")
+		    (if (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[hdwmy]\\)")
 			(delete-region (match-beginning 1) (match-end 1)))))))
 	    (setq task (buffer-string)))
 	  (insert task))
@@ -11936,7 +11936,7 @@ This function is run automatically after each state change to a DONE state."
 	 (aa (assoc org-last-state org-todo-kwd-alist))
 	 (interpret (nth 1 aa))
 	 (head (nth 2 aa))
-	 (whata '(("d" . day) ("m" . month) ("y" . year)))
+	 (whata '(("h" . hour) ("d" . day) ("m" . month) ("y" . year)))
 	 (msg "Entry repeats: ")
 	 (org-log-done nil)
 	 (org-todo-log-states nil)
@@ -11972,10 +11972,12 @@ 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]+\\)\\([hdwmy]\\)" 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"))
+	  (if (and (equal what "h") (not (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)))
+	      (error "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
 	  ;; Preparation, see if we need to modify the start date for the change
 	  (when (match-end 1)
 	    (setq time (save-match-data (org-time-string-to-time ts)))
@@ -12001,7 +12003,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]+\\)\\([hdwmy]\\)" ts))))
 	  (org-timestamp-change n (cdr (assoc what whata)))
 	  (setq msg (concat msg type " " org-last-changed-timestamp " "))))
       (setq org-log-post-message msg)
@@ -12048,7 +12050,7 @@ can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
     (let* ((old-date (org-entry-get nil "DEADLINE"))
 	   (repeater (and old-date
 			  (string-match
-			   "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			   "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			   old-date)
 			  (match-string 1 old-date))))
       (if remove
@@ -12096,7 +12098,7 @@ either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
     (let* ((old-date (org-entry-get nil "SCHEDULED"))
 	   (repeater (and old-date
 			  (string-match
-			   "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			   "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			   old-date)
 			  (match-string 1 old-date))))
       (if remove
@@ -13250,7 +13252,7 @@ epoch to the beginning of today (00:00)."
      ((string= s "<today>") (org-time-today))
      ((string= s "<tomorrow>")   (+ 86400.0 (org-time-today)))
      ((string= s "<yesterday>")  (- (org-time-today) 86400.0))
-     ((string-match "^<\\([-+][0-9]+\\)\\([dwmy]\\)>$" s)
+     ((string-match "^<\\([-+][0-9]+\\)\\([hdwmy]\\)>$" s)
       (+ (org-time-today)
 	 (* (string-to-number (match-string 1 s))
 	    (cdr (assoc (match-string 2 s)
@@ -14946,7 +14948,7 @@ at the cursor, it will be modified."
 	 	     (save-match-data
 	 	       (beginning-of-line)
 	 	       (when (re-search-forward
-			      "\\([.+-]+[0-9]+[dwmy] ?\\)+" ;;\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+			      "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ;;\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
 			      (save-excursion (progn (end-of-line) (point))) t)
 			 (match-string 0)))))
 	 org-time-was-given org-end-time-was-given time)
@@ -15048,7 +15050,7 @@ mean next year.  For details, see the manual.  A few examples:
   etc.
 
 Furthermore you can specify a relative date by giving, as the *first* thing
-in the input:  a plus/minus sign, a number and a letter [dwmy] to indicate
+in the input:  a plus/minus sign, a number and a letter [hdwmy] to indicate
 change in days weeks, months, years.
 With a single plus or minus, the date is relative to today.  With a double
 plus or minus, it is relative to the date in DEFAULT-TIME.  E.g.
@@ -15466,7 +15468,7 @@ DEF-FLAG   is t when a double ++ or -- indicates shift relative to
 	  (concat
 	   "\\`[ \t]*\\([-+]\\{0,2\\}\\)"
 	   "\\([0-9]+\\)?"
-	   "\\([dwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
+	   "\\([hdwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
 	   "\\([ \t]\\|$\\)") s)
 	 (or (> (match-end 1) (match-beginning 1)) (match-end 4)))
     (let* ((dir (if (> (match-end 1) (match-beginning 1))
@@ -15583,7 +15585,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)?\\'" ts)
 	  (setq off (- (match-end 0) (match-beginning 0)))))
     (setq end (- end off))
     (setq w1 (- end beg)
@@ -15654,7 +15656,7 @@ Don't touch the rest."
    ((<= org-deadline-warning-days 0)
     ;; 0 or negative, enforce this value no matter what
     (- org-deadline-warning-days))
-   ((string-match "-\\([0-9]+\\)\\([dwmy]\\)\\(\\'\\|>\\| \\)" ts)
+   ((string-match "-\\([0-9]+\\)\\([hdwmy]\\)\\(\\'\\|>\\| \\)" ts)
     ;; lead time is specified.
     (floor (* (string-to-number (match-string 1 ts))
 	      (cdr (assoc (match-string 2 ts)
@@ -15845,7 +15847,7 @@ The variable date is bound by the calendar when this is called."
     (if (org-diary-sexp-entry (match-string 1 s) "" date)
 	daynr
       (+ daynr 1000)))
-   ((and daynr (string-match "\\+[0-9]+[dwmy]" s))
+   ((and daynr (string-match "\\+[0-9]+[hdwmy]" s))
     (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
 			  (time-to-days (current-time))) (match-string 0 s)
 			  prefer show-all))
@@ -15956,7 +15958,7 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
 
       (if (<= cday sday) (throw 'exit sday))
 
-      (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change)
+      (if (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change)
 	  (setq dn (string-to-number (match-string 1 change))
 		dw (cdr (assoc (match-string 2 change) a1)))
 	(error "Invalid change specifier: %s" change))
@@ -16140,7 +16142,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]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)*\\)[]>]"
 	   ts)
 	  (setq extra (match-string 1 ts)))
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
-- 
1.7.9.4


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

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

* Re: [PATCH] Support hour in repeated task cookie
  2012-03-31 20:54 ` Takafumi Arakaki
  2012-04-01  8:25   ` Bastien
@ 2012-04-23 13:10   ` Bastien
  2012-04-26 14:38     ` Takafumi Arakaki
  1 sibling, 1 reply; 7+ messages in thread
From: Bastien @ 2012-04-23 13:10 UTC (permalink / raw)
  To: Takafumi Arakaki; +Cc: emacs-orgmode

Hi Takafumi,

Takafumi Arakaki <aka.tkf@gmail.com> writes:

> No comments? No one wants to have "+3h" in SCHEDULED?

I applied this patch, thanks.

Note that timestamps need to be well formatted.  If there is
a +3d repeat cookie and the original timestamp doesn have any 
indication for the hour, it will produce an error.

-- 
 Bastien

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

* Re: [PATCH] Support hour in repeated task cookie
  2012-04-23 13:10   ` Bastien
@ 2012-04-26 14:38     ` Takafumi Arakaki
  2012-04-27 21:34       ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Takafumi Arakaki @ 2012-04-26 14:38 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi, Bastien

Thanks for the patch and I am sorry for this late reply (especially
because I pushed maintainers to review my patch before...).

Anyway, I tried the head of master
(580add2f4148fea949a4db5550577911ee6d756e) and it works fine for me.
But I couldn't reproduce this behavior:

> Note that timestamps need to be well formatted.  If there is
> a +3d repeat cookie and the original timestamp doesn have any
> indication for the hour, it will produce an error.

(BTW, you mean +3h, right?)  There is no change in the SCHEDULE time
stamp, but I've got state change log and LAST_REPEAT in PROPERTIES.
Note that I have `(setq org-log-into-drawer t)' in my configuration.
Resulting tree was something like this (I changed the state to DONE
three times):

* TODO Test
  SCHEDULED: <2012-04-26 Thu +3h>
  :LOGBOOK:
  - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
  - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
  - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
  :END:
  :PROPERTIES:
  :LAST_REPEAT: [2012-04-26 Thu 16:16]
  :END:


Regarding not using constant for "dwmy".

> I didn't replace "dwmy" by a constant though, this is not expected
> to change anymore.

I think somebody may want to have minute cookie.  And in that case,
repeating the same task is tiresome.  I didn't put minute in my patch
simply because I didn't know what letter I should use.  I guess no one
wants second or century though.  So maybe we should decide what letter
to use for minute and change "dwmy" again, if you don't like the
constant solution?

--
Takafumi

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

* Re: [PATCH] Support hour in repeated task cookie
  2012-04-26 14:38     ` Takafumi Arakaki
@ 2012-04-27 21:34       ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2012-04-27 21:34 UTC (permalink / raw)
  To: Takafumi Arakaki; +Cc: emacs-orgmode

Hi Takafumi,

Takafumi Arakaki <aka.tkf@gmail.com> writes:

> Anyway, I tried the head of master
> (580add2f4148fea949a4db5550577911ee6d756e) and it works fine for me.
> But I couldn't reproduce this behavior:
>
>> Note that timestamps need to be well formatted.  If there is
>> a +3d repeat cookie and the original timestamp doesn have any
>> indication for the hour, it will produce an error.
>
> (BTW, you mean +3h, right?)  There is no change in the SCHEDULE time
> stamp, but I've got state change log and LAST_REPEAT in PROPERTIES.
> Note that I have `(setq org-log-into-drawer t)' in my configuration.
> Resulting tree was something like this (I changed the state to DONE
> three times):
>
> * TODO Test
>   SCHEDULED: <2012-04-26 Thu +3h>
>   :LOGBOOK:
>   - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
>   - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
>   - State "DONE"       from "TODO"        [2012-04-26 Thu 16:16]
>   :END:
>   :PROPERTIES:
>   :LAST_REPEAT: [2012-04-26 Thu 16:16]
>   :END:

Yes -- please ping the list about this issue if you find it nagging
when using the feature an a regular basis.

> Regarding not using constant for "dwmy".
>
>> I didn't replace "dwmy" by a constant though, this is not expected
>> to change anymore.
>
> I think somebody may want to have minute cookie.  

Well, let's wait for somebody to dare asking this!  Seriously, I would
put a constant if this game had no end, but luckily enough, I don't
think we can go beyond minutes... 

Thanks for the feedback!

-- 
 Bastien

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

end of thread, other threads:[~2012-04-27 21:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 21:22 [PATCH] Support hour in repeated task cookie Takafumi Arakaki
2012-03-31 20:54 ` Takafumi Arakaki
2012-04-01  8:25   ` Bastien
2012-04-23 13:10   ` Bastien
2012-04-26 14:38     ` Takafumi Arakaki
2012-04-27 21:34       ` Bastien
2012-04-20 14:57 ` Bastien

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