From 90dcd9f63351d346fb65b10897d61b7300dddffa Mon Sep 17 00:00:00 2001
From: Sacha Chua <sacha@sachachua.com>
Date: Fri, 12 Apr 2013 19:19:16 -0400
Subject: [PATCH] Change relative weekday specifications (ex: fri or -tue) to
 exclude today

* lisp/org.el (org-read-date-get-relative): Handle positive and
negative weekday specifications so that they don't return today.
If today is Friday, "fri" should mean next Friday. This changes
the previous behavior, which required you to specify "+2fri" in
order to mean next Friday if today was Friday. If you want to
schedule something for today, you can use ".".

* doc/org.texi (The date/time prompt): Update the documentation
to reflect the new way `org-read-date-get-relative' handles
weekdays.

TINYCHANGE
---
 doc/org.texi |  5 +++--
 lisp/org.el  | 10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index ac66b79..7ecd057 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5881,7 +5881,7 @@ in @b{bold}.
 14            @result{} @b{2006}-@b{06}-14
 12            @result{} @b{2006}-@b{07}-12
 2/5           @result{} @b{2007}-02-05
-Fri           @result{} nearest Friday (default date or later)
+Fri           @result{} nearest Friday after the default date
 sep 15        @result{} @b{2006}-09-15
 feb 15        @result{} @b{2007}-02-15
 sep 12 9      @result{} 2009-09-12
@@ -5906,7 +5906,8 @@ the abbreviation of day name, the date will be the Nth such day, e.g.:
 +4            @result{} same as above
 +2w           @result{} two weeks from today
 ++5           @result{} five days from default date
-+2tue         @result{} second Tuesday from now.
++2tue         @result{} second Tuesday from now
+-wed          @result{} last Wednesday
 @end example
 
 @vindex parse-time-months
diff --git a/lisp/org.el b/lisp/org.el
index bbbeb7a..cf5c9a9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16141,7 +16141,8 @@ mean next year.  For details, see the manual.  A few examples:
   12:45         --> today 12:45
   22 sept 0:34  --> currentyear-09-22 0:34
   12            --> currentyear-currentmonth-12
-  Fri           --> nearest Friday (today or later)
+  Fri           --> nearest Friday after today
+  -Tue          --> last Tuesday
   etc.
 
 Furthermore you can specify a relative date by giving, as the *first* thing
@@ -16529,7 +16530,12 @@ DEF-FLAG   is t when a double ++ or -- indicates shift relative to
       (if wday1
 	  (progn
 	    (setq delta (mod (+ 7 (- wday1 wday)) 7))
-	    (if (= dir ?-) (setq delta (- delta 7)))
+	    (if (= delta 0) (setq delta 7))
+	    (if (= dir ?-)
+		(progn
+		  (setq delta (- delta 7))
+		  (if (= delta 0) (setq delta -7))
+		  ))
 	    (if (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7)))))
 	    (list delta "d" rel))
 	(list (* n (if (= dir ?-) -1 1)) what rel)))))
-- 
1.8.1.msysgit.1

