浏览代码

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
Sacha Chua 12 年之前
父节点
当前提交
e82fb4402c
共有 2 个文件被更改,包括 11 次插入4 次删除
  1. 3 2
      doc/org.texi
  2. 8 2
      lisp/org.el

+ 3 - 2
doc/org.texi

@@ -5875,7 +5875,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
@@ -5900,7 +5900,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

+ 8 - 2
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)))))